ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 22 Jan 2013 17:10:56 -0600Unable to evaluate integral of x*x/(exp(x)+1)http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/I was trying to evaluate the following integral using sage
integrate(x*x/(exp(x)+1),x,0,oo)
and I get the following answer
3/2*zeta(3) + limit(1/3*x^3 - x^2*log(e^x + 1) - 2*x*polylog(2, -e^x) +
2*polylog(3, -e^x), x, +Infinity, minus)
However, mathematica gives just the first term `3/2*zeta(3)`. Is there a way to get just the zeta function for integrals of the form `x^n/(exp(x)+1)`? The limit makes it difficult to calculate the numerical values in the end
Mon, 21 Jan 2013 08:32:45 -0600http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/Answer by achrzesz for <p>I was trying to evaluate the following integral using sage</p>
<pre><code>integrate(x*x/(exp(x)+1),x,0,oo)
</code></pre>
<p>and I get the following answer</p>
<pre><code>3/2*zeta(3) + limit(1/3*x^3 - x^2*log(e^x + 1) - 2*x*polylog(2, -e^x) +
2*polylog(3, -e^x), x, +Infinity, minus)
</code></pre>
<p>However, mathematica gives just the first term <code>3/2*zeta(3)</code>. Is there a way to get just the zeta function for integrals of the form <code>x^n/(exp(x)+1)</code>? The limit makes it difficult to calculate the numerical values in the end</p>
http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?answer=14484#post-id-14484Maxima can not compute the limit but expanding into series
and integrating term by term helps:
sage: maxima('powerseries(x^2*exp(-x)/(exp(-x)+1),exp(-x),0)')
x^2*%e^-x*'sum((-1)^i1*%e^-(i1*x),i1,0,inf)
sage: var('k x');
sage: assume(k+1>0);
sage: sum(integrate(x^2*exp(-x)*(-1)^k*exp(-(k*x)),x,0,oo),k,0,oo)
3/2*zeta(3)
Mon, 21 Jan 2013 18:32:41 -0600http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?answer=14484#post-id-14484Comment by achrzesz for <p>Maxima can not compute the limit but expanding into series
and integrating term by term helps:</p>
<pre><code>sage: maxima('powerseries(x^2*exp(-x)/(exp(-x)+1),exp(-x),0)')
x^2*%e^-x*'sum((-1)^i1*%e^-(i1*x),i1,0,inf)
sage: var('k x');
sage: assume(k+1>0);
sage: sum(integrate(x^2*exp(-x)*(-1)^k*exp(-(k*x)),x,0,oo),k,0,oo)
3/2*zeta(3)
</code></pre>
http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18351#post-id-18351Zeta is by definition the sum of a series, so this approach seems to be natural. I suspect that Mathematica uses a similar approach.
As far as the speed is concerned:
sage: timeit('numerical_integral(x^2/(exp(x)+1),0,oo)')
625 loops, best of 3: 1.36 ms per loop
Tue, 22 Jan 2013 17:10:56 -0600http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18351#post-id-18351Comment by Shashank for <p>Maxima can not compute the limit but expanding into series
and integrating term by term helps:</p>
<pre><code>sage: maxima('powerseries(x^2*exp(-x)/(exp(-x)+1),exp(-x),0)')
x^2*%e^-x*'sum((-1)^i1*%e^-(i1*x),i1,0,inf)
sage: var('k x');
sage: assume(k+1>0);
sage: sum(integrate(x^2*exp(-x)*(-1)^k*exp(-(k*x)),x,0,oo),k,0,oo)
3/2*zeta(3)
</code></pre>
http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18354#post-id-18354Thanks a lot! That works, but still don't understand why I have to expand the function in series and then intergrate it term by term. Also, do you know how this affects the speed. Naively I would think that summing would take a long time. Tue, 22 Jan 2013 09:13:29 -0600http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18354#post-id-18354Comment by achrzesz for <p>Maxima can not compute the limit but expanding into series
and integrating term by term helps:</p>
<pre><code>sage: maxima('powerseries(x^2*exp(-x)/(exp(-x)+1),exp(-x),0)')
x^2*%e^-x*'sum((-1)^i1*%e^-(i1*x),i1,0,inf)
sage: var('k x');
sage: assume(k+1>0);
sage: sum(integrate(x^2*exp(-x)*(-1)^k*exp(-(k*x)),x,0,oo),k,0,oo)
3/2*zeta(3)
</code></pre>
http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18355#post-id-18355This method works for higher powers of x
Wolfram alpha does not allow for x^n, n>4Tue, 22 Jan 2013 00:46:25 -0600http://ask.sagemath.org/question/9726/unable-to-evaluate-integral-of-xxexpx1/?comment=18355#post-id-18355