Ask Your Question

# How do I understand the result of symbolic integrals

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

## 7 Answers

Sort by ยป oldest newest most voted

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

more

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.

more

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.

more

## Comments

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

( 2011-12-22 10:22:22 +0200 )edit

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.

more

## Comments

Yeah, see http://trac.sagemath.org/sage_trac/ticket/11164 for another example of how this relationship causes trouble in Maxima/Sage.

( 2011-12-21 23:12:59 +0200 )edit

This is a really old question, but the answers omit a significant fact.

Let us say that w = %e^x/x-(%e^x-1)/x^2. As computed here (DERIV ...)

From the given construction we know that ONE anti-derivative of w is (exp(x)-1)/x; but there are an infinite number of anti-derivatives. remember your calculus ... + a constant.

From Maxima we know (in the absence of bugs etc) that another anti-derivative is

-1/x-gamma_incomplete(0,-x)-gamma_incomplete(-1,-x)

They don't have to be the same.

They can differ by a constant. As it happens, they don't. But they could.

more

In one line:

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

(e^x - 1)/x

more

## Comments

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

( 2011-12-23 12:08:54 +0200 )edit

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?

more

## Your Answer

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

Add Answer

## Stats

Asked: 2010-08-18 20:04:12 +0200

Seen: 843 times

Last updated: Jan 21 '21