I get a slightly different result when integrating in Matlab (2008a):
[matlab]
>> syms X Y L H K;
>> int(int(2*X*X+2*Y*Y-1, Y, -sqrt(1-X*X), sqrt(1-X*X)), X, L, 1)

ans =

-2/3*(1-L^2)^(1/2)*L*(L-1)*(1+L)


>> expand(ans)

ans =

2/3*(1-L^2)^(1/2)*L-2/3*(1-L^2)^(1/2)*L^3
[/matlab]

In sympy, it seems like if you do the first integral, there are two
additive terms:
>>> integrate(2*X*X+2*Y*Y-1, (Y, -(1-X**2)**Rational(1,2), 
>>> (1-X**2)**Rational(1,2)) )
-2*(1 - X**2)**(1/2)*(1 - 2*X**2) + 4*(1 - X**2)**(3/2)/3
>>> t1 = integrate(4*(1 - X**2)**(3/2)/3, (X,L,1))
8/9 - 4*L/3 + 4*L**3/9
>>> t2 = integrate(-2*(1 - X**2)**(1/2)*(1 - 2*X**2), (X,L,1))
-2/3 + 2*L - 4*L**3/3
>>> t1+t2
2/9 + 2*L/3 - 8*L**3/9

So if you perform the second integration on each term, one at a time,
it is fine, but when you try to do the whole thing, it doesn't like
it, as you pointed out.  I'm not sure why this would happen, it seems
like integrate should parse each additive term and try to integrate
it, if this were the case, the above example should work like
Matlab.

Additionally, it doesn't seem that the results are the same, so there
must be some sort of bug in integrate.

~Luke

On May 22, 2:27 am, Oyster <lepto.pyt...@gmail.com> wrote:
> please note the dual-integrate result
> how can I get an advanced value in sympy? thanx
>
> [smypy]>>> from sympy import *
> >>> X,Y=symbols('XY', real=True)
> >>> integrate(2*X*X+2*Y*Y-1, (Y, -(1-X**2)**Rational(1,2), 
> >>> (1-X**2)**Rational(1,2)) )
>
> -2*(1 - X**2)**(1/2)*(1 - 2*X**2) + 4*(1 - X**2)**(3/2)/3>>> 
> integrate(integrate(2*X*X+2*Y*Y-1, (Y, -(1-X**2)**Rational(1,2), 
> (1-X**2)**Rational(1,2)) ), (X,L,1))
>
> Integral(-2*(1 - X**2)**(1/2)*(1 - 2*X**2) + 4*(1 - X**2)**(3/2)/3,
> (X, L, 1))>>> simplify(integrate(integrate(2*X*X+2*Y*Y-1, (Y, 
> -(1-X**2)**Rational(1,2), (1-X**2)**Rational(1,2)) ), (X,L,1)))
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File "h:\pure_pylib\math\sympy\sympy\simplify\simplify.py", line
> 1079, in simplify
>   File "h:\pure_pylib\math\sympy\sympy\polys\polynomial.py", line 607,
> in cancel
>   File "h:\pure_pylib\math\sympy\sympy\core\basic.py", line 1437, in
> expand
>   File "h:\pure_pylib\math\sympy\sympy\core\basic.py", line 1372, in
> _eval_expand_basic
>   File "h:\pure_pylib\math\sympy\sympy\core\basic.py", line 374, in
> new
>   File "h:\pure_pylib\math\sympy\sympy\integrals\integrals.py", line
> 48, in __new__
> ValueError: Invalid integration variable or limits: (((X, (L, 1)),),)
> [/sympy]
>
> [matlab]
>
> >> syms X Y L H K;
> >> int(int(2*X*X+2*Y*Y-1, Y, -sqrt(1-X*X), sqrt(1-X*X)), X, L, 1)
>
> ans =
>
> 2/3*L*(1-L^2)^(3/2)
>
> >> int(2*X*X+2*Y*Y-1, Y, -sqrt(1-X*X), sqrt(1-X*X))
>
> ans =
>
> 4*X^2*(1-X^2)^(1/2)+4/3*(1-X^2)^(3/2)-2*(1-X^2)^(1/2)
>
> >> int(int(2*X*X+2*Y*Y-1, Y, -sqrt(1-X*X), sqrt(1-X*X)), X, L, 1)
>
> ans =
>
> 2/3*L*(1-L^2)^(3/2)
> [/matlab]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to