# Improper integral with log and absolute value

How do you show that $$\int^{\infty}_{0} \frac{\log |\tan x|}{1+x^{2}} \ dx = \frac{\pi}{2} \log (\tanh 1)\, ?$$

The integral converges since $\log |\tan x| = \frac{1}{2} \log(\tan^{2}x)$, and $\log (\tan^{2} x)$ behaves like $2 (-1)^{n} \log \left(x-\frac{n \pi}{2} \right)$ near $x= \frac{n \pi}{2}$. Thus the singularities at $x= \frac{n \pi}{2}$ are integrable.

-

## 2 Answers

How about: $$\int_0^\infty \frac{\log | \tan x |}{1+x^2} \mathrm{d} x = \frac{1}{2} \int_0^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x = \frac{1}{4} \int_{-\infty}^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x \tag{\ast}$$ Writing the integral over $\mathbb{R}$ as the average of integrals over $\mathbb{R} + i \epsilon$ and $\mathbb{R} - i \epsilon$ and using $\vert \tan(z) \vert^2 = \frac{\sin^2(2 x) + \sinh^2(2y)}{(\cos(2x) + \cosh(2y))^2} \to_{y \to \pm \infty} 1$ we can complete the integration contours and apply the residue theorem: $$\begin{eqnarray} \int_{-\infty}^\infty \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x &=& \frac{1}{2} \int_{-\infty +i 0}^{\infty +i 0} \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x + \frac{1}{2} \int_{-\infty-i 0}^{\infty - i 0} \frac{\log \tan^2 x }{1+x^2} \mathrm{d} x \\ &=& \frac{1}{2} \cdot 2 \pi i \operatorname{Res}_{x=i}\frac{\log \tan^2 x }{1+x^2} - \frac{1}{2} \cdot 2 \pi i \operatorname{Res}_{x=-i}\frac{\log \tan^2 x }{1+x^2} \\ &=& 2 \pi \log \tanh(1) \end{eqnarray}$$ Combining with eq. $(\ast)$: $$\int_0^\infty \frac{\log | \tan x |}{1+x^2} \mathrm{d} x = \frac{\pi}{2} \log \tanh(1)$$

-
Just nice! (+1) – user 1618033 Jan 24 '13 at 19:10
I don't understand how we're closing the contour. – Random Variable Jan 24 '13 at 19:17
@RandomVariable The integral just above the real line is closed by couter-clock-wise arc from $+\infty$ to $i \infty$ to $-\infty$, and the integral just below the real line is closed by a clock-wise arc from $+\infty$ to $-i \infty$ to $-\infty$. – Sasha Jan 24 '13 at 19:28
So what you're finding is the principal value of an integral that goes through infinitely-many isolated singular points by averaging the values of the integrals just above and just below the singularities? And that fact about $\vert \tan(z) \vert^2$ is why we can close the contours in the upper half and lower half planes? Did we need to define a branch cut because we're dealing with log? – Random Variable Jan 24 '13 at 20:02
@RandomVariable Yes to the first two questions. The branch cut of the $\log$ is chosen along the negative real semi-axis. The only subtle point is to show that $\tan^2(z)$ does not cross $\log$'s branch cuts along the contour. – Sasha Jan 24 '13 at 20:45

Denote the evaluated integral as $I$, then $I$ may be rewritten as $$I=\frac{1}{2}\int_0^\infty \frac{\ln \sin^2 x}{1+x^2}\,dx-\frac{1}{2}\int_0^\infty \frac{\ln \cos^2 x}{1+x^2}\,dx$$ Using Fourier series representations of $\ln \sin^2 \theta$ and $\ln \cos^2 \theta$, $$\ln \sin^2 \theta=-2\ln2-2\sum_{k=1}^\infty \frac{\cos2k\theta}{k}$$ and $$\ln \cos^2 \theta=-2\ln2+2\sum_{k=1}^\infty (-1)^{k+1}\frac{\cos2k\theta}{k}$$ also note that $$\int_0^\infty\frac{\cos ax}{1+x^2}\,dx=\frac{\pi e^{-a}}{2}$$ then \begin{align}I&=-\sum_{k=1}^\infty \frac{1}{k}\int_0^\infty\frac{\cos2kx}{1+x^2}\,dx-\sum_{k=1}^\infty \frac{(-1)^{k+1}}{k}\int_0^\infty\frac{\cos2kx}{1+x^2}\,dx\\&=-\pi\sum_{k=1}^\infty \frac{e^{-2k}}{2k}-\pi\sum_{k=1}^\infty (-1)^{k+1}\frac{e^{-2k}}{2k}\\&=\frac{\pi}{2}\ln\left(1-e^{-2}\right)-\frac{\pi}{2}\ln\left(1+e^{-2}\right)\\&=\frac{\pi}{2}\ln\left(\frac{1-e^{-2}}{1+e^{-2}}\right)\\&=\frac{\pi}{2}\ln\left(\tanh 1\right)\end{align}

-