<s>[INST] Improper integral with log and absolute value: $\int^{\infty}_{0} \frac{\log |\tan x|}{1+x^{2}} \, dx$ How do you show that $$ \int^{\infty}_{0} \frac{\log |\tan x|}{1+x^{2}} \, dx = \frac{\pi}{2} \log (\tanh 1)\, ?$$
I know that 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.
 [/INST] 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}$$
</s>