Hi,

On 24 May 2011 21:13, Chris Smith <smi...@gmail.com> wrote:

> Andy Ray Terrel wrote:
> > Quite strange indeed.
> >
> > On my Mac Python 2.7, sympy.__version__ = 0.6.7 I get:
> >
> > In [17]: expr = (2.1 - 2.1*y**2 + 2*x)/x**3
> >
> > In [18]: sympy.simplify(expr)
> > Out[18]: -inf
> >
> This raises an error for me:
>
>    raise ValueError("can't raise polynomial to a negative power")
>    ValueError: can't raise polynomial to a negative power
>
> But if I nsimplify(..., rational=True) everthing works ok:
>
>    h[12] >>> e1= (2.1 - 2.1*y**2 + 2*x)/x**3
>    h[12] >>> e2= (2.1*x*(1-y)**2+2*y*x)/ x**3
>    h[12] >>> e3= (sympy.Rational(21,10)*x*(1-y)**2 + 2*y*x) / X**3
>    h[12] >>> for e in [e1,e2,e3]:
>         ...  print simplify(nsimplify(e,rational=True))
>         ...
>    (20*x - 21*y**2 + 21)/(10*x**3)
>    (21*y**2 - 22*y + 21)/(10*x**2)
>    x*(21*y**2 - 22*y + 21)/(10*X**3)
>

One problem was with PRS GCD algorithm and was fixed in:


https://github.com/sympy/sympy/commit/2f6031a364cc33612285e704e2615e3cd5682aa3

The other problem (mainly "can't raise polynomial to a negative power") is
related to poor floating point number support in sympy.polys. The exception
is being raised in dmp_prem() which fails to recognize a zero polynomial and
keeps iterating. I prepared a patch in which I extended RR domain to support
eps (tolerance) parameter and robustified low-level polynomial arithmetic
functions to take advantage of this, but this doesn't solve all problems
with floating point numbers (e.g. Groebner bases algorithm over RR doesn't
work as expected). It seems that the right way to go is (as suggested by
Bartosz) to replace mpf dtype of RR with a class that can manage tolerance
on its own. I'm now experimenting with mpf, because it may already have all
features that we need to implement this.


> CAUTION: you used an X instead of an x in the last equation.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
>
Mateusz

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to