Calculation of $\int_{-\infty}^\infty {\cos x\over a^2-x^2}\ dx$ using residue theorem 
Compute the integral using Residue theorem:
$$\int_{-\infty}^\infty {\cos x\over a^2-x^2}\ dx\quad a>0.$$

My attempt: Choose the contour
$$\Gamma = \{Re^{i\theta}:0\leq\theta\leq\pi\}\cup [-R,-a-\epsilon]\cup\{-a+\epsilon e^{i\theta}:0\leq\theta\leq\pi\}\cup[-a+\epsilon,a-\epsilon]\cup\{a+\epsilon e^{i\theta}:0\leq\theta\leq\pi\}\cup[a+\epsilon, R]$$
Denote the three upper half circle $C_R$, $C_{\epsilon_1}$ and $C_{\epsilon_2}$. The function  ${e^{iz}\over a^2-z^2}$ is analytic on and inside of $\Gamma$ so by Cauchy theorem, the integral over $\Gamma$ is zero.
\begin{align*}
\int_{C_R}{e^{iz}\over a^2-z^2}\ dz & = \int_0^{\pi}{e^{i(Re^{i\theta})}\over a^2-R^2e^{2i\theta}}iRe^{i\theta}\ d\theta\\
& \leq\int_0^\pi{R\over R^2-a^2}e^{-R\sin\theta}\ d\theta\\
& = 2\int_0^{\pi/2}{R\over R^2-a^2}e^{-R\sin\theta}\ d\theta\\
&\leq 2\int_0^{\pi/2}{R\over R^2- a^2} e^{-R(2\theta/\pi)}\ d\theta\\
& = {2R\over R^2-a^2}\left(-{\pi\over 2R}\right)(e^{-R}-1)\to 0\quad R\to\infty.\\
\int_{C_{\epsilon_2}}{e^{iz}\over a^2-z^2}\ dz & = \int_0^{\pi}{e^{i(a+\epsilon e^{i\theta})}\over a^2 - (a+\epsilon e^{i\theta})^2} i \epsilon e^{i\theta}\ d\theta\\
& = \int_0^{\pi}{e^{ia+i\epsilon\cos\theta}e^{-\epsilon\sin\theta}\over -2a\epsilon e^{i\theta} - \epsilon^2 e^{2i\theta}}i\epsilon e^{i\theta}\ d\theta\\
& = \int_{0}^\pi - i{e^{ia+i\epsilon\cos\theta}e^{-\epsilon\sin\theta} -1\over 2a+\epsilon e^{i\theta}} - i{1\over 2a+\epsilon e^{i\theta}}\ d\theta\\
\end{align*}
Note that
\begin{align*}
\left|{e^{ia+i\epsilon\cos\theta}e^{-\epsilon\sin\theta} -1\over 2a+\epsilon e^{i\theta}}\right|& \leq {1-e^{-\epsilon\sin\theta}\over 2a-\epsilon}\\
\int_0^{\pi}{1-e^{-\epsilon\sin\theta}\over 2a-\epsilon}\ d\theta & = {2\over 2a-\epsilon}\int_0^{\pi/2}1-e^{-\epsilon\sin\theta}\ d\theta\\
&\leq{2\over 2a-\epsilon}\int_0^{\pi/2}1-e^{-\epsilon}\ d\theta\to 0\quad\epsilon\to 0\\
\end{align*}
Hence,
$$ \int_{0}^\pi - i{e^{ia+i\epsilon\cos\theta}e^{-\epsilon\sin\theta} -1\over 2a+\epsilon e^{i\theta}} - i{1\over 2a+\epsilon e^{i\theta}}\ d\theta = -i\int_0^{\pi}{1\over 2a}\ d\theta = -{i\pi\over 2a}\quad\epsilon\to 0$$
Similarly, we can compute the integral over $C_{\epsilon_1}$
\begin{align*}
\int_{\epsilon_1}{e^{iz}\over a^2-z^2}\ dz & = \int_0^{\pi}{e^{i(-a+\epsilon e^{i\theta})}\over a^2- (-a+\epsilon e^{i\theta})^2} i\epsilon e^{i\theta}\ d\theta\\
& = \int_0^\pi i{e^{i(-a+\epsilon\cos\theta)}e^{-\epsilon\sin\theta}-1\over 2a-\epsilon e^{i\theta}}\ d\theta + \int_0^{\pi}i{1\over 2a-\epsilon e^{i\theta}}\ d\theta\to {i\pi\over 2a}\quad \epsilon\to 0\\
\end{align*}
So the integral is $0$? I can't find the error here. Please help.
By the way, the contour containing the poles by reflecting $C_{\epsilon_1}$ and $C_{\epsilon_2}$ will give the same calculation except that residue appears now. But they cancel each other
$$\int_{-\infty}^\infty{\cos x\over a^2-x^2}\ dx = \operatorname{Re}\left[2\pi i\operatorname{Res}\left({e^{iz}\over a^2-z^2}, z = \pm a\right)\right] = 0.$$
N.B. The integration is interpreted as
$$\int_{-\infty}^\infty = \lim_{R\to\infty,\epsilon\to 0+}\left(\int_{-R}^{-a-\epsilon}+\int_{-a+\epsilon}^{a-\epsilon}+\int_{a+\epsilon}^R\right).$$
 A: You missed the terms $e^{\pm ia}$ in the integrals on the semi-circular arcs around $\pm a$.  So, let's take another look at the integrals along those semi-circular arcs
For the integral around $C_{\varepsilon_1}$, $z=-a+\varepsilon e^{i\phi}$, and $\phi$ starts at $\pi$ and ends at $0$.  So, we have $e^{iz}=e^{i(-a+\varepsilon e^{i\phi})}$, $a-z=2a-\varepsilon e^{i\phi}$, $a+z=\varepsilon e^{i\phi}$, and $dz=i\varepsilon e^{i\phi}$.  Putting this together we find that
$$\begin{align}
\lim_{\varepsilon\to 0^+}\int_{C_{\varepsilon_1}}\frac{e^{iz}}{a^2-z^2}\,dz&=\lim_{\varepsilon\to 0^+}\int_\pi^0 \frac{e^{i(-a+\varepsilon e^{i\phi})}}{(2a-\varepsilon e^{i\phi})(\varepsilon e^{i\phi})}\,i\varepsilon e^{i\phi}\,d\phi\\\\
&=-\frac{i\pi e^{-ia}}{2a}\tag1
\end{align}$$
Analogously, we have for the integral around $C_{\varepsilon_2}$
$$\begin{align}
\lim_{\varepsilon\to 0^+}\int_{C_{\varepsilon_2}}\frac{e^{iz}}{a^2-z^2}\,dz&=\lim_{\varepsilon\to 0^+}\int_\pi^0 \frac{e^{i(a+\varepsilon e^{i\phi})}}{(2a+\varepsilon e^{i\phi})(-\varepsilon e^{i\phi})}\,i\varepsilon e^{i\phi}\,d\phi\\\\
&=\frac{i\pi e^{ia}}{2a}\tag2
\end{align}$$
Adding $(1)$ and $(2)$ we find that
$$\lim_{\varepsilon\to 0^+}\left(\int_{C_{\varepsilon_1}}\frac{e^{iz}}{a^2-z^2}\,dz+\int_{C_{\varepsilon_2}}\frac{e^{iz}}{a^2-z^2}\,dz\right)=-\frac{\pi\sin(a)}{a}\tag3$$
Using $(3)$, we have
$$\text{PV}\int_{-\infty}^\infty \frac{\cos(x)}{a^2-x^2}\,dx=\frac{\pi \sin(a)}{a}$$
