Wrong (?) indefinite integral results with wxMaxima and Sympy

272 Views Asked by At

I am working on interactive notebooks with several symbolic calculations, among which there are two indefinite integrals involving square roots. These are integrals (29) and (30) of this table of integrals --> http://integral-table.com.

When I try to evaluate these indefinite integrals with wxMaxima and Sympy, I get wrong results:

wxMaxima:

(29) Similar to the correct one, but the argument of the log function is wrong.

(%i127) integrate(sqrt(x^2-a^2),x);
(%o127) (x*sqrt(x^2-a^2))/2-(a^2*log(2*sqrt(x^2-a^2)+2*x))/2

(30) Similar to the correct one, but with arcsin instead of arctan and wrong argument.

(%i128) integrate(sqrt(a^2-x^2), x);
(%o128) (a^2*asin(x/abs(a)))/2+(x*sqrt(a^2-x^2))/2

Sympy:

(29) Completely different and messy result.

from sympy import *
x, a = Symbol('x', real=True), Symbol('a', real=True)
integrate(sqrt(x**2 - a**2), x)

Result of integral (29) with Sympy

(30) Again, completely different and messy result.

integrate(sqrt(a**2-x**2),x)

Result of integral (30) with Sympy

Instead, with Wolfram Alpha I get the correct primitive functions:

(29) https://www.wolframalpha.com/input/?i=Integrate%5BSqrt%5B+x%5E2-a%5E2%5D%2C+x%5D

(30) https://www.wolframalpha.com/input/?i=Integrate%5BSqrt%5Ba%5E2+-+x%5E2%5D%2C+x%5D

Does anyone know how to circumvent this problem, at least with wxMaxima? Maybe there is some trick, or, as I think, these are bugs to be reported to the developers.

Thank you!

p.s.: I need to work on a free notebook, so using Wolfram Alpha or Mathematica is not a solution.

EDITED: With regard to integral (30), by googling around I just discovered this relation between arcsin and arctan functions:

asin(x/a) = atan(x/sqrt(a^2-x^2))

This makes the result I obtained with Maxima equal to that indicated in the Table of Integrals and given by Wolfram Alpha. However, it seems that wxMaxima doesn't know this relation, since:

(%i165) ratsimp(atan(x/sqrt(a^2-x^2))- asin(x/a));
(%o165) atan(x/sqrt(a^2-x^2))-asin(x/a)

or by setting a=2, for example:

(%i167) ratsimp(atan(x/sqrt(a^2-x^2))- asin(x/a)), a=2;
(%o167) atan(x/sqrt(4-x^2))-asin(x/2)

I tried to employ several simplification methods, but I never obtained zero, hence equivalence between asin(x/a) and atan(x/sqrt(a^2-x^2)).

1

There are 1 best solutions below

1
On

Thanks for investigating, I appreciate it a lot. I am a Maxima developer. Any mistaken results should be reported to the bug tracker: https://sourceforge.net/p/maxima/bugs/ It is necessary to have a Sourceforge account to submit a bug report. Also, most discussion about Maxima is conducted via the mailing list: https://sourceforge.net/projects/maxima/lists/maxima-discuss

About the results you mentioned, you can verify the results by differentiating with respect to x and then comparing to the integrand. When I do that, I get an identical result for the second one. The first one is different, but numerical evaluation suggests (doesn't prove, I know) that it's the same.

(%i2) e: sqrt(x^2 - a^2);
                                2    2
(%o2)                     sqrt(x  - a )
(%i3) integrate (e, x);
                 2    2     2             2    2
         x sqrt(x  - a )   a  log(2 sqrt(x  - a ) + 2 x)
(%o3)    --------------- - -----------------------------
                2                        2
(%i4) diff (%o3, x);
           2       2 x
          a  (------------- + 2)
                    2    2                  2    2
              sqrt(x  - a )           sqrt(x  - a )
(%o4) (- -------------------------) + -------------
                    2    2                  2
         2 (2 sqrt(x  - a ) + 2 x)
                                                         2
                                                        x
                                                + ---------------
                                                          2    2
                                                  2 sqrt(x  - a )
(%i5) ratsimp (%);
                            2    2     2    2
                    x sqrt(x  - a ) + x  - a
(%o5)               -------------------------
                              2    2
                        sqrt(x  - a ) + x

(omitting some exploratory gyrations here ... and now jump to final result)

(%i11) %o5 - e, a = 1;
                     2         2
             x sqrt(x  - 1) + x  - 1         2
(%o11)       ----------------------- - sqrt(x  - 1)
                      2
                sqrt(x  - 1) + x
(%i12) makelist (''%, x, makelist (i, i, 1, 10)), numer;
(%o12) [0.0, 0.0, 0.0, 0.0, 8.881784197001252E-16, 
8.881784197001252E-16, 0.0, 0.0, - 1.77635683940025E-15, 
- 1.77635683940025E-15]

Unfortunately I can honestly say that integration, both definite and indefinite, is a source of many bugs for Maxima. We are continuing to work on it, and towards that end it is very helpful for you to check results, so I encourage you to keep going.