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

In [19]: expr = (2.1*x*(1-y)**2+2*y*x)/ x**3

In [20]: sympy.simplify(expr)
Out[20]: (2.1 - 2.2*y + 2.1*y**2)/x**2

In [21]: expr = (sympy.Rational(21,10)*x*(1-y)**2 + 2*y*x) / X**3

In [22]: sympy.simplify(expr)
Out[22]: (105*x - 110*x*y + 105*x*y**2)/(50*X**3)

In the dev version I just get completely wrong results.

-- Andy


On Tue, May 24, 2011 at 11:29 AM, Bartosz
<[email protected]> wrote:
> Hi all,
>
> I have been trying to simplify expressions with floating point numbers
> and I noticed that the results are quite unpredictable. In many cases
> the calculation took indefinite time (until I killed it) or produced
> wrong results (infinity or other incorrect expressions). Here is an
> example:
>
> simplify of:
>
>                 2
> 2.1 - 2.1⋅y + 2⋅x
> ───────────
>         3
>        x
>
> returns:
>
> 2
> ─
> x
>
> While:
>
>                     2
> 2.1⋅x⋅(1 - y) + 2⋅y⋅x
> ──────────────────────
>           3
>          x
>
> returns infinity.
>
> My workaround is now to use rational numbers instead:
>
> 21⋅x⋅(1 - y)        2
> ──────────── + 2⋅y⋅x
>     10
> ─────────────────────
>           3
>          x
>
> but it would be better if this could be done automatically. Is there a
> simple fix to this problem?
>
> Thanks for your help and sympy!
>
> Cheers,
>
> Bartosz
>
> --
> 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.
>
>

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