rtoy / maxima

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

Integral hangs with domain:complex #3578

Closed rtoy closed 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:03 Created by kcrisman on 2014-12-08 15:17:53 Original: https://sourceforge.net/p/maxima/bugs/2854


See below. Note also that not so long ago the correct answer was given, after a fix! See https://sourceforge.net/p/maxima/bugs/2411/ - strange that even without the complex domain it now gives the long answer, since that worked prior to that ticket.

;;; Loading #P"/Users/.../sage/local/lib/ecl/sb-bsd-sockets.fas"
;;; Loading #P"/Users/.../sage/local/lib/ecl/sockets.fas"
;;; Loading #P"/Users/.../sage/local/lib/ecl/defsystem.fas"
;;; Loading #P"/Users/.../sage/local/lib/ecl/cmp.fas"
Maxima 5.34.1 http://maxima.sourceforge.net
using Lisp ECL 13.5.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) display2d:false
;

(%o1) false
(%i2) integrate(exp(-x)*sinh(sqrt(x)),x,0,inf);

(%o2) -%e^(1/4)*(2*gamma_incomplete(1,1)-gamma_incomplete(1/2,1)-sqrt(%pi)-2)/4
 +%e^(1/4)*gamma_incomplete(1,1)/2-%e^(1/4)*gamma_incomplete(1/2,1)/4
 +%e^(1/4)*sqrt(%pi)/4-%e^(1/4)/2
(%i3) domain:complex;

(%o3) complex
(%i4) integrate(exp(-x)*sinh(sqrt(x)),x,0,inf);
^C
Maxima encountered a Lisp error:

 Console interrupt.

Automatically continuing.

Downstream at http://trac.sagemath.org/ticket/11238 and http://trac.sagemath.org/ticket/17469

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:04 Created by rswarbrick on 2014-12-13 14:07:27 Original: https://sourceforge.net/p/maxima/bugs/2854/#779c


First thing to notice: Maxima hangs on this example when checked out at sha [15c4ea] or [c08c4c]. These commits are (I think) either side of Dan's fix for bug [#2411], so I think the hang is independent of that.

It seems to be hanging while trying to run intsubs (which tries to do a definite integral by evaluating a known antiderivative, but being careful with poles). I haven't figured out why yet.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:08 Created by rswarbrick on 2014-12-13 14:27:41 Original: https://sourceforge.net/p/maxima/bugs/2854/#9f82


Hmm, I've just re-read the contents of [#2411] and presumably I've confused myself.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:11 Created by rswarbrick on 2014-12-13 14:39:43 Original: https://sourceforge.net/p/maxima/bugs/2854/#097b


For anyone tracking this down, the intsubs call with the fix for [#2411] takes /ages/. Here's a build of [c1bffa], which I believe is the first version with the fix for [#2411]:

::text
rupert@halibut /s/maxima> 
time ./maxima-local -l sbcl -r 'integrate(exp(-x)*sinh(sqrt(x)), x, 0, inf), domain: complex;'
Maxima branch_5_27_base_171_g5d98db3 http://maxima.sourceforge.net
using Lisp SBCL 1.2.4.debian
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)         1/4                                              1
      %e    (2 gamma_incomplete(1, 1) - gamma_incomplete(-, 1) + sqrt(%pi) - 2)
                                                         2
(%o1) -------------------------------------------------------------------------
                                          4
        1/4                                              1
      %e    (2 gamma_incomplete(1, 1) - gamma_incomplete(-, 1) - sqrt(%pi) - 2)
                                                         2
    - -------------------------------------------------------------------------
                                          4
(%i2) 22.70user 0.47system 0:23.16elapsed 100%CPU (0avgtext+0avgdata 239772maxresident)k
0inputs+0outputs (0major+513985minor)pagefaults 0swaps
rupert@halibut /s/maxima> git rev-parse HEAD
c1bffa4bc3530282012952495964ae2ff21d956a

(Yes, it really does take 22 seconds, and this is a reasonably fast machine)

I've just tried tracing $LIMIT with the version of Maxima on master and running it locally. After about 20 seconds (I didn't time it properly), one of the nested limit calls finishes, but the calculation doesn't terminate even after several minutes wait.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:15 Created by rswarbrick on 2014-12-13 14:53:26 Original: https://sourceforge.net/p/maxima/bugs/2854/#a041


To save someone else bisecting the regression (which is rather tedious), it's caused by commit [17ca33]. I haven't figured out what the problem is yet.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-08 09:31:19 Created by rswarbrick on 2014-12-13 15:57:15 Original: https://sourceforge.net/p/maxima/bugs/2854/#232e


This should be fixed by [f5808b]. I haven't added a test to the testsuite because the limit calculation in this example takes a ridiculously long time :-(

If anyone knows a simpler example that displays this bug (and whose integral can be computed in under a second), that would be fantastic and help us avoid breaking this again in future.