On the series $\sum \limits_{n=-\infty}^{\infty} \frac{\cos n}{n^2+1}$. Prove that
$$\sum_{n=-\infty}^{\infty} \frac{\cos n}{n^2+1} = \frac{\pi \cosh (\pi -1)}{\sinh \pi }$$
I already have a solution using Fourier expansion of the exponential function. I'm interested in a complex analysis approach. It would be natural to consider the function
$$f(z) = \frac{\pi \cot \pi z \cos z}{z^2+1}$$
and integrate it around an appropriate contour $\Gamma_N$ ( say a square ) The residues at $z=i$ and $z=-i$ are equal;
$$\mathfrak{Res}_{z=i} f(z) = \mathfrak{Res}_{z=-i} f(z) = - \frac{\pi \cosh 1 \coth \pi}{2}$$
Thus,
$$\frac{1}{2\pi i } \oint \limits_{\Gamma_N} f(z) \, \mathrm{d}z = \sum_{n=-N}^{N}  \mathfrak{Res}_{z=n} f(z) + \mathfrak{Res}_{z=i} f(z) + \mathfrak{Res}_{z=-i} f(z)$$
If we let $N \rightarrow +\infty$ the contour would go to $0$ and we would pick the result. However, this is not the case. Something's missing. The main question is why is that? Can you suggest an appropriate kernel function as well as a contour? 
 A: Hint: try to integrate
$$f(z)=\frac{{\pi {e^{iz}}}}{{({z^2} + 1)({e^{2\pi iz}} - 1)}}$$
around the rectangular contour with vertices $\pm R \pm Ri$, with $R$ a half integer. You might want to check carefully that the integral indeed tends to $0$. 
The sum of residues at $z=\pm i$ is $\frac{i}{2}\frac{{\pi \cosh (\pi  - 1)}}{{\sinh \pi }}$, giving
$$ - \frac{i}{2}\sum\limits_{n =  - \infty }^\infty  {\frac{{{e^{in}}}}{{{n^2} + 1}}}  + \frac{i}{2}\frac{{\pi \cosh (\pi  - 1)}}{{\sinh \pi }} = 0$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
With the Poisson's Sumation Formula:
\begin{align}
&\bbox[10px,#ffd]{\sum_{n = -\infty}^{\infty}{\cos\pars{n} \over
n^{2} + 1}} =
\sum_{n = -\infty}^{\infty}\int_{-\infty}^{\infty}{\cos\pars{t} \over t^{2} + 1}\expo{-2\pi\ic nt}\,\dd t
\\[5mm] & =
{1 \over 2}\sum_{n = -\infty}^{\infty}\bracks{\int_{-\infty}^{\infty}
{\expo{\pars{1 - 2n\pi}\ic t} \over t^{2} + 1}\,\dd t +
\int_{-\infty}^{\infty}
{\expo{\pars{-1 - 2n\pi}\ic t} \over t^{2} + 1}\,\dd t}
\end{align}

However,
$\ds{\left.\int_{-\infty}^{\infty}
{\expo{\ic kt} \over t^{2} + 1}\,\dd t\,\right\vert_{\ k\ \in\ \mathbb{R}} = \pi\expo{-\verts{k}}}$.

Then,
\begin{align}
&\bbox[10px,#ffd]{\sum_{n = -\infty}^{\infty}{\cos\pars{n} \over
n^{2} + 1}} =
{1 \over 2}\,\pi\sum_{n = -\infty}^{\infty}\bracks{%
\expo{-\verts{2n\pi - 1}} + \expo{-\verts{2n\pi + 1}}}
\\[5mm] & =
\bbx{\pi\cosh\pars{\pi - 1} \over \sinh\pars{\pi}} \approx 1.1739
\\ &
\end{align}
