Definite Intergral wrong. How to solve

38 views
Skip to first unread message

Nasir Haniffa

unread,
Feb 13, 2016, 11:55:34 AM2/13/16
to sympy
Hi,

How to get the correct answer for the problems

1.   Integral( (1+x**2)**(-3/2) ,(x,-1,1)  )


2.   Integral( (1+x**2+y**2)**(-3/2) ,(x,-1,1), (y,-1,1)  )

Both gives 0 in sympy which is wrong.

Mathematica gives correct answer!

Nasir



Oscar Benjamin

unread,
Feb 13, 2016, 12:10:39 PM2/13/16
to sympy
On 13 February 2016 at 07:48, Nasir Haniffa <nasirh...@gmail.com> wrote:
> Hi,
>
> How to get the correct answer for the problems
>
> 1. Integral( (1+x**2)**(-3/2) ,(x,-1,1) )
>
>
> 2. Integral( (1+x**2+y**2)**(-3/2) ,(x,-1,1), (y,-1,1) )
>
> Both gives 0 in sympy which is wrong.

This is a bug in current master:

>>> from sympy import Symbol, Integral
>>> x = Symbol('x')
>>> Integral( (1+x**2)**(-3/2) ,(x,-1,1) )
Integral((x**2 + 1)**(-2), (x, -1, 1))
>>> Integral( (1+x**2)**(-3/2) ,(x,-1,1) ).doit()
1/2 + pi/4

Note that -3/2 under Python 2.7 gives -2 which is not what you want so
use -S(3)/2

>>> from sympy import S
>>> Integral( (1+x**2)**(-S(3)/2) ,(x,-1,1) ).doit()
0
>>> expr = (1+x**2)**(-S(3)/2)
>>> expr.integrate((x, -1, 1))
0

Under sympy 0.7.1 I get:

>>> Integral( (1+x**2)**(-S(3)/2) ,(x,-1,1) ).doit()
Integral((x**2 + 1)**(-3/2), (x, -1, 1))
>>> Integral( (1+x**2)**(-S(3)/2) ,(x,-1,1) ).evalf()
1.41421356237310

--
Oscar
Reply all
Reply to author
Forward
0 new messages