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?
 A: 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}
A: 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} $$

