This expression returns zero, but it shouldn`t.
P = x^6-14x^4+49x^2-36
integrate(1/P, (x, 1/3, 1/2))
I also used expand on expression, without any result. Am i doing something wrong or is this a bug?
This works:
from sympy import *
x = symbols('x')
P = x**6-14*x**4+49*x**2-36
I = integrate(1/expand(P), (x, S.One/3, S.One/2))
I get the result:
In [5]: I
Out[5]: -3*log(3)/80 - log(7)/48 - log(2)/48 - log(8)/240 + log(10)/240 + log(4)/48 + 3*log(5)/80
In [6]: I.n()
Out[6]: -0.00601350282195297
In alternative, you could run the command isympy -i, this will run a SymPy prompt that converts all Python integers to SymPy integers before the input gets evaluated by the SymPy parser.
Python integer division is different between Python 2 and Python 3, the first returns and integer, the second returns a floating point number. Both versions are different to SymPy integer division, which returns fractions. To use SymPy division, you need to make sure that at least one among the dividend and divisor are SymPy objects.