I'm trying to do the inverse Laplace transform of a generalized rational function of the form: D/(A*s**2 + B*s + C) using sympy.
from sympy import *
from sympy import inverse_laplace_transform as ilt
from sympy.abc import s, t
var('A:D')
eq = D/(A*s**2 + B*s + C)
solution = ilt(eq, s, t)
Knowing the answer from mathematical analysis to be:
-(A (e^(t (-1/2 sqrt(C^2-4 B)-C/2))-e^(t (1/2 sqrt(C^2-4 B)-C/2))))/sqrt(C^2-4 B)
But the sympy will NOT yield a solution and the code will stuck in an infinity CPU process with no specific gain. But putting the eq like this:
eq = B/((s - A)**2 + B**2)
sympy will result in the equation of the form like this:
-I*(I*exp(t*im(B))*sin(t*(re(B) - im(A))) - exp(t*im(B))*cos(t*(re(B) - im(A)))
+ I*exp(-t*im(B))*sin(t*(re(B) + im(A))) + exp(-t*im(B))*cos(t*(re(B) + im(A))))
*exp(t*re(A))*Heaviside(t)/2
Which is not what I would need to. Any suggestions on how to make sympy yield to such a human readable answer?
Looking at the traceback, this looks like a legitimate bug. You should report it in the SymPy issue tracker.