A (basic?) contour integration problem I am trying to prove the following using complex analysis:
$$\sum_{n=-\infty}^{\infty}\frac{(-1)^{n}}{a^{2}+n^{2}}=\frac{\pi}{a\sinh(a\pi)}$$
I am told to use the following function:
$$f(z)=\frac{1}{(a^{2}+z^{2})\sin(\pi z)}$$
So we note that $f(z)$ has singularities at $z = \{\pm i a, n\}$, where $n \in \mathbb{Z}$. We can use the following contour (which I will call $\Gamma$):
                                    
By Cauchy's Residue Theorem, we have:
$$\lim_{R \to \infty}\oint_{\Gamma}f(z)\:\mathrm{d}z=2\pi i \sum_{n=-\infty}^{\infty}\operatorname{Res}(n,f(z))$$
We can compute the residue at each point:
$$\operatorname{Res}(n,f(z))=\frac{(-1)^n}{\pi(a^{2}+n^{2})}$$
So we have:
$$\lim_{R\to \infty}\oint_{\Gamma}f(z)\:\mathrm{d}z = 2\pi i \sum_{n=-\infty}^{\infty}\frac{(-1)^{n}}{a^{2}+n^{2}}$$
But we have that:
$$\begin{align*}\lim_{R\to\infty}\oint_{\Gamma}f(z)\:\mathrm{d}z = \lim_{R\to\infty}\Bigg(I &+ \int_{-\frac{a}{2}}^{\frac{a}{2}}\frac{\mathrm{d}y}{(a^{2} + (R + iy)^{2}\sin(\pi(R + iy))} \\ &+ \int_{R}^{-R}\frac{\mathrm{d}x}{(a^{2} + (x + ia/2)^{2})\sin(\pi(x+ia/2))} \\ 
&+ \int_{\frac{a}{2}}^{-\frac{a}{2}}\frac{\mathrm{d}y}{(a^{2} + (iy - R)^{2})\sin(\pi(iy - R))}\Bigg)\end{align*}$$
However, I'm not not sure how to proceed? I'd be grateful for any hints!
 A: Change the contour to a square box $C_{R}$ of sides $2R$ and centered at the origin.  The residues are from singularities at $z=\pm i$ and $z=n$ for all integers $|n|<R$ .
The residues at $z=\pm i$ are both equal to 
$$\frac{1}{2ia\sin(\pi ia)}=-\frac{1}{2a \sinh(\pi a)}$$
The residues at $n$ are given by
$$\frac{(-1)^n}{\pi(a^2+n^2)}$$
It is easy to show that 
$$\lim_{R\to \infty }\oint_{C_{R}}\frac{1}{(a^2+z^2)\sin(\pi z)}dz=0$$
since $\sin (\pi z) = \sin (\pi x)\cosh (\pi y)+i\cos(\pi x) \sinh (\pi y)$ grows exponentially on each side of the box.
Thus, 
$$\lim_{R\to \infty}\oint_{C_{box}}\frac{1}{(a^2+z^2)\sin(\pi z)}dz=2\pi i\left(\sum_{n=-\infty}^{\infty}\frac{(-1)^n}{\pi(a^2+n^2)}-\frac{1}{a\sinh(\pi a)}\right) =0$$
implies that the sum of the residues is zero.  This gives
$$\sum_{n=-\infty}^{\infty}\frac{(-1)^n}{a^2+n^2}=\frac{\pi}{a\sinh(\pi a)}$$
as was to be shown!
A: Ok i will give an answer using the original contour:
As the questioner correctly mentioned, by looking into the $\textbf{INTERIOR}$  of the contour we get (Limit $R\rightarrow \infty$ is implicit)
$$
\oint_{\Gamma}f(z)=2 \pi i\sum_{n=-\infty}^{\infty}\frac{(-1)^n}{(n^2+a^2)\pi} \quad (1)
$$
But if we are looking at the $\textbf{EXTERIOR}$  of the contour we get (because the big semicircles in the upper/lower halfplane  will vanish)
$$
\oint_{\Gamma}f(z)= -2 \pi i(\text{ res}[ia]+\text{ res}[-ia])= 2 \pi i\frac{1}{a\sinh(\pi a)} \quad (2)
$$
the minus sign is for reverting the path of integration. So all what's left is to put $(1)=(2)$ and therefore:
$$
\frac{\pi}{a\sinh(\pi a)}=\sum_{n=-\infty}^{\infty}\frac{(-1)^n}{n^2+a^2} 
$$
Remark: $\textbf{EVERY}$ contour which encloses the the real axis can be used for this trick, as long as no singularities in the rest of the complex plane are crossed
