# How to evaluate $\int_1^2 e^{x^3} dx$?

I tried to evaluate $\int_1^2 e^{x^3} dx$ in Sage. Is this a bug?

┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.5, Release Date: 2015-02-17                         │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: x=var('x');N(integrate(exp(x^3),x,1,2))
-138.557717219510 - 238.442320120796*I
sage:

edit retag close merge delete

Sort by » oldest newest most voted

This looks indeed like a bug. Thanks for reporting, it is now trac ticket 17968.

For numerical integration, you should use the numerical_integral function:

sage: f(x) = exp(x^3)
sage: numerical_integral(f,1,2)
(275.5109837633117, 3.0587863771115628e-12)


Note that, if you want to stay in the symbolic world, sympy seems to do the job:

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
exp(-I*pi/3)*gamma(1/3)*lowergamma(1/3, 8*exp_polar(I*pi))/(9*gamma(4/3)) - exp(-I*pi/3)*gamma(1/3)*lowergamma(1/3, exp_polar(I*pi))/(9*gamma(4/3))
sage: h.n()
275.510983763312 - 1.68744844960818e-21*I


Which is consistent with the numerical approach (the imaginary part is just numerical noise).

more

This bug is now fixed !

( 2017-10-30 13:58:23 -0600 )edit