Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate produces wrong results due to loading of abs_integrate in Maxima interface #25904

Open
nasser1 opened this issue Jul 23, 2018 · 3 comments

Comments

@nasser1
Copy link

nasser1 commented Jul 23, 2018

I was told to report this here.

There seems to be an old bug related to this issue #12731

When using default setting of SageMath for integrate, Maxima produces many wrong integral results.

Here are few examples of many I have:

Example 1


    SageMath version 8.3.rc1, Release Date: 2018-07-14

    sage: var('x e a b f c d m');
    sage: integrate ((d*sin (f*x + e) + c)^(3/2)*(b*sin (f*x + e) + a)^m, x)
    1/9*(c^3*sin(9/2*f*x + 9/2*e) - 3*c^3*sin(3/2*f*x + 3/2*e))*2^(-m - 5/2)/f

The above is clearly wrong, since the anti dropped/missing the parameters d,a,b in the integrand.

in Maxima

    Maxima 5.41.0 http://maxima.sourceforge.net
    using Lisp ECL 16.1.2

    (%i1) domain:complex$    
    (%i2) domain;
    (%o2)                               complex

    (%i3) integrate ((d*sin (f*x + e) + c)^(3/2)*(b*sin (f*x + e) + a)^m, x);
                  /
                  [                     m                     3/2
    (%o3)         I (b sin(f x + e) + a)  (d sin(f x + e) + c)    dx
                  ]
                  /

Example 2


    sage: integrate(sqrt(d*sin (f*x + e) + c)*(b*sin (f*x + e) + a)^m, x,algorithm="maxima")
    1/3*(c*sin(3/2*f*x + 3/2*e) - 3*c*sin(1/2*f*x + 1/2*e))*2^(-m - 3/2)/f

The above is clearly wrong, since the anti dropped/missing the parameters d,a,b in the integrand.

Using Maxima

    (%i7) integrate (sqrt (d*sin (f*x + e) + c)*(b*sin (f*x + e) + a)^m, x);
                  /
                  [                     m
    (%o7)         I (b sin(f x + e) + a)  sqrt(d sin(f x + e) + c) dx
                  ]
                  /

The above is the correct result, since this integral is supposed to be non integrable.

Example 3


    sage: integrate (x*sqrt (cos (b*x + a)), x,algorithm="maxima")
    1/840*(70*sqrt(2)*a*(sin(3/2*b*x + 3/2*a) - 3*sin(1/2*b*x + 1/2*a)) - sqrt(2)*(15*sin(7/2*b*x + 7/2*a) - 21*sin(5/2*b*x + 5/2*a) - 35*sin(3/2*b*x + 3/2*a) + 105*sin(1/2*b*x + 1/2*a)))/b^2

The above result did not verify by differentiating the antiderivative.

Using Maxima

    (%i9) integrate (x*sqrt (cos (b*x + a)), x);                 
                               /
                               [
    (%o9)                      I x sqrt(cos(b x + a)) dx
                               ]
                               /

The above is the correct result, since this integral is supposed to be non integrable.

example 4


    sage: integrate(x*cos(b*x + a)^(3/2), x, algorithm="maxima")
    1/349920*(243*sqrt(2)*a*(3*sin(15/2*b*x + 15/2*a) + 5*sin(9/2*b*x + 9/2*a) - 30*sin(3/2*b*x + 3/2*a)) - 20*sqrt(2)*(2*(81*(b*x + a)^2 - 8)*cos(9/2*b*x + 9/2*a) - 162*(9*(b*x + a)^2 - 8)*cos(3/2*b*x + 3/2*a) + 9*(27*(b*x + a)^3 - 8*b*x - 8*a)*sin(9/2*b*x + 9/2*a) - 243*(3*(b*x + a)^3 - 8*b*x - 8*a)*sin(3/2*b*x + 3/2*a)))/b^2

The above result did not verify by differentiating the antiderivative.

Using Maxima

    (%i10) integrate(x*cos(b*x + a)^(3/2), x);
                                /
                                [               3/2
    (%o10)                      I x cos(b x + a)    dx
                                ]
                                /

The above is the correct result, since this integral is supposed to be non integrable.

Example 5


    sage: integrate(cos (x)^(3/2)/x^3, x, algorithm="maxima")
    -9/512*sqrt(2)*(25*gamma(-2, 15/2*I*x) + 9*gamma(-2, 9/2*I*x) - 2*gamma(-2, 3/2*I*x) - 2*gamma(-2, -3/2*I*x) + 9*gamma(-2, -9/2*I*x) + 25*gamma(-2, -15/2*I*x))

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i11) integrate (cos (x)^(3/2)/x^3, x);
                                    /       3/2
                                    [ cos(x)
    (%o11)                          I --------- dx
                                    ]     3
                                    /    x

The above is the correct result, since this integral is supposed to be non integrable.

Example 6


    sage: integrate(cos(d*x + c)^(7/3)/sqrt(b*cos(d*x + c) + a), x,algorithm="maxima")
    1/6366178138320*2^(1/6)*(61213251330*cos(13/2*d*x + 13/2*c) - 72342933390*cos(11/2*d*x + 11/2*c) - 82321269030*cos(29/6*d*x + 29/6*c) + 140430400110*cos(17/6*d*x + 17/6*c) - 217028800170*cos(11/6*d*x + 11/6*c) - 341045257410*cos(7/6*d*x + 7/6*c) + 23405066685*sin(17/2*d*x + 17/2*c) - 26525742243*sin(15/2*d*x + 15/2*c) - 29113619535*sin(41/6*d*x + 41/6*c) + 41160634515*sin(29/6*d*x + 29/6*c) - 44209570405*sin(9/2*d*x + 9/2*c) - 51898191345*sin(23/6*d*x + 23/6*c) + 56840876235*sin(7/2*d*x + 7/2*c) - 62824126365*sin(19/6*d*x + 19/6*c) + 70215200055*sin(17/6*d*x + 17/6*c) + 1193658400935*sin(1/6*d*x + 1/6*c))/(a*d)

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i12) integrate (cos (d*x + c)^(7/3)/sqrt (b*cos (d*x + c) + a), x);
                             /                 7/3
                             [     cos(d x + c)
    (%o12)                   I ------------------------ dx
                             ] sqrt(b cos(d x + c) + a)
                             /

The above is the correct result, since this integral is supposed to be non integrable.

Example 7


    sage: integrate(cos(d*x + c)^(2/3)/sqrt(b*cos(d*x + c) + a), x,algorithm="maxima")
    -1/54264*2^(5/6)*(1071*cos(19/6*d*x + 19/6*c) + 1197*cos(17/6*d*x + 17/6*c) - 2261*cos(3/2*d*x + 3/2*c) - 2907*cos(7/6*d*x + 7/6*c) + 6783*cos(1/2*d*x + 1/2*c) + 20349*cos(1/6*d*x + 1/6*c))/(a*d)

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i13) integrate (cos (d*x + c)^(2/3)/sqrt (b*cos (d*x + c) + a), x);
                             /                 2/3
                             [     cos(d x + c)
    (%o13)                   I ------------------------ dx
                             ] sqrt(b cos(d x + c) + a)
                             /

The above is the correct result, since this integral is supposed to be non integrable.

Example 8


    sage: var('B A f x e b a c m')
    (B, A, f, x, e, b, a, c, m)

    sage: integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*cos(f*x+e))^m,x)
    1/3465*(385*(a^3*c^m*sin(9/2*f*x + 9/2*e) - 3*a^3*c^m*sin(3/2*f*x + 3/2*e))*2^(-m - 5/2)*A + 4*(231*a^3*sin(15/2*f*x + 15/2*e) + 630*a^3*sin(11/2*f*x + 11/2*e) - 770*a^3*sin(9/2*f*x + 9/2*e) + 495*a^3*sin(7/2*f*x + 7/2*e) - 2079*a^3*sin(5/2*f*x + 5/2*e) + 1155*a^3*sin(3/2*f*x + 3/2*e))*2^(-m - 13/2)*B)/f

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i15) integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*cos(f*x+e))^m,x);
           /
           [                 m                                          3/2
    (%o15) I (c cos(f x + e))  (B cos(f x + e) + A) (b cos(f x + e) + a)    dx
           ]
           /

The above is the correct result, since this integral is supposed to be non integrable.

Example 9


    sage: integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*cos(f*x+e))^m,x)
    1/315*(105*(a*c^m*sin(3/2*f*x + 3/2*e) - 3*a*c^m*sin(1/2*f*x + 1/2*e))*2^(-m - 3/2)*A + (35*a*sin(9/2*f*x + 9/2*e) - 90*a*sin(7/2*f*x + 7/2*e) + 189*a*sin(5/2*f*x + 5/2*e) - 315*a*sin(3/2*f*x + 3/2*e) + 315*a*sin(1/2*f*x + 1/2*e))*2^(-m - 7/2)*B)/f

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i16) integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*cos(f*x+e))^m,x);
           /
           [                 m
    (%o16) I (c cos(f x + e))  (B cos(f x + e) + A) sqrt(b cos(f x + e) + a) dx
           ]
           /

The above is the correct result, since this integral is supposed to be non integrable.

Example 10


    sage: integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*sec(f*x+e))^m,x)
    -1/2520*sqrt(2)*(35*2^m*A^3*a*sin(9/2*f*x + 9/2*e) + 630*(A^3*B - A^3*a)*2^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 630*(A^3*B - A^3*a)*2^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) + 45*(2*A^3*B - A^3*a)*2^m*sin(7/2*f*x + 7/2*e) - 63*(2*A^3*B - 3*A^3*a)*2^m*sin(5/2*f*x + 5/2*e) + 105*(4*A^3*B - 5*A^3*a)*2^m*sin(3/2*f*x + 3/2*e) - 630*(4*A^3*B - 3*A^3*a)*2^m*sin(1/2*f*x + 1/2*e))/f

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i17) integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*sec(f*x+e))^m,x);
           /
           [                                          3/2                 m
    (%o17) I (B cos(f x + e) + A) (b cos(f x + e) + a)    (c sec(f x + e))  dx
           ]
           /

The above is the correct result, since this integral is supposed to be non integrable.

Example 11


    sage: integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*sec(f*x+e))^m,x)
    1/40*(20*sqrt(2)*(2^m*a*c^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 2^m*a*c^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) - 2^(m + 1)*a*c^m*sin(1/2*f*x + 1/2*e))*A + sqrt(2)*(5*2^(m + 2)*a*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 5*2^(m + 2)*a*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) - 2^(m + 1)*a*sin(5/2*f*x + 5/2*e) + 5*2^(m + 1)*a*sin(3/2*f*x + 3/2*e) - 15*2^(m + 2)*a*sin(1/2*f*x + 1/2*e))*B)/f

The above result did not verify by differentiating the antiderivative.

Maxima:

    (%i18) integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*sec(f*x+e))^m,x);
           /
           [                                                               m
    (%o18) I (B cos(f x + e) + A) sqrt(b cos(f x + e) + a) (c sec(f x + e))  dx
           ]
           /

The above is the correct result, since this integral is supposed to be non integrable.

reference: https://ask.sagemath.org/question/43088/integrate-results-that-are-different-from-using-maxima/

CC: @rwst @kcrisman @sagetrac-tmonteil @orlitzky

Component: symbolics

Keywords: integrate, maxima, abs_integrate

Issue created by migration from https://trac.sagemath.org/ticket/25904

@nasser1 nasser1 added this to the sage-8.4 milestone Jul 23, 2018
@kcrisman
Copy link
Member

comment:2

Thank you! See also the list at symbolics.

@fchapoton
Copy link
Contributor

Changed keywords from integrate, maxima to integrate, maxima, abs_integrate

@orlitzky
Copy link
Contributor

comment:4

The situation has improved some. Maxima knows that it can't compute the integrals from examples 2 through 11, but the fallback integrators aren't having much luck on my machine. Without algorithm="maxima", I've been waiting for like half an hour to get results back.

@mkoeppe mkoeppe removed this from the sage-8.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants