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?
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$$