How can I show this? $$ \int_{-\infty}^{\infty} x^2 \frac{e^x}{(e^x+1)^2} dx = \pi^2/3$$

I tried applying residuals, but the pole is of infinite(?) order.

  • 1
    $\begingroup$ That's a nasty one. I like it! $\endgroup$ May 26 '16 at 17:30
  • 2
    $\begingroup$ Hint 1 the integrated function is even. So we can evaluate the integral from 0 to infinity. $\endgroup$
    – A s
    May 26 '16 at 17:34
  • $\begingroup$ Okay, that the function is even doesn't really help me. What I noticed is the indefinite integral of $e^x/(e^x+1)^2$ is $1/(e^x+1)$. Maybe some weird form of integration by parts? $\endgroup$
    – Christian
    May 26 '16 at 17:48
  • $\begingroup$ Yes, it's funny that if you change $e^x$ to $e^{-x}$ then again you get the same fraction! $\endgroup$ May 26 '16 at 18:01
  • $\begingroup$ That $\pi$ there says either we should transform into Gamma function, or we may have to go to complex analysis integration over contours. $\endgroup$ May 26 '16 at 18:08

Here, we present an approach that uses "Feynmann's Trick" for differentiating under the integral along with Contour Integration.

Let $I$ be the integral given by

$$I=\int_{-\infty}^\infty \frac{x^2e^x}{(e^x+1)^2}\,dx$$


Enforcing the substitution $x\to \log(x)$ reveals

$$\begin{align} I&=\int_0^\infty \frac{\log^2(x)}{(x+1)^2}\,dx\\\\ &=\bbox[5px,border:2px solid #C0A000]{\left.\left(\frac{d^2}{da^2}\int_0^\infty \frac{x^a}{(x+1)^2}\,dx\right)\right|_{a=0}} \tag 1 \end{align}$$


To evaluate the integral in $(1)$, we move to the complex plane and analyze the closed-contour integral $J(a)$ given by

$$\bbox[5px,border:2px solid #C0A000]{J(a)=\oint_C \frac{z^a}{(1+z)^2}\,dz} \tag 2$$

where $C$ is the classical "key-hole" contour along the branch cut extending from the origin along the non-negative real axis.

Evaluation Using the Residue Theorem

From the Residue Theorem, $J(a)$ is given by

$$\begin{align} J(a)&=2\pi i \text{Res}\left(\frac{z^a}{(1+z)^2}, z=-1\right)\\\\ &=2\pi i \left.\frac{d}{dz}\left((1+z)^2\frac{z^a}{(1+z)^2}\right)\right|{z=-1}\\\\ &=\bbox[5px,border:2px solid #C0A000]{-2\pi i a e^{i\pi a}} \tag 2 \end{align}$$

Decomposing $J(a)$

Next, we write $J(a)$ as

$$\begin{align} J(a)&=\int_0^\infty \frac{x^a}{(1+x)^2}\,dx-\int_0^\infty \frac{x^ae^{i2\pi a}}{(1+x)^2}\,dx\\\\ &=\bbox[5px,border:2px solid #C0A000]{(1-e^{i2\pi a})\int_0^\infty \frac{x^a}{(1+x)^2}\,dx} \tag 3 \end{align}$$


From $(2)$ and $(3)$ we see that

$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{x^a}{(1+x)^2}\,dx=\frac{\pi a}{\sin(\pi a)}} \tag 4$$


Finally, using $(4)$ in $(1)$ reveals

$$\begin{align} I&=\left.\left(\frac{d^2}{da^2}\frac{\pi a}{\sin(\pi a)}\right)\right|_{a=0}\\\\ &=\lim_{a\to 0}\left(\frac{\pi^3 a(1+\cos^2(\pi a))-2\pi^2 \cos(\pi a)\sin(\pi a)}{\sin^3(\pi a)}\right)\\\\\ &=\frac{\pi^2}{3} \end{align}$$

as was to be shown!

  • $\begingroup$ Very well organized answer +1. Especially in line with what OP was trying to do (i.e. using residues). $\endgroup$ Jun 5 '16 at 4:21
  • $\begingroup$ @ParamanandSingh Thank you Paramanand! Much appreciative. -Mark $\endgroup$
    – Mark Viola
    Jun 5 '16 at 4:24
  • $\begingroup$ Beautiful answer @Dr.MV $\endgroup$
    – Mathxx
    Jun 5 '16 at 4:28
  • $\begingroup$ @Mathxx Wow, thank you for that note! $\endgroup$
    – Mark Viola
    Jun 5 '16 at 4:30

We have $$\frac d{dx}\frac1{e^x+1}=\frac{-e^x}{(e^x+1)^2}$$ Also $$\frac{e^x}{(e^x+1)^2}=\frac{e^{-x}}{(1+e^{-x})^2}$$ So $$\begin{align}\int_{-\infty}^{\infty}x^2\frac{e^x}{(e^x+1)^2}dx&=2\int_0^{\infty}x^2\frac{e^x}{(e^x+1)^2}dx=-2\int_0^{\infty}x^2\frac d{dx}\frac1{e^x+1}dx\\ &=\left.-2x^2\frac1{e^x+1}\right|_0^{\infty}+4\int_0^{\infty}\frac x{e^x+1}dx\\ &=0+4\int_0^{\infty}\frac{xe^{-x}}{e^{-x}+1}dx=4\sum_{k=0}^{\infty}(-1)^k\int_0^{\infty}xe^{-(k+1)x}dx\\ &=4\sum_{k=0}^{\infty}(-1)^k \frac{\Gamma(2)}{(k+1)^2}=4\sum_{k=1}^{\infty}\frac{(-1)^{k+1}}{k^2}\\ &=4\left(1-\frac24\right)\zeta(2)=2\frac{\pi^2}6=\frac{\pi^2}3\end{align}$$


Another approach. We have $$\int_{-\infty}^{\infty}\frac{x^{2}e^{x}}{\left(e^{x}+1\right)^{2}}dx=2\int_{0}^{\infty}\frac{x^{2}e^{x}}{\left(e^{x}+1\right)^{2}}dx=2\int_{0}^{\infty}\frac{x^{2}}{e^{x}+1}dx-2\int_{0}^{\infty}\frac{x^{2}}{\left(e^{x}+1\right)^{2}}dx. $$ The first integral is classical $$2\int_{0}^{\infty}\frac{x^{2}}{e^{x}+1}dx=2\sum_{k\geq0}\left(-1\right)^{k}\int_{0}^{\infty}x^{2}e^{-x\left(k+1\right)}dx $$ $$=4\sum_{k\geq0}\frac{\left(-1\right)^{k}}{\left(k+1\right)^{3}}=3\zeta\left(3\right) $$ and in a similar way we can compute the other integral $$2\int_{0}^{\infty}\frac{x^{2}}{\left(e^{x}+1\right)^{2}}dx=2\sum_{k\geq0}k\left(-1\right)^{k-1}\int_{0}^{\infty}x^{2}e^{-x\left(k+1\right)}dx $$ $$=4\sum_{k\geq0}\frac{k\left(-1\right)^{k-1}}{\left(k+1\right)^{3}}=-\frac{\pi^{2}}{3}+3\zeta\left(3\right) $$ hence $$\int_{-\infty}^{\infty}\frac{x^{2}e^{x}}{\left(e^{x}+1\right)^{2}}dx=\frac{\pi^{2}}{3}$$ as wanted.


I would start by trying to find the indefinite integral, as follows: $$ \frac{d}{dx} \frac{x2e^x}{(1+e^x)^2} = \frac{x^2e^x}{(1+e^x)^2}+2\frac{x e^x}{1+e^x} $$ Now let's try to rid ourselves of the $2\frac{x e^x}{1+e^x}$: $$ \frac{d}{dx} \left( 2x \log(1+e^x) \right) = 2\frac{x e^x}{1+e^x} + 2 \log(1+e^x) $$ Well, we now have to add back $2\int \log(1+e^x) dx$. But this is progress because dilogarithms are your friend. (You can tell I don't have many human friends.) In particular, $$ \frac{d}{du} \mbox{Li}_2 (u) = -\frac{\log(1-u)}{u} $$ and if we substitute $u=-e^x$ we can find that $$ \frac{d}{dx} \mbox{Li}_2 (-e^{x}) = -\log(1+e^x) $$ So we can find the indefinite integral: $$ \int\frac{x^2e^x}{(1+e^x)^2}dx = x^2\frac{e^x}{(1+e^x)^2}-2x\log(1+e^x) - 2\mbox{ Li}_2(-e^x) $$ After all of that, we deserve to be close to finished, but now we need to find the value of the improper definite integral. We want $$ \lim_{x\to\infty} \left[ x^2\frac{e^x}{(1+e^x)^2}-2x\log(1+e^x) - 2\mbox{ Li}_2(-e^x) -x^2\frac{e^{-x}}{(1+e^{_x})^2}-2x\log(1+e^{-x})+2\mbox{ Li}_2(-e^{-x})\right] $$ Of these six terms, the last three (that is, all three terms form the negative side of the improper definite integral) go to zero in the limit as $x->\infty$. We are left with $$ \lim_{x\to\infty} \left[ x^2\frac{e^x}{(1+e^x)^2}-2x\log(1+e^x) - 2\mbox{ Li}_2(-e^x) \right] $$ We know (at least if we have been on a couple of dates with dilogarithms) that $$ \lim_{x\to\infty} \mbox{ Li}_2(-e^x) +\frac{x^2}{2} = -\frac{\pi^2}{6} $$ It is easy to see that $$\lim_{x\to\infty} \left(x^2\frac{e^x}{(1+e^x)^2} -x^2 \right)=0 $$ And it is not too hard to see that $$\lim_{x\to\infty} \left( x\log(1+e^x) -x^2 \right)=0$$ (effectively, for large $x$, the $1$ in the log doesn't matter so the log looks like $x$).

Combining these limits, we find that our answer is $$ \lim_{x\to\infty} \left[ \left(x^2\frac{e^x}{(1+e^x)^2} -x^2\right)\\ -2\left(x\log(1+e^x) -x^2\right)\\- 2 \left(\mbox{ Li}_2(-e^x) +\frac12 x^2 \right)\\+x^2-2x^2+x^2\right]\\ = 0 -2 \cdot 0 -2 \cdot \left( -\frac{\pi^2}{6}\right) = \frac{\pi^2}{3} $$


Consider \begin{align} I(a)&=\int_0^\infty\frac{x}{1+e^{ax}}\ \mathrm dx\\[9pt] &=\int_0^\infty\frac{x\ e^{-ax}}{1+e^{-ax}}\ \mathrm dx\\[9pt] &=\int_0^\infty\sum_{k=0}^\infty\ (-1)^k\ xe^{-a(k+1)x}\ \mathrm dx\\[9pt] &=\sum_{k=0}^\infty\ (-1)^k\int_0^\infty xe^{-a(k+1)x}\ \mathrm dx\\[9pt] &=\sum_{k=0}^\infty\ \frac{(-1)^k}{a^2(k+1)^2}\\[9pt] &=\frac{\pi^2}{12a^2}\\[9pt] \end{align} then the given integral is simply $2I'(-1)$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.