I am trying to teach myself the residue theorem, and one of the problems I am looking at is $$\int_0^\infty \frac{(\ln{x})^2}{1+x^2}dx$$
With a branch point at $0$, and a branch cut extending down the negative imaginary axis, this leads to a contour integral (containing a poles at $\pm i$), looking like an upside down U. In turn, this contour integral can be broken up into four smaller integrals. The bottom two integrals (running along the real axis) are used to "solve" the problem by setting them equal to the residue (times appropriate prefactor). However, the integrals on the inside and outside curved portions of the "U" can be eliminated, as they are equal to $0$.
I do not know how to calculate the integral of these two curves, and as such cannot see why they are $0$. The solutions I am looking at simply state "via the l'Hospital's rule" without any calculations shown. Disregarding the backstory, below is the integral I am trying to solve, which is the inside of the U shape.
$\lim \limits_{r \to 0}\int_\pi^0 \frac{(\ln{z})^2}{1+z^2} d\theta$, where $z$ is the complex number represented by $z = re^{i\theta}$
Let $f(z) = (\log z)^2/(1 + z^2)$ and $0 < \epsilon < 1 < R$. Suppose the upper and lower circular arcs of the contour have radii $R$ and $\epsilon$, respectively. Since $f(z)$ is analytic inside and on the contour, except at the simple pole at $z = i$, by the residue theorem, the integral of $f(z)$ along the entire contour is $$2\pi i\operatorname{Res}_{z = i} f(z) = 2\pi i\frac{(\log i)^2}{2i} = \pi\left(\frac{\pi}{2}i\right)^2 = -\frac{\pi^3}{4}.$$ On the upper arc, $\lvert (\log z)^2\rvert \le \ln^2 R + \pi^2$ and $\lvert 1 + z^2\rvert \ge R^2-1$. Since the length of the arc is $\pi R$, by the ML inequality the integral of $f(z)$ along this arc is bounded by $$\left(\frac{\ln^2 R + \pi^2}{R^2 - 1}\right)\pi R,$$ which tends to $0$ are $R \to \infty$. Similarly, the integral of $f(z)$ along the lower arc is bounded by $$\left(\frac{\ln^2 \epsilon + \pi^2}{1 - \epsilon^2}\right)\pi \epsilon,$$ which tends to $0$ as $\epsilon \to 0$. Therefore, $$\lim_{\epsilon\to 0,\, R\to \infty} \left(\int_{-R}^{-\epsilon} f(z)\, dz + \int_\epsilon^R f(z)\, dz\right) = -\frac{\pi^3}{4}.\tag{*}$$ For all $z$ in the segment $[-R,-\epsilon]$, $\log z = \ln(-z) + \pi i$; using the parametrization $z = -x$, $\epsilon \le x \le R$, we find $$\int_{-R}^{-\epsilon} f(z)\, dz = \int_{\epsilon}^R \frac{(\ln x + \pi i)^2}{1 + x^2}\, dx = \int_\epsilon^R \frac{(\ln x)^2-\pi^2}{1 + x^2}\, dx + 2\pi i \int_\epsilon^R \frac{\ln x\, dx}{1 + x^2}\, dx.$$ Thus $$\int_{-R}^{-\epsilon} f(z) \, dz + \int_\epsilon^R f(z)\, dz = 2\int_\epsilon^R \frac{(\ln x)^2}{1 + x^2}\, dx - \int_\epsilon^R \frac{\pi^2}{1 + x^2}\, dx + 2\pi i\int_\epsilon^R \frac{\ln x}{1 + x^2}\, dx.$$ By statement (*) we must have $$2\int_0^\infty \frac{(\ln x)^2}{1 + x^2}\, dx - \int_0^\infty \frac{\pi^2}{1 + x^2}\, dx = -\frac{\pi^3}{4},$$ and so $$\int_0^\infty \frac{(\ln x)^2}{1 + x^2}\, dx = \frac{\pi^2}{2}\int_0^\infty \frac{dx}{1 + x^2} - \frac{\pi^3}{8} = \frac{\pi^3}{4} -\frac{\pi^3}{8} = \frac{\pi^3}{8}.$$