Actually, the second argument of rising (and falling) factorial should always be an integer. I think that `as_int` would be a good solution, it is reasonable to allow integral floating point values. It would probably raise an error in some cases where unevaluated expression is currently returned, but those should be fixed anyway.
Kalevi Suominen On Thursday, May 7, 2020 at 12:28:29 AM UTC+3, czgdp1807 wrote: > > May be using `as_int` with the second argument in `RisingFactorial` should > solve the problem. Just an idea. > > With Regards, > Gagandeep Singh > Github - https://github.com/czgdp1807 > LinkedIn - https://www.linkedin.com/in/czgdp1807 > > On Thu, 7 May, 2020, 2:55 AM Aaron Meurer, <[email protected]> wrote: > >> Here is the error >> >> >>> inverse_laplace_transform(0.5/(.5*s+1)*1/s, s, t) >> Traceback (most recent call last): >> File "./sympy/polys/polyutils.py", line 211, in >> _parallel_dict_from_expr_if_gens >> monom[indices[base]] = exp >> KeyError: RisingFactorial(_t + 1, 2.0) >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "./sympy/polys/partfrac.py", line 82, in apart >> (P, Q), opt = parallel_poly_from_expr((P, Q), x, **options) >> File "./sympy/polys/polytools.py", line 4301, in parallel_poly_from_expr >> return _parallel_poly_from_expr(exprs, opt) >> File "./sympy/polys/polytools.py", line 4354, in >> _parallel_poly_from_expr >> reps, opt = _parallel_dict_from_expr(exprs, opt) >> File "./sympy/polys/polyutils.py", line 332, in _parallel_dict_from_expr >> reps, gens = _parallel_dict_from_expr_if_gens(exprs, opt) >> File "./sympy/polys/polyutils.py", line 217, in >> _parallel_dict_from_expr_if_gens >> "the set of generators." % factor) >> sympy.polys.polyerrors.PolynomialError: RisingFactorial(_t + 1, 2.0) >> contains an element of the set of generators. >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "./sympy/integrals/transforms.py", line 1293, in >> inverse_laplace_transform >> return InverseLaplaceTransform(F, s, t, plane).doit(**hints) >> File "./sympy/integrals/transforms.py", line 121, in doit >> self.function_variable, self.transform_variable, **hints) >> File "./sympy/integrals/transforms.py", line 1245, in _compute_transform >> return _inverse_laplace_transform(F, s, t, self.fundamental_plane, >> **hints) >> File "./sympy/integrals/transforms.py", line 206, in wrapper >> res = func(*args, **kwargs) >> File "./sympy/integrals/transforms.py", line 1172, in >> _inverse_laplace_transform >> needeval=True, noconds=False) >> File "./sympy/integrals/transforms.py", line 875, in >> inverse_mellin_transform >> return InverseMellinTransform(F, s, x, strip[0], >> strip[1]).doit(**hints) >> File "./sympy/integrals/transforms.py", line 121, in doit >> self.function_variable, self.transform_variable, **hints) >> File "./sympy/integrals/transforms.py", line 819, in _compute_transform >> return _inverse_mellin_transform(F, s, x, strip, **hints) >> File "./sympy/integrals/transforms.py", line 206, in wrapper >> res = func(*args, **kwargs) >> File "./sympy/integrals/transforms.py", line 746, in >> _inverse_mellin_transform >> h = hyperexpand(G) >> File "./sympy/simplify/hyperexpand.py", line 2491, in hyperexpand >> return f.replace(hyper, do_replace).replace(meijerg, do_meijer) >> File "./sympy/core/basic.py", line 1508, in replace >> rv = bottom_up(self, rec_replace, atoms=True) >> File "./sympy/simplify/simplify.py", line 1152, in bottom_up >> rv = F(rv) >> File "./sympy/core/basic.py", line 1489, in rec_replace >> new = _value(expr, result) >> File "./sympy/core/basic.py", line 1437, in <lambda> >> _value = lambda expr, result: value(*expr.args) >> File "./sympy/simplify/hyperexpand.py", line 2488, in do_meijer >> allow_hyper, rewrite=rewrite, place=place) >> File "./sympy/simplify/hyperexpand.py", line 2373, in _meijergexpand >> t, 1/z0) >> File "./sympy/simplify/hyperexpand.py", line 2346, in do_slater >> t, premult, au, rewrite=None) >> File "./sympy/simplify/hyperexpand.py", line 2042, in _hyperexpand >> formula = try_lerchphi(func) >> File "./sympy/simplify/hyperexpand.py", line 1783, in try_lerchphi >> part = apart(numer/denom, t) >> File "./sympy/utilities/decorator.py", line 36, in threaded_func >> return func(expr, *args, **kwargs) >> File "./sympy/polys/partfrac.py", line 85, in apart >> raise PolynomialError(msg) >> sympy.polys.polyerrors.PolynomialError: RisingFactorial(_t + 1, 2.0) >> contains an element of the set of generators. >> >> It looks like somewhere in the integration algorithm it creates >> RisingFactorial(t + 1, 2.0) expecting it to be converted to a >> polynomial. But this only works if the second argument is an integer, >> not a float >> >> >>> RisingFactorial(t + 1, 2) >> (t + 1)*(t + 2) >> >>> RisingFactorial(t + 1, 2.0) >> RisingFactorial(t + 1, 2.0) >> >> I would suggest opening an issue for this. >> >> Aaron Meurer >> >> On Wed, May 6, 2020 at 3:00 PM Oscar Benjamin >> <[email protected]> wrote: >> > >> > Hi Javier, >> > >> > I'm not sure exactly the problem with the example you showed. I think >> > it's a bug somewhere. >> > >> > It is usually better not to use floats in sympy. With exact rational >> > numbers your example works for me: >> > >> > In [17]: inverse_laplace_transform(S.Half/(S.Half*s+1)*1/s, s, t) >> > Out[17]: >> > -2⋅t >> > θ(t) ℯ ⋅θ(t) >> > ──── - ───────── >> > 2 2 >> > >> > >> > Oscar >> > >> > On Wed, 6 May 2020 at 18:36, Javier Arantegui >> > <[email protected]> wrote: >> > > >> > > Hello! >> > > >> > > I'm using Sympy 1.5.1 and Python is 3.7.7. Both installed using >> Anaconda. >> > > >> > > I have tried to do an inverse Laplace transform and I got an error: >> > > >> > > inverse_laplace_transform(0.5/(.5*s+1)*1/s, s, t) >> > > >> > > The error message is quite long, tell me if you need it. >> > > >> > > I spent 10 minutes in front of my students trying to think what was >> wrong... >> > > >> > > Finally, I was able to solve it with an easy change: >> > > >> > > inverse_laplace_transform(0.5*2/(2*(.5*s+1))*1/s, s, t) >> > > >> > > >> > > Best regards, >> > > >> > > Javier >> > > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups "sympy" group. >> > > To unsubscribe from this group and stop receiving emails from it, >> send an email to [email protected]. >> > > To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/aa5c4270-6c71-485b-8354-b5ea39e9c380%40googlegroups.com >> . >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "sympy" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/CAHVvXxQkmTvjGMWwe40mw3EFrk2eF2%2BY3hjiPpT9Xde8OYJb0A%40mail.gmail.com >> . >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/CAKgW%3D6LgE8sggDZFK94_EGbrgOSfq%3Dx1GpEjnAx0ng7zCzKybQ%40mail.gmail.com >> . >> > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4954a005-3074-485b-b08f-20efd1d933e6%40googlegroups.com.
