Hi everyone,
I am having trouble combining mpmath's findroot function with sympy.
Here is a short example of what I am trying to accomplish:
import sympy
import mpmath
mpmath.mp.dps = 45
x = sympy.var('x')
p = (5.0/2.0*x**3 - 3.0/2.0*x).as_poly()
print 'subs: ', mpmath.findroot(lambda xi: p.subs(x, xi), 1.0)
print 'lambda:', mpmath.findroot(lambda x: 5.0*x**3/2.0 - 3.0*x/2.0,
1.0)
print 'exact: ', mpmath.sqrt(mpmath.mpf('3.0')/mpmath.mpf('5.0'))
The output is:
subs: 0.77459666924148342341315597798728447146706553
lambda: 0.774596669241483377035853079956479922166584341
exact: 0.774596669241483377035853079956479922166584341
That is, when using mpmath.findroot, substituting into a SymPy
polynomial does not produce the same result as using a lambda form
with a handwritten version of the polynomial. Is there a way to the
SymPy subs method to work as expected?
Thanks,
Matt
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.