mp.invertlaplace(fp,t,method='talbot') raise TypeError("cannot create mpf from " + repr(x))

17 views
Skip to first unread message

rupu...@gmail.com

unread,
Dec 13, 2018, 6:01:31 AM12/13/18
to mpmath
Dear all,
When I try to use following syntax to obtain the inverse laplace result, the system raise error information TypeError("cannot create mpf from " + repr(x)).
>>>
import mpmath as mp
from functools import reduce
s = sp.symbols('s')
x = sp.symbols('x')
y = sp.symbols('y')

wse =[mp.exp(-0.5*s)/(s + 1), mp.exp(-2*s)/(3*s + 1)]
a = (reduce(lambda x,y: x*y, wse[0]))
fp = lambda s:a/s
b = mp.invertlaplace(fp,t=10,method='talbot')
print(b)
>>>
Since the list of wse will change in my loops, I didn't do the inverse laplace transfer directly.
Can someone help me to tackle the problem?
Thank you in advance.
Rupu

Kris Kuhlman

unread,
Dec 13, 2018, 6:44:10 AM12/13/18
to mpm...@googlegroups.com
If you replace “sp.symbols” with numerical values for those variables and make the functions in wse into lambdas, it may work (I can’t test it right now). Try evaluating the function “by hand” before passing it to the invertlaplace function.

This is a numerical inversion algorithm, not an algebraic one.

Kris

--
You received this message because you are subscribed to the Google Groups "mpmath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpmath+un...@googlegroups.com.
To post to this group, send email to mpm...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpmath.
For more options, visit https://groups.google.com/d/optout.

haha Yang

unread,
Dec 13, 2018, 7:48:48 AM12/13/18
to mpm...@googlegroups.com
Thank you Kris,
But symbols "s" is factor in laplace format, and "x,y" will help to multiply the elements is a list. And to tackle a general problem, I am afraid I have to keep these symbols.
Rupu

Kris Kuhlman <kristophe...@gmail.com> 于2018年12月13日周四 下午12:44写道:
Reply all
Reply to author
Forward
0 new messages