I want to calculate inverse laplace of e^(-2s) which is dirac(t-2), but sympy gives unevaluated.
More generally, SymPy's integrator doesn't know how to return delta
functions. It only knows how to deal with delta functions as arguments
to integrals.
import sympy as sp
from sympy.abc import t, s, c
F=5*sp.exp(-3*s)+2*sp.exp(c*s)-2*sp.exp(-2*s)/s
f=0; a_ = sp.Wild("a_"); b_ = sp.Wild("b_")
Fr=F.rewrite(sp.exp)
if type(Fr)==sp.Add:
terms=Fr.expand().args
else:
terms=(Fr,)
for term in terms:
#compute the Laplace transform for each term
r=sp.simplify(term).match(a_*sp.exp(b_))
if r!=None and sp.diff(term,s)!=0:
rlist=list(r.values())
modulus=rlist[0]
phase=rlist[1]/s
# if a is constant and b/s is constant
if sp.diff(modulus,s)==0 and sp.diff(phase,s)==0:
f = f + modulus*sp.DiracDelta(t+phase)
else:
f = f + sp.Subs(sp.inverse_laplace_transform(term, s, t),sp.Heaviside(t),1).doit()
elif sp.diff(term,s)==0:
f = f + term*sp.DiracDelta(t)
else:
f = f + sp.Subs(sp.inverse_laplace_transform(term, s, t),sp.Heaviside(t),1).doit()
--
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 post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4c84d52b-894e-4bc8-bb0f-e187d69213ec%40googlegroups.com.