rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

integration error 0 to negative exponent #1523

Open rtoy opened 1 month ago

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:02 Created by kcrisman on 2021-12-22 00:30:17 Original: https://sourceforge.net/p/maxima/bugs/3906


See https://trac.sagemath.org/ticket/29059#comment:11

Maxima 5.45.0 https://maxima.sourceforge.io
using Lisp ECL 21.2.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) domain:complex;
(%o1)                               complex
(%i2) f:x^2*asin(1/3*sqrt(-x^2 + 1)/sqrt(-1/9*x^2 + 1/9));
                                               2
                             2       sqrt(1 - x )
(%o2)                       x  asin(--------------)
                                                2
                                           1   x
                                    3 sqrt(- - --)
                                           9   9
(%i3) integrate(f,x,0,1);

expt: undefined: 0 to a negative exponent.
 -- an error. To debug this try: debugmode(true);
rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:03 Created by robert_dodier on 2021-12-24 04:54:04 Original: https://sourceforge.net/p/maxima/bugs/3906/#73b9


I see the error with domain = real, so I guess it doesn't hinge on that.

I see the error in a few different ways. In addition to integrate(f, x, 0, 1) shown above, I see it in integrate(f, x) and in load(antid); antidiff(f, x, u);.

However, I don't see it in risch(f, x). I guess that different paths lead to the place the error is happening, or happen to call something else.

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:06 Created by robert_dodier on 2022-01-26 05:49:01 Original: https://sourceforge.net/p/maxima/bugs/3906/#b08d


A little bit more info. Tracing some of the usual suspects shows

1 Enter dintegrate [x^2*asin(sqrt(1-x^2)/(3*sqrt(1/9-x^2/9))),x,0,1]
 1 Enter antideriv [x^2*asin(sqrt(1-x^2)/(3*sqrt(1/9-x^2/9)))]
  1 Enter sinint [x^2*asin(sqrt(1-x^2)/(3*sqrt(1/9-x^2/9))),x]
   1 Enter integrator [x^2*asin(sqrt(1-x^2)/(3*sqrt(1/9-x^2/9))),x]
    1 Enter intform [asin(sqrt(1-x^2)/(3*sqrt(1/9-x^2/9)))]
     2 Enter intform [sqrt(1-x^2)/(3*sqrt(1/9-x^2/9))]
      3 Enter intform [1/3]
      3 Exit  intform false
      3 Enter intform [sqrt(1-x^2)]
      3 Exit  intform false
      3 Enter intform [1/sqrt(1/9-x^2/9)]
      3 Exit  intform false
     2 Exit  intform false
    1 Exit  intform false
    2 Enter integrator [x^2,x]
    2 Exit  integrator x^3/3
    2 Enter integrator 
    [(x^3*((x*sqrt(1-x^2))/(27*(1/9-x^2/9)^(3/2))-x/(3*sqrt(1-x^2)*sqrt(1/9-x^2/9))))
      /(3*sqrt(1-(1-x^2)/(9*(1/9-x^2/9)))),x]
     1 Enter intform [1/sqrt(1-(1-x^2)/(9*(1/9-x^2/9)))]
      2 Enter intform [1/sqrt(x^2/(1-x^2)-1/(1-x^2)+1)]
expt: undefined: 0 to a negative exponent.

which looks like INTEGRATOR has made a change of variable and transformed the integrand into something (the argument of the last call to INTEGRATOR shown above) is identically zero; eventually some function downstream from INTFORM notices that.

I guess INTEGRATOR should verify the transformation is valid before going ahead.

For what it's worth, the argument to asin is just 1, so the antiderivative for f is just %x^3*%pi/6 (that agrees with risch).

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:10 Created by robert_dodier on 2022-01-26 05:57:44 Original: https://sourceforge.net/p/maxima/bugs/3906/#5859


Test cases for this problem. This is a bit of an experiment, to put in some cases which can be copied into the test suite, and making use of "milestone" values to track whether there are test cases, and whether they've been copied into the test suite. Anyway here it is.

/* SF bug #3906: "integration error 0 to negative exponent" */

(f:x^2*asin(1/3*sqrt(-x^2 + 1)/sqrt(-1/9*x^2 + 1/9)),
 0);
0;

risch (f, x);
(%pi*x^3)/6;

integrate (f, x);
(%pi*x^3)/6;

integrate (f, x, 0, 1);
%pi/6;
rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:14 Created by robert_dodier on 2022-01-26 05:58:51 Original: https://sourceforge.net/p/maxima/bugs/3906/#01dc


rtoy commented 1 month ago

Imported from SourceForge on 2024-07-04 18:05:17 Created by peterpall on 2022-01-26 06:10:55 Original: https://sourceforge.net/p/maxima/bugs/3906/#fa62


Having test cases in a bug report is great.

Would it make s|nse to add these test cases to the test suite immediately? That way if the bug tracker ever gets lost the big still is kinda visible and if some unrelated change improves things we get an info that something has improved.