Computing integral using complex analysis methods I'm trying to compute the integral
$$
\int_0^{\infty} \frac{\ln(x)}{x^2 + 1} \, dx
$$
using complex analysis methods. We haven't learned residue calculus yet though, only contour integrals up through the Cauchy integral formula.
I'm trying to make use of a half circle centered at the origin of radius $R$ and then let $R$ tend to infinity, but there is a definite singularity for the $\ln(x)$ function. Does anybody have a suggestion?
 A: It is not necessary to use complex analysis methods to solve this problem. You only need $x\to\frac{1}{x}$. In fact, letting $u=\frac{1}{x}$ gives
$$ \int_1^\infty\frac{\ln x}{1+x^2}dx=\int_1^0\frac{\ln \frac{1}{u}}{1+\frac{1}{u^2}}(-\frac{du}{u^2})=-\int_0^1\frac{\ln u}{1+u^2}du. $$
So
$$ \int_0^\infty\frac{\ln x}{1+x^2}dx=\int_0^1\frac{\ln x}{1+x^2}dx+\int_1^\infty\frac{\ln x}{1+x^2}dx=\int_0^1\frac{\ln x}{1+x^2}dx-\int_0^1\frac{\ln u}{1+u^2}du=0. $$
A: One way to do this would be to consider the integral 
$$ \int_C \frac{(\log z)^2}{1+z^2}dz $$ where $C$ is the keyhole contour. By standard estimates, the integral on the outer ($R$) and inner ($r$) circular parts of the contour would be zero when we consider limiting values of $R$ and $r$. For the horizontal segment above the real axis you will get $\frac{(\log z)^2}{1+z^2} = \frac{(\log|x|)^2}{1+x^2}$. For the horizontal segment below the real axis you will have 
$$ \frac{(\log z)^2}{1+z^2} = \frac{(\log|x|+2\pi i)^2}{1+x^2}= \frac{(\log|x|)^2 -4\pi^2 + 4\pi i log|x|}{1+x^2} $$
where we use the $0 < \arg z < 2\pi $ branch. 
Since the integration limits will be inverted for the two horizontal segments, hence you will be left with the desired integral, residue of $\frac{(\log z)^2}{1+z^2}$ at $z = \pm i$ and a standard integral: $\int_0^{\infty} \frac{dx}{1+x^2}$. 
