Skip to content

Wrong integral of exp(x^3) from 1 to 2. #17968

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

Closed
sagetrac-tmonteil mannequin opened this issue Mar 16, 2015 · 18 comments
Closed

Wrong integral of exp(x^3) from 1 to 2. #17968

sagetrac-tmonteil mannequin opened this issue Mar 16, 2015 · 18 comments

Comments

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Mar 16, 2015

The following was reported on this ask question:

sage: f(x) = exp(x^3)
sage: f.integrate(x, 1, 2)
-1/3*gamma(1/3, -1) + 1/3*gamma(1/3, -8)
sage: f.integrate(x, 1, 2).n()
-138.557717219510 - 238.442320120796*I

numerical_integral and sympy seem to agree on the result:

sage: numerical_integral(f,1,2)
(275.5109837633117, 3.0587863771115628e-12)
sage: import sympy
sage: f = f._sympy_()
sage: g = f.integrate() ; g
exp(-I*pi/3)*gamma(1/3)*lowergamma(1/3, x**3*exp_polar(I*pi))/(9*gamma(4/3))
sage: h = g.subs(x,2) - g.subs(x,1)
sage: h.n()
275.510983763312 - 1.68744844960818e-21*I

CC: @kcrisman @mforets

Component: symbolics

Author: Marcelo Forets

Branch/Commit: 82161f2

Reviewer: Travis Scrimshaw

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

@sagetrac-tmonteil sagetrac-tmonteil mannequin added this to the sage-6.6 milestone Mar 16, 2015
@kcrisman
Copy link
Member

comment:1

Usually such problems are due to our conversions with such special functions, but apparently this time it might be Maxima's integration that is wrong:

(%i5) display2d: false;

(%o5) false
(%i6) integrate(exp(x^3),x,1,2);

(%o6) (gamma_incomplete(1/3,-8)-gamma_incomplete(1/3,-1))/3
(%i7) %, numer; 

(%o7) 0.3333333333333333*(-715.7985328820091*%i-413.2664756449672)

which seems to be the same issue as we have. Possibly related is #17328 or #11164. W|A gives the same antiderivative but for the definite integral uses the exponential integral E sub 2/3 of -1 and -8, which implies to me some kind of branch cut thing as usual.

@mforets
Copy link
Mannequin

mforets mannequin commented Mar 19, 2017

comment:2

This seems to be fixed by now:

sage: version()
SageMath version 7.5, Release Date: 2017-01-11
sage: integrate(exp(x^3), (x, 1, 2))
-1/3*(-1)^(2/3)*gamma(1/3, -1) + 1/3*(-1)^(2/3)*gamma(1/3, -8)
sage: integrate(exp(x^3), (x, 1, 2)).n()
275.510983763312 - 7.21644966006352e-14*I

should this ticket be closed?

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Mar 19, 2017

comment:4

Replying to @mforets:

This seems to be fixed by now:

sage: version()
SageMath version 7.5, Release Date: 2017-01-11
sage: integrate(exp(x^3), (x, 1, 2))
-1/3*(-1)^(2/3)*gamma(1/3, -1) + 1/3*(-1)^(2/3)*gamma(1/3, -8)
sage: integrate(exp(x^3), (x, 1, 2)).n()
275.510983763312 - 7.21644966006352e-14*I

should this ticket be closed?

Certainly not. We should add a doctest (with a pointer to this ticket) to ensure that the issue will not reappear.

@mforets
Copy link
Mannequin

mforets mannequin commented Mar 19, 2017

@mforets
Copy link
Mannequin

mforets mannequin commented Mar 19, 2017

comment:6

Replying to @sagetrac-tmonteil:

Replying to @mforets:

This seems to be fixed by now:

sage: version()
SageMath version 7.5, Release Date: 2017-01-11
sage: integrate(exp(x^3), (x, 1, 2))
-1/3*(-1)^(2/3)*gamma(1/3, -1) + 1/3*(-1)^(2/3)*gamma(1/3, -8)
sage: integrate(exp(x^3), (x, 1, 2)).n()
275.510983763312 - 7.21644966006352e-14*I

should this ticket be closed?

Certainly not. We should add a doctest (with a pointer to this ticket) to ensure that the issue will not reappear.

got it!

i copied the doctest which is just a couple of lines above ("Check that 11737 is fixed::..."). the difference is that the numerical noise in the imag part of the integral of exp(x^3) did not "magically vanish" by setting prec=54, as it is the case for the integral in the 11737 test. hence, i took the real_part().


New commits:

69a3e10add doctest for ticket 17968

@mforets
Copy link
Mannequin

mforets mannequin commented Mar 19, 2017

Commit: 69a3e10

@mforets mforets mannequin added the s: needs review label Mar 20, 2017
@kcrisman
Copy link
Member

comment:8

Apparently doesn't apply for some reason.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 28, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

bbd9432merge w/integral.py
00fc6d3trac:17968 doctest

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 28, 2017

Changed commit from 69a3e10 to 00fc6d3

@mforets
Copy link
Mannequin

mforets mannequin commented Jun 28, 2017

comment:10

OK, i've merged with the most recent beta and solved a conflict in integral.py, maybe that was the reason, we'll see..

@tscrim
Copy link
Collaborator

tscrim commented Jun 29, 2017

comment:11

This is not really a bug:

        sage: N(integrate(exp(x^3), (x, 1, 2)))    # known bug (non-zero imag part)
        275.510983763312

Instead, it is more of an issue with the numerics from the indefinite integral:

sage: integral(exp(x^3), x)
-1/3*x*gamma(1/3, -x^3)/(-x^3)^(1/3)

Also author name.

@tscrim tscrim modified the milestones: sage-6.6, sage-8.0 Jun 29, 2017
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 29, 2017

Changed commit from 00fc6d3 to 82161f2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 29, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

82161f2check real AND imag part

@mforets
Copy link
Mannequin

mforets mannequin commented Jun 29, 2017

comment:13

@sagetrac-travis: yes, you're right, i've changed it.

@mforets
Copy link
Mannequin

mforets mannequin commented Jun 29, 2017

Author: Marcelo Forets

@mforets mforets mannequin added s: needs review and removed s: needs work labels Jun 29, 2017
@tscrim
Copy link
Collaborator

tscrim commented Jun 29, 2017

comment:14

LGTM.

@tscrim
Copy link
Collaborator

tscrim commented Jun 29, 2017

Reviewer: Travis Scrimshaw

@vbraun
Copy link
Member

vbraun commented Jul 26, 2017

Changed branch from u/mforets/wrong_integral_of_exp_x_3__from_1_to_2_ to 82161f2

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