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

Maxima doesn't do an integral we thought was fixed #17469

Open
kcrisman opened this issue Dec 8, 2014 · 9 comments
Open

Maxima doesn't do an integral we thought was fixed #17469

kcrisman opened this issue Dec 8, 2014 · 9 comments

Comments

@kcrisman
Copy link
Member

kcrisman commented Dec 8, 2014

#11238 is back.


;;; 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.

Upstream: Fixed upstream, but not in a stable release.

Component: calculus

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

@kcrisman kcrisman added this to the sage-6.5 milestone Dec 8, 2014
@kcrisman
Copy link
Member Author

kcrisman commented Dec 8, 2014

comment:1

To be precise,

sage: integrate(exp(-x)*sin(sqrt(x)), x, 0, oo)
integrate(e^(-x)*sin(sqrt(x)), x, 0, +Infinity)

This did work in Sage 5.2.

sage: integrate(exp(-x)*sinh(sqrt(x)), x, 0, oo)
1/2*sqrt(pi)*e^(1/4)

@kcrisman kcrisman changed the title Maxima hangs on an integral we thought was fixed Maxima doesn't do an integral we thought was fixed Dec 8, 2014
@kcrisman
Copy link
Member Author

kcrisman commented Dec 8, 2014

Upstream: Reported upstream. No feedback yet.

@kcrisman
Copy link
Member Author

kcrisman commented Dec 8, 2014

@kcrisman
Copy link
Member Author

kcrisman commented Dec 8, 2014

comment:4

Current doctest for this bites.

    Another symbolic integral, from :trac:`11238`, that used to return
    zero incorrectly; with Maxima 5.26.0 one gets
    ``1/2*sqrt(pi)*e^(1/4)``, whereas with 5.29.1, and even more so
    with 5.33.0, the expression is less pleasant, but still has the
    same value.  Unfortunately, the computation takes a very long time
    with the default settings, so we temporarily use the Maxima
    setting ``domain: real``::

        sage: sage.calculus.calculus.maxima('domain: real')
        real
        sage: f = exp(-x) * sinh(sqrt(x))
        sage: t = integrate(f, x, 0, Infinity); t            # long time
        1/4*sqrt(pi)*(erf(1) - 1)*e^(1/4) - 1/4*(sqrt(pi)*(erf(1) - 1) - sqrt(pi) + 2*e^(-1) - 2)*e^(1/4) + 1/4*sqrt(pi)*e^(1/4) - 1/2*e^(1/4) + 1/2*e^(-3/4)
        sage: t.simplify_exp()  # long time
        1/2*sqrt(pi)*e^(1/4)
        sage: sage.calculus.calculus.maxima('domain: complex')
        complex

And the 'long time' is not kidding.

@kcrisman
Copy link
Member Author

Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.

@kcrisman
Copy link
Member Author

comment:5

Apparently fixed again upstream, though still looooong time...

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented Aug 9, 2018

comment:6

Sorry, wrong ticket (and I don't know how to delete a comment in Trac...)

@DaveWitteMorris
Copy link
Member

comment:7

Update: Sage v9.2 can evaluate the integral:

sage: integrate(exp(-x)*sin(sqrt(x)), x, 0, oo)                                          
1/2*sqrt(pi)*e^(-1/4)

This is not the same answer as previously reported, because the previous calculation has e^(1/4), not e^(-1/4). However, Maple and Wolfram Alpha agree that there should be a minus sign, so probably this is good.

And the calculation is not ridiculously slow (from %timeit on CoCalc):

3.02 s ± 248 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

I was going to suggest closing this ticket as WorksForMe, but then I noticed that the integration fails if we simply multiply the integrand by a constant:

sage: integrate(-exp(-x)*sin(sqrt(x)), x, 0, oo)
-integrate(e^(-x)*sin(sqrt(x)), x, 0, +Infinity)

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented Dec 2, 2020

comment:8

FMIW :

sage: var("a")
a
sage: f(x)=exp(-x)*sin(sqrt(x))
sage: integrate(f(x),[x,0,oo])
1/2*sqrt(pi)*e^(-1/4)
sage: integrate(f(x),[x,0,oo]).n()
0.690194223521571
sage: numerical_integral(f(x),0,oo)
(0.6901942235198321, 1.3133617826621702e-07)

The minus sign seems correct...

sage: integrate(a*f(x),[x,0,oo])
a*integrate(e^(-x)*sin(sqrt(x)), x, 0, +Infinity)

Indeed... But :

sage: integrate(a*f(x),[x,0,oo]).unhold()
1/2*sqrt(pi)*a*e^(-1/4)

This might be more general...

Another quirk :

sage: integrate(a*f(x),[x,0,oo], algorithm="mathematica_free")
1/2*sqrt(pi)*a*e^(-1/4)
sage: integrate(f(x),[x,0,oo], algorithm="mathematica_free")
0.690194000000000

Replying to @DaveWitteMorris:

Update: Sage v9.2 can evaluate the integral:

sage: integrate(exp(-x)*sin(sqrt(x)), x, 0, oo)                                          
1/2*sqrt(pi)*e^(-1/4)

This is not the same answer as previously reported, because the previous calculation has e^(1/4), not e^(-1/4). However, Maple and Wolfram Alpha agree that there should be a minus sign, so probably this is good.

And the calculation is not ridiculously slow (from %timeit on CoCalc):

3.02 s ± 248 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

I was going to suggest closing this ticket as WorksForMe, but then I noticed that the integration fails if we simply multiply the integrand by a constant:

sage: integrate(-exp(-x)*sin(sqrt(x)), x, 0, oo)
-integrate(e^(-x)*sin(sqrt(x)), x, 0, +Infinity)

@mkoeppe mkoeppe removed this from the sage-6.5 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

3 participants