Trying to evaluate the integral $$\int_0^\infty \frac{\log(x)^2}{(1+x)^2}dx$$

or equivalently $$\int_{-\infty}^\infty e^x\frac{x^2}{(1+e^x)^2}dx$$ The answer should be $\frac{\pi^2}{3}$

Looks like we can use residue theorem, but the integration path does not seem to be easy to choose

  • 1
    $\begingroup$ This is NOT the same problem, but it might be helpful in terms of setting up a path regarding that logarithm: math.stackexchange.com/questions/191736/… $\endgroup$
    – imranfat
    May 5, 2018 at 4:00
  • $\begingroup$ If you want to use a residue based approach, then you will probably want to use a keyhole contour. $\endgroup$
    – Frank W
    May 5, 2018 at 5:45
  • $\begingroup$ Another way to evaluate this integral is to use differentiation under the integral and rewrite it so that$$I=\lim\limits_{\mu\to0}\frac {\partial^2}{\partial\mu^2}\left[\frac {\pi\mu}{\sin\pi\mu}\right]=\frac {\pi^2}3$$ $\endgroup$
    – Frank W
    May 5, 2018 at 5:59

2 Answers 2


Since you want to use the residue theorem, I'll provide the contour-analysis based approach using a keyhole contour (the coolest way of evaluating this integral).

A nice tip you can use when you want to use a residue-based approach and see that your function has a logarithm in the numerator is to consider the same function with the logarithm raised to an extra power of one. In this case, the power is two so we use the function$$g(z)=f(z)\log^3z\qquad\qquad f(z)=\frac 1{(1+z)^2}$$And the contour we integrate, pictured below, is a keyhole contour.


A keyhole contour allows us to derive the integral by exploiting the logarithm's multivalued behavior. In this case, we define the argument above the positive real axis to be zero and below to be $2\pi$. I.e $z=x$ above and $z=xe^{2\pi i}$ below the real axis.

To evaluate the contour integral, we first parametrize about each piece of the contour. Let the larger and smaller circle have a radius of $R$ and $\epsilon$ respectively and the arcs $\Gamma_{R}$ and $\gamma_{\epsilon}$ respectively. Now define the complex function$$f(z)=\frac 1{(1+z)^2}$$

and integrate it about the contour to get$$\begin{multline}\oint\limits_{\mathrm C}dz\, f(z)\log^3z=\int\limits_{\epsilon}^{R}dx\, f(x)\log^3x+\int\limits_{\Gamma_{R}}dz\, f(z)\log^3z\\-\int\limits_{\epsilon}^{R}dx\, f(x)(\log|x|+2\pi i)^3+\int\limits_{\gamma_{\epsilon}}dz\, f(z)\log^3z\end{multline}$$

As $R\to\infty$ and $\epsilon\to0$, the second and fourth integrals vanish, leaving us with$$\oint\limits_{\mathrm C}dz\, f(z)\log^3z=-12\pi^2\int\limits_0^{\infty}dx\, f(x)\log x-6\pi^2 i\int\limits_0^{\infty}dx\, f(x)\log^2x+8\pi^2i\int\limits_0^{\infty}dx\, f(x)$$Where the middle integral is the one we want. The residue at $z=-1$ is$$\operatorname*{Res}_{z\, =\, -1}\frac {\log^3z}{(1+z)^2}=\lim\limits_{z\to -1}\frac {d}{dz}\,\frac {(z+1)^2\log^3z}{(z+1)^2}=3\pi^2$$So the contour integral is simply $2\pi i$ times that. Taking the imaginary part gives$$6\pi^3=-6\pi\int\limits_0^{\infty}dx\, f(x)\log^2x+8\pi^3\underbrace{\int\limits_0^{\infty}dx\, f(x)}_1$$Isolating and dividing both sides by $-6\pi$, it's clear that$$\int\limits_0^{\infty}dx\,\frac {\log^2x}{(1+x)^2}\color{blue}{=\frac {\pi^2}3}$$


We can compute directly.

$$\int_0^{\infty}\frac{\log^2x}{(1+x)^2}dx = \int_{0}^1 \frac{\log^2x}{(1+x)^2}dx + \int_1^{\infty}\frac{\log^2x}{(1+x)^2}dx. $$

With a change of variable $t=\frac{1}{x}$ in the second integral we have

$$\int_{1}^{\infty} \frac{\log^2x}{(1+x)^2} dx = \int_0^1\frac{\log^2t}{(1+t)^2}dt.$$

Then we have $$\int_0^\infty\frac{\log^2x}{(1+x)^2} dx = 2 \int_0^1 \frac{\log^2x}{(1+x)^2} dx$$

and we only need to compute the last integral.


$$\int_0^1 \frac{\log^2x}{(1+x)^2} dx = \int_0^1 \frac{\log^2x}{(1+x)} dx - \int_0^1 \frac{x\log^2x}{(1+x)^2}dx$$ and a integration by parts gives $$\int_0^1\frac{x\log^2x}{(1+x)^2} dx= -\int_0^1 x\log^2x d\left(\frac{1}{1+x}\right) = \int_0^1 \frac{\log^2x}{(1+x)} dx + 2\int_0^1\frac{\log x}{1+x}dx.$$

As a result, we have $$\int_0^1\frac{\log^2x}{(1+x)^2} dx = -2 \int_0^1 \frac{\log x}{1+x}dx = -2\int_0^1 \log x \sum_{n=0}^\infty (-x)^n dx =2 \sum_{n=0}^\infty (-1)^n \frac{1}{(n+1)^2} = \frac{\pi^2}{6},$$

where the term by term integration can be justified by the Fubini's theorem.

After all, the result is $\frac{\pi^2}{3}$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .