Opened 4 years ago
Closed 2 years ago
#17968 closed defect (fixed)
Wrong integral of exp(x^3) from 1 to 2.
Reported by:  tmonteil  Owned by:  

Priority:  major  Milestone:  sage8.0 
Component:  symbolics  Keywords:  
Cc:  kcrisman, mforets  Merged in:  
Authors:  Marcelo Forets  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  82161f2 (Commits)  Commit:  82161f2fd032766b6f190415761c5cd3cab11ae1 
Dependencies:  Stopgaps: 
Description
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.0587863771115628e12)
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.68744844960818e21*I
Change History (15)
comment:1 Changed 4 years ago by
comment:2 followup: ↓ 4 Changed 2 years ago by
This seems to be fixed by now:
sage: version() SageMath version 7.5, Release Date: 20170111 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.21644966006352e14*I
should this ticket be closed?
comment:3 Changed 2 years ago by
 Cc kcrisman mforets added
comment:4 in reply to: ↑ 2 ; followup: ↓ 6 Changed 2 years ago by
Replying to mforets:
This seems to be fixed by now:
sage: version() SageMath version 7.5, Release Date: 20170111 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.21644966006352e14*Ishould 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.
comment:5 Changed 2 years ago by
 Branch set to u/mforets/wrong_integral_of_exp_x_3__from_1_to_2_
comment:6 in reply to: ↑ 4 Changed 2 years ago by
 Commit set to 69a3e107975e16c55e4f2b0f17dd3cbd4aabc336
Replying to tmonteil:
Replying to mforets:
This seems to be fixed by now:
sage: version() SageMath version 7.5, Release Date: 20170111 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.21644966006352e14*Ishould 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:
69a3e10  add doctest for ticket 17968

comment:7 Changed 2 years ago by
 Status changed from new to needs_review
comment:8 Changed 2 years ago by
Apparently doesn't apply for some reason.
comment:9 Changed 2 years ago by
 Commit changed from 69a3e107975e16c55e4f2b0f17dd3cbd4aabc336 to 00fc6d3a2d7098c804296337690ff12ad7e99fb0
comment:10 Changed 2 years ago by
OK, i've merged with the most recent beta and solved a conflict in integral.py
, maybe that was the reason, we'll see..
comment:11 Changed 2 years ago by
 Milestone changed from sage6.6 to sage8.0
 Status changed from needs_review to needs_work
This is not really a bug:
sage: N(integrate(exp(x^3), (x, 1, 2))) # known bug (nonzero 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.
comment:12 Changed 2 years ago by
 Commit changed from 00fc6d3a2d7098c804296337690ff12ad7e99fb0 to 82161f2fd032766b6f190415761c5cd3cab11ae1
Branch pushed to git repo; I updated commit sha1. New commits:
82161f2  check real AND imag part

comment:13 Changed 2 years ago by
 Status changed from needs_work to needs_review
@travis: yes, you're right, i've changed it.
comment:14 Changed 2 years ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
LGTM.
comment:15 Changed 2 years ago by
 Branch changed from u/mforets/wrong_integral_of_exp_x_3__from_1_to_2_ to 82161f2fd032766b6f190415761c5cd3cab11ae1
 Resolution set to fixed
 Status changed from positive_review to closed
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:
which seems to be the same issue as we have. Possibly related is #17328 or #11164. WA 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.