Contour integral with a logarithm squared

The integral I'd like to evaluate is $\int_0^\infty \frac{\log^2 x \, dx}{(1+x)^2}$. I consider the function $f(z) = \frac{\text{Log}^2 z}{(1+z)^2}$, which has a pole of order 2 at $z=-1$ and has a branch point at $z=0$. I set up the integral $\oint_C f(z) dz$ along the contour $C = C_1 + C_2 + C_3 + C_4 + C_5 + C_6$, which consists of $C_1$ going just above the branch cut from $0$ to infinity, $C_2$, which is a big half-circle, $C_3$, which is a piece along the real axis from infinity to a point infinitesimally close to $z=-1$, $C_4$, which is a small half-circle going around $z=-1$ clockwise, $C_5$, which is another small piece on the real axis, and, finally, $C_6$, which is a quarter-circle around the origin to close the contour.

Now, I take the branch with $\text{Log}(z) = \log(r) + i \theta$, $0 \le\theta<2\pi$. Then the piece along $C_1$ is the integral $I$ I want to calculate. The pieces along $C_2$ and $C_6$ are zero when we take appropriate limits, but I'm not sure what to do with all the other pieces, since we can't really (can we?) write them in a way "$\text{something} \cdot I$", because of the singularity at $z=-1$. I know what I would do in the case of $1+z^2$ in the denominator, but not in this one. Suggestions?

• The way you are sketching out the solution gives you, as the contour integral $$-PV \int_0^{\infty} dx \frac{(\log{x}+i \pi)^2}{(1-x)^2} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{\log^2{(e^{i \pi}+\epsilon e^{i \phi})}}{(\epsilon e^{i \phi})^2} \\ + \int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2}$$ This forces you to evaluate a wholly different principal value integral and is sort of leading you astray. I prefer the way I outline using a keyhole contour which, while it requires using a log cubed, gets us there. – Ron Gordon Dec 27 '15 at 6:38

I would consider the integral

$$\oint_C dz \frac{\log^3{z}}{(1+z)^2}$$

where $C$ is a keyhole contour about the real axis of radius $R$. Then as $R \to \infty$ the integral is equal to

$$-i 6 \pi \int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} + 12 \pi^2 \int_0^{\infty} dx \frac{\log{x}}{(1+x)^2} +i 8 \pi^3 \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^3{z}}{(1+z)^2}$$

Note that the definition of the keyhole contour implies that the pole at $z=-1$ is necessarily represented as $z=e^{i \pi}$, as $\arg{z} \in [0,2 \pi]$.

To evaluate the other integrals we consider similar contour integrals:

$$\oint_C dz \frac{\log^2{z}}{(1+z)^2} = -i 4 \pi \int_0^{\infty} dx \frac{\log{x}}{(1+x)^2} + 4 \pi^2 \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^2{z}}{(1+z)^2}$$

$$\oint_C dz \frac{\log{z}}{(1+z)^2} = -i 2 \pi \int_0^{\infty} dx \frac{1}{(1+x)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2}$$

Back substituting the other integral expressions into the first one, we find that

$$-i 6 \pi \int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} + 12 \pi^2 \left [ i \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2}-\frac12 \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^2{z}}{(1+z)^2}\right ] \\ -i 8 \pi^3 \operatorname*{Res}_{z=e^{i \pi}} \frac{\log{z}}{(1+z)^2} = i 2 \pi \operatorname*{Res}_{z=e^{i \pi}} \frac{\log^3{z}}{(1+z)^2}$$

or

\begin{align}\int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} &= \operatorname*{Res}_{z=e^{i \pi}} \frac{(2 \pi^2/3 )\log{z}+ i \pi \log^2{z} - (1/3) \log^3{z}}{(1+z)^2}\\ &= \left (\frac{2 \pi^2}{3} \right )\frac1{e^{i \pi}} + (i \pi) 2 \frac{i \pi}{e^{i \pi}} -\frac13 \frac{3 (i \pi)^2}{e^{i \pi}}\end{align}

Thus,

$$\int_0^{\infty} dx \frac{\log^2{x}}{(1+x)^2} = \frac{\pi^2}{3}$$

• Thanks! I remembered vaguely that this "adding power" technique should work in case of a log, but it's nice to see exactly how. I'll up-vote once I get 15 points. – some1 Dec 27 '15 at 6:47
• @some1: No problem. Please note here how I did not need to evaluate the lower-order integrals directly, but rather expressed them in terms of their residues. The result is a nice, nontrivial expression of the integral of a function times log squared in terms of the residue of the function times a cubic polynomial in log. This works in general and not just for your integral here. – Ron Gordon Dec 27 '15 at 6:52
• yeah, I know. By the way, what if we consider an equivalent integral (up to changing the variables): $\int_{-\infty}^{+\infty} \frac{dx x^2 e^x}{(1+e^x)^2}$, so that now we have an infinite number of singularities along the imaginary axis. The usual rectangular contour doesn't work here (you get the identity $4\pi^2 = 4\pi^2$). Is there any reasonable contour we can choose to calculate this integral without changing variables? – some1 Dec 27 '15 at 7:00
• @some1: for a rectangular contour I would use a similar trick: consider the contour integral of $z^3$ rather than $z^2$. – Ron Gordon Dec 27 '15 at 7:01
• OK, so "adding power" technique works here too. Great, thanks! – some1 Dec 27 '15 at 7:02

We have $$\int_1^{\infty} \dfrac{\log^2(x)}{(1+x)^2}dx = \int_1^0 \dfrac{\log^2(1/x)}{(1+1/x)^2} \left(-\dfrac{dx}{x^2}\right) = \int_0^1 \dfrac{\log^2(x)}{(1+x)^2}dx$$ Hence, our integral becomes \begin{align} I & = \int_0^{\infty}\dfrac{\log^2(x)}{(1+x)^2}dx = 2\int_0^1\dfrac{\log^2(x)}{(1+x)^2}dx = 2\int_0^1 \sum_{k=0}^{\infty}(-1)^k (k+1)x^k \log^2(x)dx\\ & = 2\sum_{k=0}^{\infty}(-1)^k(k+1) \int_0^1 x^k\log^2(x)dx = 2\sum_{k=0}^{\infty}(-1)^k(k+1) \cdot \dfrac2{(k+1)^3}\\ & = 4 \sum_{k=0}^{\infty} \dfrac{(-1)^k}{(k+1)^2} = 4\left(\dfrac1{1^2} - \dfrac1{2^2} + \dfrac1{3^2} - \dfrac1{4^2} \pm \cdots\right) = \dfrac{\pi^2}3 \end{align}

• I'm aware of this derivation, but I'd like to use complex analysis. – some1 Dec 27 '15 at 6:08

My suggestion would be, if you are to use complex analysis, you have to worry about the definition of functions. Function f is not defined in -1, so it does not have a pole at that point. First of all, you must "throw" the $x<0,y=0$ to somewhere, say to include a change of variable $x \to ix$ and then the singularity will not be what you have stated and your problem will vanish.

• Well, it is defined at $z=-1$, isn't it? $\text{Log}(-1) = \log|-1| + i \pi$. I was sloppy with my notation, I've changed my original post, so $f(z)$ is now defined in terms of the principal $\text{Log}$, which exists at $z=-1$. – some1 Dec 27 '15 at 6:16
• even if you define it that way, you have to map like I have described, everyone does it in that way. Your problem will vanish, it will not even be in a region you are interested in(-1 will go to -i, and there you have no interest, and no trouble) – nikola Dec 27 '15 at 6:22
• No, I don't have to. See the answer by Ron Gordon above. – some1 Dec 27 '15 at 6:29