Ask Your Question
3

How do I understand the result of symbolic integrals

asked 2010-08-18 20:04:12 +0100

Philipp Schneider gravatar image

updated 2023-01-09 23:59:30 +0100

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

7 Answers

Sort by ยป oldest newest most voted
1

answered 2011-12-21 22:55:20 +0100

updated 2011-12-21 23:04:05 +0100

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

http://en.wikipedia.org/wiki/Exponent... http://en.wikipedia.org/wiki/Incomple...

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

Comments

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

kcrisman gravatar imagekcrisman ( 2011-12-21 23:12:59 +0100 )edit
1

answered 2010-08-18 20:37:41 +0100

William Stein gravatar image

updated 2010-08-18 20:38:02 +0100

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

Comments

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

mmarco gravatar imagemmarco ( 2011-12-22 10:22:22 +0100 )edit
1

answered 2011-12-22 02:03:01 +0100

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
1

answered 2010-08-20 15:56:42 +0100

Robert Dodier gravatar image

updated 2021-01-21 23:46:14 +0100

slelievre gravatar image

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
0

answered 2021-12-24 07:01:58 +0100

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.

edit flag offensive delete link more
0

answered 2011-12-22 03:54:00 +0100

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

Comments

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

kcrisman gravatar imagekcrisman ( 2011-12-23 12:08:54 +0100 )edit
0

answered 2010-08-19 15:14:38 +0100

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

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 1,278 times

Last updated: Jan 21 '21