user600942 - 2 years ago 84

Python Question

Using python 3.5.1 64 bit on windows 8.1, I have installed sympy, 1.0.

Running interactively

`from sympy import *`

p = symbols('p')

factor('8 + 8/(2+p)')

result is

`8*(p + 3)/(p + 2)`

If I go to http://live.sympy.org/ running sympy 0.7.6 and python 2.7.5 and enter the same equation and hit the evaluate button, I get the right answer.

`8 + 8/(2+p)`

There is no reduction. Why am I getting the wrong answer with Python 3.5.1 and sympy 1.0?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

You are not getting the wrong answer. All that `sympy.factor`

ensures is that a polynomial is factored into irreducible fractions over the rationals.

Notice that

So the form given by `factor`

in version 1.0 is correct, and represents an irreducible fraction over the rationals.

**Update** : I ran your code on SymPy Live and you get the exact same fraction when using `factor`

, without the 8 factored out. They are the same. Note as Steven Rumbalski said, that *evaluating* and *factoring* are two different things.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**