How to evaluate $PV \int_0^\infty\frac{\cos(\ln x)}{x^2+1}\,dx$? 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!
 A: According to your text book we consider $f(z)=\dfrac{e^{i\log z}}{z^2+1}.$
Integrating $f(z)$ around a contour in Figure 7.3, we have 
\begin{align}
\left(\int_{-R}^{-\varepsilon }+\int_{C_\varepsilon }+\int_{\varepsilon }^R +\int_{C_R}\right)f(z)dz=2\pi i\operatorname{Res}(f; i),
\end{align}
since $f(z)$ has a simple pole at $z=i$.
It is easy to see that 
$$
\operatorname{Res}(f; i)=\frac{    e^{-\frac{\pi}{2}}       }        {2i}           .
$$
Since $$
\int_{-R}^{-\varepsilon }\dfrac{e^{i\log z}}{z^2+1}dz=-\int_{R}^{\varepsilon }\dfrac{e^{i(\log x+\pi i)}}{x^2+1}dx=e^{-\pi}\int_{\varepsilon }^R\dfrac{e^{i\log x}}{x^2+1}dx,
$$ 
we have 
$$
\left(\int_{-R}^{-\varepsilon }+\int_{\varepsilon }^R\right)f(z)dz=\left(1+e^{-\pi}\right)\int_{\varepsilon }^R\dfrac{e^{i\log x}}{x^2+1}dx.$$
Therefore if we could show that$$
\lim_{\varepsilon \to 0} \int_{C_\varepsilon } f(z)dz=0\quad\text{and}\quad\lim_{R\to \infty}\int_{C_R}f(z)dz=0,
$$ 
we have $$
\left(1+e^{-\pi}\right)\int_0^\infty\dfrac{e^{i\log x}}{x^2+1}dx=\pi e^{-\frac{\pi}{2}}.$$
Taking real parts of both sides we have $$
\int_0^\infty\dfrac{\cos(\log x)}{x^2+1}dx=
\frac{\pi}{e^{\frac{\pi}{2}}+e^{-\frac{\pi}{2}}}.$$
A: 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.
A: HINT :
The poles of $\frac{\cos(\ln z)}{z^2+1}$ are $z=i$ and $z=-i$
$$\text{Res}_{z=i}=-\frac{i}{2}\cosh\left(\frac{\pi}{2}\right)$$
$$\text{Res}_{z=-i}=\frac{i}{2}\cosh\left(\frac{\pi}{2}\right)$$
I suppose that you can take it from here.
