Integrating this natural log using complex analysis

Question: Integrate$$\mathscr{I}=\int\limits_{-\infty}^{\infty}dx\,\frac {\log(1+x^2)}{1+x^2}$$

I tried using a semicircle with radius $$R$$ with a smaller semicircle detour inside So we have that$$\oint\limits_{C}dz\, f(z)=\int\limits_r^Rdx\, f(x)+\int\limits_{\gamma_R}dz\, f(z)+\int\limits_{-R}^{-r}dx\,\frac {\log|1+x^2|+i\arg(1+x^2)}{1+x^2}+\int\limits_{\gamma_r}dz\, f(z)$$where $$f(z)$$ represents the integrand. However, I'm having trouble computing the residue at $$z=i$$ because the limit leads to infinity.

Are branch cuts required? If so, is it possible for you to walk me through it? I'm not very familiar with them...

• The issue is that your integrand is not analytic on the upper half plane. Any branch of the logarithm $\log(1+z^2)$ that is analytic near $\mathbb{R}$ has a branch cut joining $i$ and $\infty$ on the upper half plane. So a semicircular contour must fail. – Sangchul Lee Dec 23 '17 at 18:44
• See here page 188 advancedintegrals.com/advanced-integration-techniques.pdf for a generalized form. – Zaid Alyafeai Dec 24 '17 at 21:57

Yes we require a branch cut, recall that $$\log(z)=\log(|z|)+i\arg(z)$$

In general with these sort of things we want to pick our branch cut so that our contour doesn't go through it, let's pick the branch cut where we insist $\arg(z)\in[-\pi/2,3\pi/2)$, i.e. the branch cut is down the negative imaginary axis, note that for real $x$, $$\log(1+x^2)=\log(1+ix)+\log(1-ix)$$

So let $f(z)=\frac{\log(1-iz)}{1+z^2}$ which is suitably nice on the upper semicircle from $-R$ to $R$ just having the one pole at $i$ with $\text{Res}(f,i)=\frac{\log(2)}{2i}$.

We then have by residue theorem that $$\int_{C_R} f(z) dz +\int_{-R}^{0}f(z) dz+ \int_{0}^{R}f(z) dz = \pi\log(2)$$

Where $C_R$ is the bit of the contour not on the real line, by the usual sort of reasoning the first integral tends to zero as $R$ tends to infinity. While after making the change of variables $z\rightarrow -z$ in the $-R$ to $0$ integral we get $$\int_0^{\infty}\frac{\log(1+iz)+\log(1-iz)}{1+z^2} dz =\int_0^{\infty}\frac{\log(1+z^2)}{1+z^2}dz=\pi\log(2)$$

And since your integrand is even...

• Sorry if this seems like a dumb question, but how did you handle the negative portion of the natural log? Shouldn't there be a little imaginary portion remaining? – Crescendo Dec 23 '17 at 23:02
• @Crescendo Sorry which negative portion? – Countingstuff Dec 24 '17 at 14:48
• When you integrate it along the negative real axis, don't you have to deal with the negative logarithm? – Crescendo Dec 24 '17 at 14:50
• @Crescendo but I make the change of variables $z\rightarrow -z$ to make it an integral on the positive real axis, and then I combine with the other integral. – Countingstuff Dec 24 '17 at 14:51
• Okay, I see. Thanks! – Crescendo Dec 24 '17 at 14:52

It is well known that a good alternative to contour integration is differentiation under the integral sign: it perfectly applies here, so I am going to outline an alternative approach. For any $a>\frac{1}{2}$, by exploiting symmetry and by enforcing the substitution $\frac{1}{1+x^2}=u$, we have $$\int_{-\infty}^{+\infty}\frac{dx}{(1+x^2)^a} = \frac{\sqrt{\pi}\,\Gamma\left(a-\tfrac{1}{2}\right)}{\Gamma(a)}$$ by Euler's Beta function. By differentiating both sides with respect to $a$, and exploiting $\frac{d}{da}\,f=f\cdot\frac{d}{da}\log f$, we get: $$\int_{-\infty}^{+\infty}\frac{-\log(1+x^2)}{(1+x^2)^a}\,dx = \frac{\sqrt{\pi}\,\Gamma\left(a-\tfrac{1}{2}\right)}{\Gamma(a)}\left[\psi\left(a-\tfrac{1}{2}\right)-\psi(a)\right]$$ and by evaluating both sides at $a=1$: $$\int_{-\infty}^{+\infty}\frac{\log(1+x^2)}{(1+x^2)}\,dx = \pi\left[\psi(1)-\psi\left(\tfrac{1}{2}\right)\right]=\color{red}{2\pi\log 2}.$$ The equivalent claim $$\int_{0}^{\pi/2}\log\sin\theta\,d\theta = -\frac{\pi}{2}\log 2$$ can also be proved through $\prod_{k=1}^{n-1}\sin\left(\frac{\pi k}{n}\right)=\frac{2n}{2^n}$ and Riemann sums, or just by symmetry tricks.

• I'm reluctant to accept this answer because it doesn't directly answer my question about how we can use contour integration to evaluate the integral... Perhaps you can include that...? – Crescendo Dec 22 '17 at 2:51


These kind of integrals are tricky. For getting started see $\ln(1+x^2)=\text{Re}(2\Log(i+x))$ where $\Log(\cdot)$ is the principal value of the logarithm. So it is reasonable to consider integrating something with $\Log(i+z)$ instead of something with $\Log(1+z^2)$. Let's integrate the following: \begin{align} \oint_C \frac{\Log(i+z)}{1+z^2}\,dz =\int_{C_R}\frac{\Log(i+z)}{1+z^2}\,dz+ \int^R_{-R}\frac{\Log(i+z)}{1+z^2}\,dz \end{align} where $C$ is a semi circle in the upper half plane; $C_R$ is the circle part and the other one is obvious. The branch cut is on $z=-i-\lambda$ with $\lambda\in (0,\infty)$, so we are (luckily) far away from the branch cut. The only residue inclosed is $z=i$ and therefore the equality: \begin{align} \int_{C_R}\frac{\Log(i+z)}{1+z^2}\,dz+ \int^R_{-R}\frac{\Log(i+z)}{1+z^2}\,dz=2\pi i \text{Res}_{z=i} \frac{\Log(i+z)}{1+z^2} \end{align} by The Residue Theorem. The integral on $C_R$ will have no contribution when $R\to\infty$. Now lets have a look at the real part of the one on $[-R,R]$: \begin{align} \Re\left(\int^R_{-R}\frac{\Log(i+z)}{1+z^2}\,dz\right) &= \frac{1}{2}\int^R_{-R} \frac{\ln(1+x^2)}{1+x^2}\,dx \end{align} That is what we have observed in the beginning. Let $R\to \infty$ and we get: \begin{align}\tag{1} \frac{1}{2}\int^\infty_{-\infty} \frac{\ln(1+x^2)}{1+x^2}\,dx = \Re\left(2\pi i \text{Res}_{z=i} \frac{\Log(i+z)}{1+z^2}\right) \end{align} Doing the residue times $2\pi i$: \begin{align} 2\pi i\text{Res}_{z=i} \frac{\Log(i+z)}{1+z^2} = 2\pi i\frac{\Log(2i)}{2i}= 2\pi i\frac{\ln(2)+i\frac{\pi}{2}}{2i}=\pi\ln(2)+\frac{i\pi^2}{2} \end{align} The real parts in both sides of $(1)$ must be equal and mulitply both sides with $2$ and get the final result:

\begin{align} \int^\infty_{-\infty}\frac{\ln(1+x^2)}{1+x^2}\,dx = 2\pi\ln(2) \end{align}

The function $ln(1+x^2)$ has two branch points at $\pm i$, then we cannot choose the contour you propose, as noted in the comment by @Sangchul Lee. Also, the point $x=0$ is not special for the function, the contribution of $\gamma_r$ is useless too. Instead, we can consider a branch cut on the vertical segment between $i$ and $-i$. It is convenient to decompose $$f(x)=\frac{1}{2}\frac{\ln(1+x^2)}{1-ix}+\frac{1}{2}\frac{\ln(1+x^2)}{1+ix}$$ By enforcing the substitution $y=-x$ in the second integral, one has \begin{align} I&=\frac{1}{2}\int_{-\infty}^\infty\frac{\ln(1+x^2)}{1-ix}\,dx+\frac{1}{2}\int_{-\infty}^\infty\frac{\ln(1+x^2)}{1+ix}\,dx\\ &=\int_{-\infty}^\infty\frac{\ln(1+x^2)}{1-ix}\,dx \end{align}

We define a contour along the real axis which avoids the branch cut by turning around $x=i$ and which is closed by the large upper semi-circle $C_R$. From the residue theorem, it holds $$0=\left[\int_{C_R}+\int_{-\infty}^{-\varepsilon}+J+\int_{\varepsilon}^{\infty}\right] f^-(x)\,dx$$ where $f^-(x)=\left( 1-ix \right)^{-1}\ln\left( 1+x^2 \right)$ and $J$ is the contribution of the path which turns around the branch cut. It can be shown that the large semi-circle contribution vanishes as $R\to\infty$, then $$I=\int_{-\infty}^\infty f^-(x)\,dx=-J$$ and

$$J=\left[\int_{-\varepsilon}^{i-\varepsilon} +\int_{\gamma_i} +\int^{\varepsilon}_{i+\varepsilon} \right] f^-(x)\,dx$$ $\int_{\gamma_i}$ is the contribution of a small semi-circle around $x=i$, it can be shown to vanish when $\varepsilon\to 0$. On the left and right sides of the vertical contribution, with $x=-\varepsilon+ iy$, and passing to the limit $\varepsilon\to 0$ \begin{align} \int_{-\varepsilon}^{i-\varepsilon}f^-(x)\,dx&=i\int_0^1\frac{\ln(1-y^2)+2i\pi}{1+y}\,dy\\ \int^{\varepsilon}_{i+\varepsilon}f^-(x)\,dx&=i\int_1^0\frac{\ln(1-y^2)}{1+y}\,dy \end{align} Adding both terms, the logarithmic contributions cancel each other and we obtain $$J=-2\pi\ln2$$ Finally, $$I=2\pi\ln2$$ In this method, like in the other given answers, a decomposition is used in order to separate the poles and the branch points near the contour.