Can you see if it works correctly in https://github.com/sympy/sympy/pull/1497?

Aaron Meurer

On Mon, Oct 15, 2012 at 3:01 AM, Freddie Witherden
<[email protected]> wrote:
> Hi all,
>
> When attempting to find the roots of a Legendre polynomial:
>
> In [3]: from sympy import Poly, legendre_poly
>
> In [4]: lp = Poly(legendre_poly(5))
>
> In [5]: [float(r.evalf()) for r in lp.all_roots()]
> Out[5]:
> [-0.5384693101056831,
>  -0.5384693101056831,
>  0.0,
>  0.5384693101056831,
>  0.906179845938664]
>
> Observe now the first root, which should be -0.906, gets found as
> -0.538.  I /suspect/ this is because the RootOf.evalf() method uses
> nsolve -- or something analogous -- which requires an initial guess.
>
> mpmath.polysolve does the job (and on account of the method used does
> not have any trouble finding all of the roots) but has a less direct
> syntax.  (Specifically, if one tries to pass the output from
> .all_coeffs() as the coeffs parameter to mpmath.polysolve the method
> enters an infinite loop; it is necessary to explicitly run:
>
> mpmath.polysolve([float(c) for c in lp.all_coeffs()])
>
> Regards, Freddie.
>

-- 
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.

Reply via email to