TITLE: How to evaluate $PV \int_0^\infty\frac{\cos(\ln x)}{x^2+1}\,dx$?
QUESTION [5 upvotes]: I'm trying to show $$PV \int_0^\infty\frac{\cos(\ln x)}{x^2+1}\,dx=\frac{\pi}{2\cosh(\pi/2)}.$$
My textbook says to do this by "integrating $e^{i\ln z}/(z^2-1)$ around a contour like Figure 7.3 but rotated 90◦ clock- wise so the straight side is along the y axis."
I took the original integral and reformulated it like this:
$$I=\int_0^\infty\frac{\cos(\ln x)}{x^2+1}\,dx=\frac{1}{2}\text{ Re}\left[\int_{-\infty}^\infty\frac{e^{i\ln x}}{x^2+1}\,dx\right]$$
Next I set up the contour integral $$\oint_C\frac{e^{i\ln z}}{(z^2-1)}\,dz=2\pi i\sum Res$$
With $\sum Res = Res[z=1]$.
I then managed to show that the semicircular paths around the contour go to zero as $R$ and $\epsilon$ go to infinity and zero respectively. This implies the contour integral is equal to the principal value of $f(z)$ evaluated from $-\infty$ to $\infty$.
But my problem is that $\frac{1}{2}$ of the real part of the sum of the residues does not equal $\frac{\pi}{2\cosh(\pi/2)}$.
Any pointers would be very much appreciated, I've been working on this for quite a while now!

REPLY [3 votes]: An alternative solution. We do not really need the $\text{PV}$ before the integral, since $\cos$ is a bounded function, hence $\frac{\cos\log x}{x^2+1}=\text{Re}\frac{x^i}{x^2+1}$ is integrable over $\mathbb{R}^+$. By setting $x=e^t$ we get:
$$ I=\int_{0}^{+\infty}\frac{\cos\log x}{x^2+1}\,dx = \int_{-\infty}^{+\infty}\frac{\cos t}{2\cosh(t)}\,dt$$
and the last integral is easily solvable through the Fourier transform, leading to:
$$ I = \frac{\pi}{2}\int_{-\infty}^{+\infty}\frac{\delta(s-1)+\delta(s+1)}{2\cosh\left(\frac{\pi s}{2}\right)}\,ds=\color{red}{\frac{\pi}{2\cosh\frac{\pi}{2}}}$$
as wanted.