Perhaps you should give Float a precision corresponding to eps.

Aaron Meurer

On Tue, Jun 18, 2013 at 4:52 PM, smichr <smi...@gmail.com> wrote:
> So altogether, finding the real roots might look something like this:
>
>>>>
> ... def rroots(eq, x, eps=None):
> ...     p = sqf(Poly(eq, x, extension=True).lift())
> ...     if p.is_Mul:
> ...         p = [pi.base if pi.is_Pow else pi for pi in p.args]
> ...     else:
> ...         p = [p]
> ...     intv = flatten([Poly(pi, x).intervals(eps=eps) for pi in p], 1)
> ...     rv = []
> ...     for (a, b), c in intv:
> ...         try:
> ...             root = nsolve(eq, x, (a+b)/2, tol=eps)
> ...             if a <= root <= b:
> ...                 rv.append(Float(root))
> ...         except: pass
> ...     return rv
> ...
>>>> rroots(eq,x,eps=.1)
> [-0.774799299008846, 1.07288890926981]
>>>> rroots(eq,x)
> [-0.774596691590882, 1.07267042449333]
>
> --
> 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 sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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 sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to