python - inverse laplace transform in Sympy - Stack Overflow

admin2025-04-17  4

I am stuck with the inverse laplace using sympy for the function

(21.4375*s**2 - 128.5*s + 1.0)/(-187.03125*s**3 - 297.9375*s**2 - 126.0*s + 1.0)

it shows RisingFactorial(_t + 1, 1.0) contains an element of the set of generators.

I was using sympy

Aprox_t = inverse_laplace_transform(PD_s, s, t)
pprint(Aprox_t)

I am stuck with the inverse laplace using sympy for the function

(21.4375*s**2 - 128.5*s + 1.0)/(-187.03125*s**3 - 297.9375*s**2 - 126.0*s + 1.0)

it shows RisingFactorial(_t + 1, 1.0) contains an element of the set of generators.

I was using sympy

Aprox_t = inverse_laplace_transform(PD_s, s, t)
pprint(Aprox_t)
Share Improve this question edited Feb 1 at 18:13 ti7 19k7 gold badges47 silver badges79 bronze badges asked Feb 1 at 17:24 Pankit ChahalPankit Chahal 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I suspect the cause of the problems are the floating point numbers. Just convert them to rational with nsimplify, then the computation runs correctly:

from sympy import *
var("s, t")
expr = (21.4375*s**2 - 128.5*s + 1.0)/(-187.03125*s**3 - 297.9375*s**2 - 126.0*s + 1.0)
expr = expr.nsimplify()
res = inverse_laplace_transform(expr, s, t)

If that doesn't work, you might want to check which sympy version you are using with import sympy as sp;print(sp.__version__). I'm using 1.13.1, but the latest is 1.13.3.

转载请注明原文地址:http://anycun.com/QandA/1744822237a88095.html