Inverse Laplace Transform

61 views
Skip to first unread message

Javier Arántegui

unread,
Feb 26, 2021, 2:08:22 PM2/26/21
to sy...@googlegroups.com
Hello,

I have tried to do the inverse Laplace transform of ‘2/((3*s + 1)*(s**2 + 1))’ and I got a really ugly result. Fortunately it’s easy to get a much better solution.

It wouldn’t surprise me to know that I’m doing something wrong... If not, I hope it could improve in someway how Sympy does the inverse Laplace transform.

Here is the Jupyter session showing how I got that ugly solution:

+*In[1]:*+
[source, ipython3]
----
from sympy import *
t = symbols("t", real=True)
s = symbols("s")

y = 2/((3*s + 1)*(s**2 + 1))

inverse_laplace_transform(y, s, t)
----


+*Out[1]:*+
----
2*(-(I*sin(t) - cos(t))*gamma(-2*I)*gamma(1/3 - I)/(gamma(1 - 2*I)*gamma(4/3 - I)) + (I*sin(t) + cos(t))*gamma(2*I)*gamma(1/3 + I)/(gamma(1 + 2*I)*gamma(4/3 + I)) + exp(-t/3)*gamma(-1/3 - I)*gamma(-1/3 + I)/(gamma(2/3 - I)*gamma(2/3 + I)))*Heaviside(t)/3
----

The solution could be improved a lot if we perform a partial fraction decomposition and then do the inverse Laplace transform:

+*In[2]:*+
[source, ipython3]
----
yapart = apart(expand(y))
yapart
----


+*Out[2]:*+
----
-(3*s - 1)/(5*(s**2 + 1)) + 9/(5*(3*s + 1))
----


+*In[3]:*+
[source, ipython3]
----
inverse_laplace_transform(yapart.args[0], s, t) + \
inverse_laplace_transform(yapart.args[1], s, t)
----

+*Out[3]:*+
----
(sin(t) - 3*cos(t))*Heaviside(t)/5 + 3*exp(-t/3)*Heaviside(t)/5
----

Maybe it could be a good idea if the inverse Laplace transform performed this decomposition.

Javier

Aaron Meurer

unread,
Feb 26, 2021, 2:18:24 PM2/26/21
to sympy
I agree. It's a known issue that the integral transforms need to
improve the way they handle cases like this. Although it would also be
nice if simplify() could reduce the large expression into the smaller
one. The gamma functions should apparently all cancel, but gammasimp()
doesn't know how to do this.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/58060483-977C-4F60-99E9-81F6846108B5%40gmail.com.
Reply all
Reply to author
Forward
0 new messages