The problem is the 1/8. I Python 2, this evaluates to 0, because of
integer division. I recommend using Python 3, or if you must use
Python 2, use "from __future__ import division". That will cause 1/8
to evaluate to the float 0.125.

For SymPy, it is best to use rational numbers, like Rational(1, 8).

See also http://docs.sympy.org/latest/tutorial/gotchas.html#two-final-notes-and.

Aaron Meurer

On Wed, Feb 1, 2017 at 10:38 AM, Lorenzo Isella
<[email protected]> wrote:
> Dear All,
> I am making my first baby steps with sympy and I must be
> misunderstanding something.
> I want to simplify the expression
>
> (N**2/8 -1/8)/((N-1)/2) hence this is what I do in a ipython shell
>
> n [2]: from sympy import *
>
> In [3]: var("N")
> Out[3]: N
>
> In [4]: simplify((N**2/8 -1/8)/((N-1)/2))
> Out[4]: N**2/(4*(N - 1))
>
> however, the right result is (N+1)/4.
>
> It is not rocket science, so what (obvious) thing am I missing?
> Many thanks
>
> Lorenzo
>
> --
> 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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/20170201153814.GA3881%40chicca.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6K36YQchCt%3D1EA9XKHF7pwcL%2BtNdUQcySajxpY3ioCyRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to