Opened 5 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: sage-8.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.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

Change History (15)

comment:1 Changed 5 years ago by kcrisman

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.

comment:2 follow-up: Changed 3 years ago by 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?

comment:3 Changed 3 years ago by mforets

  • Cc kcrisman mforets added

comment:4 in reply to: ↑ 2 ; follow-up: Changed 3 years ago by 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.

comment:5 Changed 3 years ago by mforets

  • Branch set to u/mforets/wrong_integral_of_exp_x_3__from_1_to_2_

comment:6 in reply to: ↑ 4 Changed 3 years ago by mforets

  • 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: 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

comment:7 Changed 3 years ago by mforets

  • Status changed from new to needs_review

comment:8 Changed 2 years ago by kcrisman

Apparently doesn't apply for some reason.

comment:9 Changed 2 years ago by git

  • Commit changed from 69a3e107975e16c55e4f2b0f17dd3cbd4aabc336 to 00fc6d3a2d7098c804296337690ff12ad7e99fb0

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

bbd9432merge w/integral.py
00fc6d3trac:17968 doctest

comment:10 Changed 2 years ago by mforets

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 tscrim

  • Milestone changed from sage-6.6 to sage-8.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 (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.

comment:12 Changed 2 years ago by git

  • Commit changed from 00fc6d3a2d7098c804296337690ff12ad7e99fb0 to 82161f2fd032766b6f190415761c5cd3cab11ae1

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

82161f2check real AND imag part

comment:13 Changed 2 years ago by mforets

  • Authors set to Marcelo Forets
  • Status changed from needs_work to needs_review

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

comment:14 Changed 2 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:15 Changed 2 years ago by vbraun

  • 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
Note: See TracTickets for help on using tickets.