Integrating $\cos z/(z^2+1)$ Let $C_R\subset\mathbb C$ be a directed line segment that goes from $-R+2i$ to $R+2i$.  I would like to evaluate 
$$
\lim_{R\rightarrow\infty} \int_{C_R} \frac{\cos z}{z^2 + 1}\ dz.
$$
I obviously tried to do this by residue calculus.
I tried expressing $\cos$ in terms of $\exp$, or experimenting with various closed curves that contains $C_R$, but in vain.
I would be grateful if you could give a clue.
 A: Let $\gamma_R^+$ be the curve that goes from $-R+2i$ to $R+2i$ then circles counter-clockwise back above the line to $-R+2i$ and $\gamma_R^-$ be the curve that goes from $-R+2i$ to $R+2i$ then circles clockwise back below the line to $-R+2i$. Then, your limit equals
$$
\lim_{R\to\infty}\left(\frac12\int_{\gamma_R^+}\frac{e^{iz}}{z^2+1}\,\mathrm{d}z
+\frac12\int_{\gamma_R^-}\frac{e^{-iz}}{z^2+1}\,\mathrm{d}z\right)\tag{1}
$$
$\gamma_R^+$ does not contain any singularities, so the first integral is $0$. $\gamma_R^-$ contains the singularities at $i$ and $-i$. The residue at $i$ is $-\frac{ei}{2}$ and the residue at $-i$ is $\frac{i}{2e}$. The integral over $\gamma_R^-$ is $-2\pi i$ times the sum of the residues, which is $-\pi\left(e-\frac1e\right)$. Thus, $(1)$ is
$$
-\frac\pi2\left(e-\frac1e\right)\tag{2}
$$
A: $\displaystyle{%
{\cal I}\left(R\right) \equiv 
\int_{C_{R}}\frac{\cos\left(z\right)}{z^{2} + 1}\,{\rm d}z}\,,
\quad
\lim_{R \to \infty}{\cal I}\left(R\right) = ?$
\begin{align}
{\cal I}\left(R\right)
&=
-2\pi{\rm i}\,{\cos\left({\rm i}\right) \over 2{\rm i}}
-
\int_{2}^{0}
{\cos\left(R + {\rm i}y\right) \over \left(R + {\rm i}y\right)^{2} + 1}\,{\rm i\,d}y
-
\int_{R}^{-R}{\cos\left(x\right) \over x^{2} + 1}\,{\rm d}x
-
\int_{0}^{2}
{\cos\left(-R + {\rm i}y\right) \over \left(-R + {\rm i}y\right)^{2} + 1}\,{\rm i\,d}y
\\[5mm]&
\lim_{R \to \infty}{\cal I}\left(R\right)
=
-\pi\cosh\left(1\right)
+
\int_{-\infty}^{\infty}{\cos\left(x\right) \over x^{2} + 1}\,{\rm d}x
=
-\pi\cosh\left(1\right)
+
\Re\int_{-\infty}^{\infty}
{{\rm e}^{{\rm i}x} \over \left(x - {\rm i}\right)\left(x + {\rm i}\right)}\,{\rm d}x
\\[3mm]&=
-\pi\cosh\left(1\right)
+
\Re\left\lbrack%
2\pi{\rm i}\,{{\rm e}^{{\rm i}\ {\rm i}} \over {\rm i} + {\rm i}}
\right\rbrack
=
-\pi\cosh\left(1\right)
+
\pi{\rm e}^{-1}
=
{\large -\pi\,\sinh\left(1\right)}
\end{align}
