TITLE: Evaluating $\int\limits_0^\infty \frac{\log x} {(1+x^2)^2} dx$ with residue theory
QUESTION [10 upvotes]: I need a little help with this question, please! 
I have to evaluate the real convergent improper integrals using RESIDUE THEORY (vital that I use this), using the following contour:
$$\int\limits_0^\infty \frac{\log x} {(1+x^2)^2} dx$$  
Using this contour: 

$R>1$ and $r<1$

REPLY [4 votes]: Calling $\sigma$ the contour you drew, i.e. a big arc of radius $R$, a small arc of radius $r$ connected by two segments, let the angle subtended by the arcs approach $2\pi$ from below, so that the two segments are just above and below the positive real axis. Choosing the branch cut of the logarithm on the positive real axis, by the residue theorem we have
$$
\oint_\sigma \frac{\ln^2 z}{(1+z^2)^2}dz=i2\pi \left(\text{Res}\frac{\ln^2z}{(1+z^2)^2}\Big|_{z=e^{i\pi/2}}+\text{Res}\frac{\ln^2z}{(1+z^2)^2}\Big|_{z=e^{i3\pi/2}}\right);
$$
note that we wrote $i={e^{i\pi/2}}$ and $-i=e^{i3\pi/2}$ according to the chosen branch cut.
Using the formula for the second order pole residue:
$$
f(z) = \frac{\ln^2z}{(1+z^2)^2}=\frac{\ln^2z}{(z+i)^2(z-i)^2}
$$
$$
\frac{d}{dz}\left[f(z)(z-i)^2\right]=2\ln z\frac{(z+i)-z\ln z}{z(z+i)^3}=\Big|_{z=e^{i\pi/2}}i\frac{\pi}{8}\left(\frac{\pi}{2}+2i\right)
$$
$$
\frac{d}{dz}\left[f(z)(z+i)^2\right]=2\ln z\frac{(z-i)-z\ln z}{z(z-i)^3}
=\Big|_{z=e^{i3\pi/2}}-i\frac{3\pi}{8}\left(\frac{3\pi}{2}+2i\right)
$$
so that
$$
\oint_\sigma \frac{\ln^2 z}{(1+z^2)^2}dz=i2\pi\left[
i\frac{\pi}{8}\left(\frac{\pi}{2}+2i\right)
-i\frac{3\pi}{8}\left(\frac{3\pi}{2}+2i\right)
\right]=\pi^3+i\pi^2.
$$
Now, the integral on the big circle vanishes as $R\to\infty$, since the integrand falls off as $\ln^2 R/(1/R^2)^2$, and the integral on the small circle vanishes as $r\to0$ since the $r$ coming from the line element cancels the $\ln^2r$ singularity: explicitly
$$
\left|\int_\Gamma \frac{\ln^2z}{(1+z^2)^2}dz\right|\le\int_{0}^{2\pi}\frac{|\ln R + i\varphi|^2}{|1+R^2|^2}Rd\varphi\le\text{const}\times R^{-3}\xrightarrow[R\to\infty]{}0,
$$
$$
\int_\gamma \frac{\ln^2z}{(1+z^2)^2}dz=
\int_{0}^{2\pi}\frac{(\ln r + i\varphi)^2}{(1+re^{i2\pi})^2}ie^{i\varphi}rd\varphi\xrightarrow[r\to0]{}0.
$$
Therefore, in such limits,
$$
\pi^3+i\pi^2 = 
\int_0^{+\infty}\frac{\ln^2x}{(1+x^2)^2}dx-\int_{0}^{+\infty}\frac{(\ln x+i2\pi)^2}{(1+x^2)^2}dx \\=
-i4\pi\int_{0}^{+\infty}\frac{\ln x}{(1+x^2)^2}dx+4\pi^2\int_{0}^{+\infty}\frac{1}{(1+x^2)^2}dx.
$$
Comparing real and imaginary parts
\begin{align}
\int_{0}^{+\infty}\frac{dx}{(1+x^2)^2} &= \frac{\pi}{4}\qquad (\star)\\
\int_{0}^{+\infty}\frac{\ln x}{(1+x^2)^2}dx&=-\frac{\pi}{4}.\qquad (\star)
\end{align}
Willing to use only the pole in the upper-half plane, one can proceed as follows: let the angle in the contour you drew approach $\pi$, which gives us
$$
\int_{0}^{+\infty}\frac{\ln x}{(1+x^2)^2}dx - 
\int_{0}^{+\infty}\frac{\ln x +i\pi}{(1+x^2)^2}e^{i\pi}dx=i2\pi \left[i\frac{\pi}{8}\left(\frac{\pi}{2}+2i\right)\right]
$$
or
$$
2\int_{0}^{+\infty}\frac{\ln x}{(1+x^2)^2}dx+i\pi \int_0^{+\infty}\frac{1}{(1+x^2)^2}dx=-\frac{\pi}{2}+i\frac{\pi^2}{4};
$$
again, confrontation leads to $(\star)$.
One can avoid computing the annoying double poles and reduce the argument to simple poles at the price of computing a derivative:
$$
\int_0^{+\infty}\frac{\ln x}{(1+x^2)^2}dx=-\frac{1}{2}\frac{d}{da}\left(\int_0^{+\infty}\frac{\ln x}{a^2+x^2}dx\right)_{a=1};
$$
now, in the same spirit as above, for an indented half-circle contour in the upper-half plane
$$
\int_0^{+\infty}\frac{\ln x}{a^2+x^2}dx-\int_0^{+\infty}\frac{\ln x+i\pi}{a^2+x^2}e^{i\pi}dx=\frac{\pi}{a}\ln a+i\frac{\pi^2}{2a}
$$
hence, real and imaginary parts give:
$$
\int_0^{+\infty}\frac{\ln x}{x^2+a^2}dx=\frac{\pi}{2a}\ln a\\
\int_0^{+\infty}\frac{dx}{a^2+x^2}=\frac{\pi}{2a}.
$$
Performing the above derivative calculated at $a=1$, one recovers the desired results $(\star)$.