# Using a contour integral to evaluate $\int^\infty_0 \frac{(\log(x))^2}{x^2+1}\,dx$

Say we want to evaluate $\int^\infty_0 \frac{(\log(x))^2}{x^2+1}\,dx$ via integrating over a complex contour.

My lecturer said to use the function $f(z) = \frac{(\log(z) - \frac{i \pi}{2})^2}{z^2+1}\$ with the branch cut along the negative imaginary axis over the following contour:

I understand the contour choice: we include the $i$ pole to take the residue of, and we avoid the branch cut. However, I don't understand the intuition behind why they've change the function from $\log(z)$ to $\log(z) - \frac{i \pi}{2}$. Why is that of benefit to us?

Note that with the branch cut along the negative real axis, we see that along the positive real axis

$$(\log(z)-i\pi/2)^2=\log^2(|x|)-i\pi\log(|x|)-\pi^2/4$$

while along the negative real axis

$$(\log(z)-i\pi/2)^2=\log^2(|x|)+i\pi\log(|x|)-\pi^2/4$$

It is easy to show that $\int_{-\infty}^0 \frac{\log^2(|x|)}{1+x^2}\,dx=\int_0^{\infty} \frac{\log^2(|x|)}{1+x^2}\,dx$.

Hence, $\int_{-\infty}^\infty \frac{(\log(x)-i\pi/2)^2}{x^2+1}\,dx=2\int_0^\infty \frac{\log^2(x)}{x^2+1}\,dx-\frac12 \pi^2\int_0^\infty \frac{1}{x^2+1}\,dx$. So, the cross term involving $\log(x)$ is no involved.

Note that had we analyzed $\oint_C \frac{\log^2(z)}{z^2+1}\,dz$, we need to evaluate the integral $\int_0^\infty \frac{\log^2(x)}{x^2+1}\,dx$. However, upon enforcing the substitution $x\to 1/x$, we would readily find that this integral is $0$.

Therefore, we have

\begin{align} \oint_C \frac{(\log(z)-i\pi/2)^2}{z^2+1}\,dz&=2\int_\epsilon^R \frac{\log^2(x)}{x^2+1}\,dx-\frac12\pi^2\underbrace{\int_\epsilon^R \frac{1}{x^2+1}\,dx}_{\to -\pi^3/4\,\text{as}\,\epsilon\to 0\,\text{and}\,R\to\infty}\\\\ &+\underbrace{\int_\pi^0 \frac{\log^2(\epsilon e^{i\phi})}{(\epsilon e^{i\phi})^2+1}\,i\epsilon e^{i\phi}\,d\phi}_{\to 0\,\text{as}\,\epsilon\to 0}+\underbrace{\int_0^\pi \frac{\log^2(R e^{i\phi})}{(R e^{i\phi})^2+1}\,i R e^{i\phi}\,d\phi}_{\to 0\,\text{as}\,R\to \infty}\\\\ &=2\pi i \text{Res}\left(\frac{(\log(z)-i\pi/2)^2}{z^2+1}, z=i\right)\\\\ &=0 \end{align}

Note that had we analyzed the integral $\oint_C \frac{\log^2(z)}{z^2+1}\,dz$, the reside would not be zero. However, this poses no significant challenge or complication.

Therefore, as $\epsilon\to 0$ and $R\to \infty$ we see that

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

Although analysis of the integral $\oint_C \frac{(\log(z)-i\pi/2)^2}{z^2+1}\,dz$ facilitates analysis in that we forgo the need to evaluate the integral $\int_0^\infty \frac{\log^2(x)}{x^2+1}\,dx=0$, this does not seem to add any significant benefit of efficiency over analysis of the integral $\oint_C \frac{\log^2(z)}{z^2+1}\,dz$.

• Thanks so much for your response. So, there is no particular reason why my lecturer chose this integrand, and I could have just as validly chosen $\oint_C \frac{\log^2(z)}{z^2+1}\,dz$ instead? – hhattiecc May 20 '17 at 21:05
• You're welcome. My pleasure. Perhaps the instructor wanted to avoid having to evaluate $\int_0^\infty \frac{\log(x)}{x^2+1}\,dx=0$ and also wanted a residue of $0$. – Mark Viola May 20 '17 at 23:03