Sympy computes the inverse Laplace transform

I'm having trouble calculating the inverse Laplace transform of a symbolic expression using sympy. In Matlab and in the book, I work from the expression s / (s ^ 2 + w ^ 2) is converted to cos (wt).

When I try to do this with sympy, for example:

expression = s/(s**2+w**2) Answer = sympy.inverse_laplace_transform(expression, s, t) 

I get that

 Answer = (-I*exp(2*t*im(w))*sin(t*re(w)) + exp(2*t*im(w))*cos(t*re(w)) + I*sin(t*re(w)) + cos(t*re(w)))*exp(-t*im(w))*Heaviside(t)/2 

What am I doing wrong?

+5
source share
1 answer

Sympy suggests that w is complex-valued. A simpler approach is to provide the real=True option in the character definition.

 s, t = sp.symbols('s, t') w = sp.symbols('w', real = True) expression = s/(s**2+w**2) sympy.inverse_laplace_transform(expression, s, t) 

cos(t*w)*Heaviside(t)

+6
source

Source: https://habr.com/ru/post/1260998/


All Articles