Hi all,

Consider the following snippet:

import sympy as sy
from sympy.abc import x
from sympy.mpmath import mp

N = 4
mp.dps = 30

# Way 1
Pn1 = sy.legendre_poly(N, x)
dPn1 = Pn1.diff()

print dPn1.evalf(mp.dps, subs={x: mp.sqrt(2)})

# Way 2
Pn2 = sy.Poly(sy.legendre_poly(N, x))
dPn2 = Pn2.diff()

print dPn2.evalf(mp.dps, subs={x: mp.sqrt(2)})


which gives:

38.8908729652601138420464399158
38.8908729654156128699457970986

with the second value (from dPn2.evalf(...)) being incorrect.  It
appears as if the mp.sqrt(2) in the second case is being cast to a float
somewhere when evaluating an sy.Poly.  Can someone explain what is going on?

Polemically yours, Freddie.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to