Ask Your Question
2

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

asked 2015-03-16 22:59:03 +0100

mathhobbyist gravatar image

updated 2023-01-10 00:01:11 +0100

tmonteil gravatar image

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2015-03-16 23:41:40 +0100

tmonteil gravatar image

updated 2015-03-17 00:10:28 +0100

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

edit flag offensive delete link more

Comments

This bug is now fixed !

tmonteil gravatar imagetmonteil ( 2017-10-30 19:58:23 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-16 22:59:03 +0100

Seen: 425 times

Last updated: Mar 17 '15