Calculating ${\int_{-\infty}^{\infty} \frac{\cos(\omega x)}{x^{2} + 25}\,{\rm d}x}$ using contour integration I want to calculate
$\displaystyle{
\int_{-\infty}^{\infty}\frac{\cos\left(\omega x\right)}{x^{2} + 25}\,{\rm d}x\,,
\quad}$ for $\omega \in \mathbb{R}$
I thought of integrating along the line segment $\left[-R, R\right]$ and the semicircle $C = \left\{z: \left\vert z\right\vert = R, \; \Im z\geq 0\right\}$. In my book this is said to be a wrong method, but I don't understand why ( I even get the same result ). 
Can someone explain me why this is wrong, and how it should be done instead?
 A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\pars}[1]{\left( #1 \right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}
 \newcommand{\yy}{\Longleftrightarrow}$
In this question the integral is solved by a few methods. One of them is by user17762 who set a differential equation for $\ds{{\rm I}\pars{\omega} \equiv \int_{-\infty}^{\infty}{\cos\pars{\omega x} \over x^{2} + 1}\,\dd x}$. Namely,
${\rm I}''\pars{\omega} - 25\,{\rm I}\pars{\omega} = -2\pi\,\delta\pars{\omega}$.
The equation in the above mentioned question is slightly different due to a different parameters but both cases are similar after a suitable scaling. The above mentioned user solves the equation without the $-2\delta\pars{\omega}$ term and later use some arguments to arrive to the correct solution. One comment ( by Ron Gordon ) pointed out the existence of the Dirac delta term in the right hand side which indicates that ${\rm I}\pars{\omega}$ is a Green function. Here we'll solve the above mentioned differential equation by taking explicitly into account the Dirac delta term.

The solutions of ${\rm I}''\pars{\omega} - {\rm I}\pars{\omega} = 0$ are lineal combination of $\expo{-5\omega}$ and $\expo{5\omega}$. The solution is written as
$$
{\rm I}\pars{\omega}
=
\Theta\pars{-5\omega}\pars{A\expo{-5\omega} + B\expo{5\omega}}
+
\Theta\pars{\omega}\pars{C\expo{-5\omega} + D\expo{5\omega}}
$$
where $A, B, C$ and $D$ are constants ( independent de $\omega$ ). The solution is an even function of $\omega$ which requires $A = D$ and $B = C$. That condition reduces ${\rm I}\pars{\omega}$ to:
\begin{align}
{\rm I}\pars{\omega}
&=
\Theta\pars{-\omega}\pars{A\expo{5\verts{\omega}} + B\expo{-5\verts{\omega}}}
+
\Theta\pars{\omega}\pars{B\expo{-5\verts{\omega}} + A\expo{5\verts{\omega}}}
=
A\expo{5\verts{\omega}} + B\expo{-5\verts{\omega}}
\end{align}
The boundary condition ${\rm I}\pars{0} = \pi/5$ leads to $A + B = \pi/5$. Then,
$$
{\rm I}\pars{\omega} = 2A\sinh\pars{5\verts{\omega}}
+
{1 \over 5}\,\pi\expo{-5\verts{\omega}}
\quad\mbox{and}\quad
{\rm I}'\pars{\omega}
=
5\bracks{2A\cosh\pars{5\verts{\omega}}
-
{1 \over 5}\,\pi\expo{-5\verts{\omega}}}\sgn\pars{\omega}
$$
The differential equation leads to the condition
$$
\lim_{\epsilon \to 0^{+}}
\int_{-\epsilon}^{\epsilon}{\rm I}''\pars{\omega}\,\dd\omega = -2\pi
\quad\imp\quad
\lim_{\epsilon \to 0^{+}}
\bracks{{\rm I}'\pars{\epsilon} - {\rm I}'\pars{-\epsilon}} = -2\pi
$$
$$
-2\pi = 5\pars{2A - {\pi \over 5}} - 5\pars{-2A + {\pi \over 5}}
=
20A - 2\,\pi\
\imp\
A = 0\
\imp\
{\rm I}\pars{\omega} = {1 \over5}\,\pi\expo{-5\verts{\omega}}
$$

Then
$${\large
\int_{-\infty}^{\infty}{\cos\pars{\omega x} \over x^{2} + 25}\,\dd x
=
{1 \over5}\,\pi\expo{-5\verts{\omega}}}
$$ 
A: The problem lies with the fact that the cosine blows up along a semicircle in the upper or lower half plane.  To do this correctly, you can break the cosine into complex exponentials, each of which satisfies Jordan's lemma on one or the other semicircular contour, as I demonstrate below.
Because cosine is even, we may assume that $\omega > 0$.  Rewrite the integral as
$$\frac12 \int_{-\infty}^{\infty} dx \frac{e^{i \omega x} + e^{-i \omega x}}{x^2+25} $$
Break the integral in two.  Now first consider the following contour integral
$$\oint_{C_+} dz \frac{e^{i \omega z}}{z^2+25} $$
where $C_+$ is a semicircle of radius $R$ in the upper half-plane.  The contour integral is equal to
$$\int_{-R}^R dx \frac{e^{i \omega x}}{x^2+25} + i R \int_0^{\pi} d\theta \, e^{i \theta} \frac{e^{-\omega R \sin{\theta}} e^{i \omega R \cos{\theta}}}{R^2 e^{i 2 \theta}+25} $$
As $R \to \infty$ the second integral has a magnitude bounded from above by
$$\frac{2}{R} \int_0^{\pi/2} d\theta \, e^{-\omega R \sin{\theta}} \le \frac{2}{R} \int_0^{\pi/2} d\theta \, e^{-2 \omega R \theta/\pi} \le \frac{\pi}{2 \omega R^2} $$
Thus the second integral vanishes as $R \to \infty$.  By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=5 i$.  Therefore,
$$\int_{-\infty}^{\infty} dx \frac{e^{i \omega x}}{x^2+25} = i 2 \pi \frac{e^{i \omega (5 i)}}{2 \cdot 5 i} = \frac{\pi}{5} e^{-5 \omega}$$
Now consider the following contour integral:
$$\oint_{C_-} dz \frac{e^{-i \omega z}}{z^2+25} $$
where $C_-$ is a semicircle of radius $R$ in the lower half-plane.  The contour integral is equal to
$$\int_{R}^{-R} dx \frac{e^{-i \omega x}}{x^2+25} + i R \int_{\pi}^{2 \pi} d\theta \, e^{i \theta} \frac{e^{\omega R \sin{\theta}} e^{-i \omega R \cos{\theta}}}{R^2 e^{i 2 \theta}+25} $$
Note that $\sin{(\pi+\theta)}=-\sin{\theta}$.  As $R \to \infty$ the second integral has a magnitude bounded from above by
$$\frac{2}{R} \int_0^{\pi/2} d\theta \, e^{-\omega R \sin{\theta}} \le \frac{2}{R} \int_0^{\pi/2} d\theta \, e^{-2 \omega R \theta/\pi} \le \frac{\pi}{2 \omega R^2} $$
Thus the second integral vanishes as $R \to \infty$.  By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=-5 i$.  Therefore,
$$-\int_{-\infty}^{\infty} dx \frac{e^{i \omega x}}{x^2+25} = i 2 \pi \frac{e^{-i \omega (-5 i)}}{2 \cdot (-5 i)} = -\frac{\pi}{5} e^{-5 \omega}$$
Therefore, putting this all together, and considering the fact that the integrand is even with respect to $\omega$, we have
$$\int_{-\infty}^{\infty} dx \frac{\cos{\omega x}}{x^2+25} =\frac{\pi}{5} e^{-5 |\omega|}$$
