Contour integration with poles I am trying to solve:
$$\int_{-\infty}^{\infty}\frac{x\sin{x}}{x^2 + a^2}dx$$
and show that it equals $\pi e^{-a}$ for all $a > 0$.
I translate it to its complex equivalent:
$$lim_{R \rightarrow \infty} \int_{-R}^{R}\frac{z\sin{z}}{z^2 + a^2}dz = \int_{C}\frac{z\sin{z}}{z^2 + a^2}dz - \int_{\gamma}\frac{z\sin{z}}{z^2 + a^2}dz$$
where C is a half circle with radius R, above the real axis, and $\gamma$ is only the curved (top part) of the half circle.
I've shown that $$\int_{\gamma}\frac{z\sin{z}}{z^2 + a^2}dz$$ tends to 0 as $R \rightarrow \infty$.
So now:
$$lim_{R \rightarrow \infty} \int_{-R}^{R}\frac{z\sin{z}}{z^2 + a^2}dz = \int_{C}\frac{z\sin{z}}{z^2 + a^2}dz$$
By residue theorem, 
$$\int_{C}\frac{z\sin{z}}{z^2 + a^2}dz = 2\pi i \cdot res_{ai}f$$
as $ai$ is the pole of $f$ that lies above the real axis.
$$2\pi i \cdot res_{ai}f = 2\pi i \cdot lim_{z \rightarrow ai} (z-ai)\frac{z sin{z}}{z^2 + a^2}$$
By L'Hospital's rule, this is equivalent to:
$$2\pi i \cdot lim_{z \rightarrow ai} (z-ai)\frac{z^2\cos{z} + 2z\sin{z} - zai\cos{z} - ai\sin{z}}{2z} = 2\pi i \cdot \frac{\sin{ai}}{2} = \pi i \sin{ai}$$
But how is $\pi i \sin{ai}$ equivalent to $\pi e^{-a}$? Did I make a mistake?
 A: 
I've shown that $$\int_{\gamma}\frac{z\sin{z}}{z^2 + a^2}dz$$ tends to 0 as $R \rightarrow \infty$.

That was erroneous. This integral does not tend to $0$ as $R\to \infty$.
Since $\frac{x}{x^2+a^2}$ is an odd function, and $\cos x$ is even, we see that
$$\int_{-\infty}^\infty \frac{x\sin x}{x^2+a^2}\,dx = \operatorname{Im} \int_{-\infty}^\infty \frac{xe^{ix}}{x^2+a^2}\,dx = \frac{1}{i} \int_{-\infty}^\infty \frac{xe^{ix}}{x^2+a^2}\,dx.$$
Since $\frac{z}{z^2+a^2}\to 0$ for $\lvert z\rvert \to\infty$, Jordan's lemma tells us that (I index the contours with the radius of the semicircle)
$$\int_{\gamma_R} \frac{ze^{iz}}{z^2+a^2}\,dz \xrightarrow{R\to\infty} 0,$$
so by Cauchy's integral theorem we obtain
$$\int_{-\infty}^\infty \frac{xe^{ix}}{x^2+a^2}\,dx = \int_{C_R} \frac{ze^{iz}}{z^2+a^2}\,dz$$
for $R > a$. The pole $ia$ of the integrand lies in the upper half-plane, and the pole $-ia$ in the lower half-plane, so by the residue theorem
$$\int_{C_R} \frac{ze^{iz}}{z^2+a^2}\,dz = 2\pi i \operatorname{Res}\left(\frac{ze^{iz}}{z^2+a^2}; ia\right) = 2\pi i \frac{iae^{-a}}{2ia} = \pi ie^{-a}$$
for $R > \lvert a\rvert$, and thus
$$\int_{-\infty}^\infty \frac{x\sin x}{x^2+a^2}\,dx = \pi  e^{-a}.$$
But
$$\int_{C_R} \frac{z\sin z}{z^2+a^2}\,dz = 2\pi i \operatorname{Res} \left(\frac{z\sin z}{z^2+a^2}; ia\right) = 2\pi i \frac{ia\sin (ia)}{2ia} = \pi i \sin (ia) = -\pi\sinh a,$$
hence
$$\begin{aligned}
\lim_{R\to\infty} \int_{\gamma_R} \frac{z\sin z}{z^2+a^2}\,dz\; 
&= \lim_{R\to\infty} \int_{C_R} \frac{z\sin z}{z^2+a^2}\,dz - \int_{-\infty}^\infty \frac{x\sin x}{x^2+a^2}\,dx\\
&= -\pi \sinh a - \pi e^{-a}\\
&= -\pi \cosh a \neq 0.
\end{aligned}$$
The issue is that while $\lvert e^{iz}\rvert = e^{-\operatorname{Im} z} \to 0$ as $\operatorname{Im} z \to +\infty$, which allows to show that the integrals
$$\int_{\gamma_R} f(z)e^{iz}\,dz$$
tend to $0$ as $R\to \infty$ when $f(z) \to 0$ for $\lvert z\rvert\to \infty$ by standard techniques, $\lvert\sin z\rvert$ grows exponentially when $\lvert\operatorname{Im} z\rvert \to \infty$ - namely $\lvert \sin (x+iy)\rvert^2 = \sin^2 x + \sinh^2 y$ for real $x,y$ - which makes it impossible to show that the integrals even remain bounded by standard techniques for the estimation of integrals for most functions $f$. For functions like $\frac{z}{z^2+a^2}$, which are holomorphic in the complex plane except for isolated singularities, real-valued on $\mathbb{R}$, have only finitely many isolated singularities (or the series of the residues is convergent), and such that the improper Riemann integral or Lebesgue integral of $f(z)\sin z$ over $\mathbb{R}$ exists, it follows that not only are the integrals bounded, they even converge to a limit. But, as the example shows, in general, that limit is not $0$.
