Ask Your Question

How do I understand the result of symbolic integrals

asked 2010-08-18 13:04:12 -0500

Philipp Schneider gravatar image

updated 2013-09-15 12:41:35 -0500

tmonteil gravatar image

So now I know how to integrate, but when I type in

sage: deriv=diff((exp(x)-1)/x,x); deriv
e^x/x - (e^x - 1)/x^2
sage: deriv.integrate(x)
-1/x + Ei(x) - gamma(-1, -x)

why don't I get back (exp(x)-1)/x +C?

edit retag flag offensive close merge delete

6 answers

Sort by » oldest newest most voted

answered 2011-12-21 15:55:20 -0500

updated 2011-12-21 16:04:05 -0500

Incomplete Gamma function and the Ei function are indeed related. See the following pages for example.

In this sense, the result of the integration is correct.

There is indeed a subtly of brunch cut. Maxima / Sage defines the brunch cut of the function differently from Mathematica. I tested the Maxima result "-1/x + Ei(x) - gamma(-1, -x)" is indeed continuous on the complex plane (i.e. the result has no problem). But the same function in Mathematica is not continuous.

edit flag offensive delete link more


Yeah, see for another example of how this relationship causes trouble in Maxima/Sage.

kcrisman gravatar imagekcrisman ( 2011-12-21 16:12:59 -0500 )edit

answered 2010-08-18 13:37:41 -0500

William Stein gravatar image

updated 2010-08-18 13:38:02 -0500

Maxima is responsible for default symbolic integration in Sage, and nobody understands how Maxima's integration code works. I just tried continuing your example above as follows:

   sage: deriv=diff((exp(x)-1)/x,x); deriv
   sage: f = integrate(deriv, x)
   sage: g = f - (exp(x)-1)/x
   sage: CDF(g(5))
   -1.7776787288 + 2.08166817117e-17*I
   sage: CDF(g(10))
   -4.43650184726 + 2.22044604925e-16*I
   sage: CDF(g(20))
   -0.530325316824 + 2.27373675443e-12*I

So it doesn't even look like f differs from (exp(x)-1)/x by a constant. Branch cuts are probably relevant. I can't wait until we have our symbolic integration code that we actually understand.

edit flag offensive delete link more


Is there any work on rewriting the whole integration functions in sage?

mmarco gravatar imagemmarco ( 2011-12-22 03:22:22 -0500 )edit

answered 2010-08-19 08:14:38 -0500

kcrisman gravatar image

I wouldn't blame the integration code; these are really hard problems. The problem is that simplification of the integral doesn't work because of logs, so it's left alone. Wolfram Alpha, for instance, simplifies this expression to something that definitely only would work in certain circumstances. Maybe this is another symptom of whether we assume variables are real in our Maxima?

edit flag offensive delete link more

answered 2011-12-21 20:54:00 -0500

achrzesz gravatar image

In one line:

sage: maxima('integrate(diff((exp(x)-1)/x,x),x),gamma_expand:true,factor').sage()

(e^x - 1)/x

edit flag offensive delete link more


Sounds like we might need to look at `gamma_expand:true` a little more closely!

kcrisman gravatar imagekcrisman ( 2011-12-23 05:08:54 -0500 )edit

answered 2011-12-21 19:03:01 -0500

achrzesz gravatar image

sage: maxima('gamma_expand:true') true sage: maxima('deriv:diff((exp(x)-1)/x,x)') %e^x/x-(%e^x-1)/x^2 sage: maxima('factor(integrate(deriv,x))') (%e^x-1)/x

edit flag offensive delete link more

answered 2010-08-20 08:56:42 -0500

Maxima 5.21.1 gives -1/x-gamma_incomplete(0,-x)-gamma_incomplete(-1,-x) for integrate(diff((exp(x) - 1)/x, x), x) which is correct from what I can tell (agrees numerically with the original expression and has the same derivative).

The result isn't as simple as it could be because the integration algorithm is phrased in more general terms, such that the integrand you specified is a special case of some general form. Often that's the most effective way to calculate integrals, since you can cover a lot of special cases with one general form.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2010-08-18 13:04:12 -0500

Seen: 409 times

Last updated: Dec 21 '11