3

Sympy and wolframalpha have produced different result. Have done anything obviously wrong here?

import sympy as smp
smp.init_printing()
In [2]:

a,R,t = smp.symbols('a,R,t',real=True)
In [3]:

f = t**2/(1+t**2/a**2);f
Out[3]:

enter image description here

In [4]:
I=smp.Integral(f,t); I
Out[4]:

enter image description here

In [5]:
I.doit()
Out[5]:

a2t

Wolframalpha gives however

enter image description here

pranphy
  • 1,787
  • 4
  • 16
  • 22
  • It looks like sympy simplifies the function by removing the a^3 tan-1(x/a) term. Not sure why though. – BenT Oct 20 '17 at 02:30

2 Answers2

1

This is a bug in SymPy: I opened an issue about it. Meanwhile, a workaround is to declare a to be positive rather than just real. The sign does not matter anyway since a is squared, but I guess knowing that it's positive helps SymPy make the correct branch cut in the complex plane, or something like that.

>>> from sympy import *
>>> a = symbols('a', positive=True)
>>> t = symbols('t', real=True)
>>> integrate(t**2/(1+t**2/a**2), t)
a**2*(-a*atan(t/a) + t)

Using integrate(expr, var) here, which is easier to type than Integral(expr, var).doit().

  • Is there any place that I can find a list of known bugs in sympy 1.1.1? – pranphy Oct 21 '17 at 03:38
  • The [issue tracker](https://github.com/sympy/sympy/issues) would be it, but it's not separated by version. –  Oct 21 '17 at 04:23
-1

Sympy currently cannot compute indefinite integrals. It computes

$$\(\int_{x_0}^{x} f(x)dx\)$$

The documentation has more details.

A great free tool on par with wolfram alpha is sagemath Check out their online platform where you can work and store your worksheets in the cloud.

Xero Smith
  • 1,968
  • 1
  • 14
  • 19