I want to evaluate following integral:
$\int_{0}^{\infty} \frac {\sin (\ln x) dx }{x^2 + 4} $
Obviously $x$ $ \gt $ $0$ and the function we want to integrate isn't even nor odd. And I need to avoid $0$.
We got two first order poles at $+2i$ and $-2i$
$f(z) = \frac {\sin (\ln z) }{z^2 + 4} = \Im \{\frac {e^{(i\ln z)} }{z^2 + 4} \} $ and we are dealing with a complex logarithm
The residue of the function above for $+2i$ is equal to $res(f, +2i) =\frac {e^{(i Ln 2)}}{4i}$ and I am considering calculating the residue for $-2i$ (it would just switch a sign)
The solution is according to textbook: $\frac {\pi \sin (Ln(2)}{4 \cosh(\pi /2)}$
My questions:
1) How to deal with the integral from $0$ to $\infty$, not from $- \infty$ to $\infty$ in this case. I was used to deal with even functions where it was obvious.
2) I have no clue about the integration path (a semi-circle with branch cuts?)
3) Why that $cosh$ in that solution?
This type of the complex integral is very new to me and I would appreciate any help!

Use the substitution $$x = 2e^t$$ for instance. This gives: $$ \begin{aligned} \int_{0}^{\infty} \frac {\sin \ln x }{x^2 + 4}\; dx &= \int_{-\infty}^{\infty} \frac {\sin (\ln 2 + t) }{4e^{2t} + 4}\; 2e^t\; dt \\ &= \frac 12 \int_{-\infty}^{\infty} \frac {\sin \ln 2\cos t+\cos \ln 2\sin t }{e^{t} + e^{-t}}\; dt \\ &= \frac 12 \int_{-\infty}^{\infty} \frac {\sin \ln 2\cos t +\text{odd function}}{e^{t} + e^{-t}}\; dt \\ &= \frac 12\sin\ln 2 \int_{-\infty}^{\infty} \frac {\cos t}{e^{t} + e^{-t}}\; dt \ . \end{aligned} $$ This is a better situation suited for an application of the residue theorem. The residues of the function $$ f(z)=\frac{\cos z}{e^z + e^{-z}} $$ in the poles $$ k\cdot \frac {i\pi} 2\ ,\qquad\text{ $k$ odd, }k=2n+1\ , $$ are correspondingly $$ -\frac i2(-1)^n\cosh \frac {k\pi}2\ . $$ Now we need to find the "good contour". The known result already tells us that $i\pi/2$ counts, but the "next" residue, $3i\pi/2$ "should not count". OK, let us then consider the rectangular contour with the corners $$ -R\ , \ +R\ , \ +R+i\pi\ , \ -R+i\pi\ . $$ Then for $z\in[-R,R]$ $$ \Re f(z+i\pi) = \Re \frac{\cos (z+i\pi)}{e^{z+i\pi} + e^{-z-i\pi}} = \Re \frac{\cos z\cos(i\pi)-\sin z\sin(i\pi)}{-(e^{z} + e^{-z})} = \Re \frac{\cos z\cosh \pi}{-(e^{z} + e^{-z})} =- \cosh \pi f(z)\ . $$ Applying the residue theorem on the rectangle: $$ \begin{aligned} 2\pi\,i\cdot \left(-\frac{1}{2} i \, \cosh\left(\frac\pi{2}\right)\right) &= \lim_{R\to \infty}\int_{-R}^R f(z)\; dz + \lim_{R\to \infty}\int_{R+i\pi}^{-R+i\pi} f(z)\; dz \\ &= (1+\cosh\pi)\lim_{R\to \infty}\int_{-R}^R f(z)\; dz \\ &= 2\cosh^2\left(\frac \pi2\right)\cdot\int_{-\infty}^\infty f(z)\; dz\ . \end{aligned} $$ It remains to put all together in one line: $$ \int_{0}^{\infty} \frac {\sin \ln x }{x^2 + 4}\; dx = \frac 12\sin\ln2\int_{\Bbb R}f = \frac 12\sin\ln2\cdot \frac \pi{2\cosh(\pi/2)}\ . $$ $\square$