Hi,
On 18 June 2013 12:26, Chris Smith <[email protected]> wrote:
> There is still a potential problem here:
>
> Consider an unfactorable polynomial
>
> >>> eq = x**5-x**3+1
> >>> factor(_)
> x**5 - x**3 + 1
>
> find where it has zeros
>
> >>> df = eq.diff(x)
> >>> solve(df)
> [0, -sqrt(15)/5, sqrt(15)/5]
>
> shift the polynomial to put one of the zeros on the x axis
>
> >>> eq.subs(x,_[1])
> 6*sqrt(15)/125 + 1
> >>> eq=Poly(eq-_, x)
>
> Now
>
> 1) intervals can't be used
>
> >>> eq.intervals()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "sympy\polys\polytools.py", line 2942, in intervals
> all=all, eps=eps, inf=inf, sup=sup, fast=fast, sqf=sqf)
> File "sympy\polys\polyclasses.py", line 749, in intervals
> return dup_isolate_real_roots(f.rep, f.dom, eps=eps, inf=inf, sup=sup,
> fast=
> fast)
> File "sympy\polys\rootisolation.py", line 512, in dup_isolate_real_roots
> raise DomainError("isolation of real roots not supported over %s" % K)
> sympy.polys.polyerrors.DomainError: isolation of real roots not supported
> over E
> X
>
> 2) solve doesn't even give RootOf solutions
>
> >>> solve(eq)
> []
>
> 3) sqf doesn't do anything
>
> >>> sqf(eq)
> x**5 - x**3 - 6*sqrt(15)/125
>
> But there are 2 roots
>
> >>> nsolve(eq.as_expr(),x,-1)
> mpf('-0.77459665120927842')
> >>> nsolve(eq.as_expr(),x,1)
> mpf('1.0726704244933239')
>
All root isolation algorithms work only on polynomials with rational
coefficients (really integer coefficients, but we can employ the obvious
conversion). Even Mathematica has this limitation. Try Poly.lift() to
remove algebraic numbers.
To make sqf() work you have to force algebraic domain instead of the
default EX, e.g.:
In [8]: sqf(x**5 - x**3 - 6*sqrt(15)/125, extension=True)
Out[8]:
2
⎛ ____⎞ ⎛ ____ 2 ____⎞
⎜ ╲╱ 15 ⎟ ⎜ 3 2⋅╲╱ 15 ⋅x 4⋅x 2⋅╲╱ 15 ⎟
⎜x + ──────⎟ ⋅⎜x - ─────────── + ─── - ────────⎟
⎝ 5 ⎠ ⎝ 5 5 25 ⎠
> /c
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
Mateusz
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.