TITLE: Using residues to evaluate a sum involving the square of $\text{csch}$
QUESTION [11 upvotes]: I have been trying to evaluate the following sum using residues:

$$ \sum_{n=1}^{\infty}\frac{1}{\sinh^{2}(\pi
 n)}=\frac{1}{6}-\frac{1}{2\pi}$$

I am mainly interested in using residues to do this.  I can do it using real methods.
I tried using $\displaystyle \oint\frac{\pi\cot(\pi z)}{\sinh^{2}(\pi z)}dz$
The residue at $z=0$ is $\frac{-2}{3}$
The residue at $\displaystyle z=n, \;\ (n=\pm 1, \pm 2, \pm 3, ....)$ is $\displaystyle \lim_{z\to n}\frac{(z-n)\cos(\pi z)}{\sin(\pi z)\sinh^{2}(\pi z)}=\frac{1}{\sinh^{2}(\pi n)}$
The residue at $\displaystyle z=ni, \;\ (\pm 1, \pm 2, \pm 3, .....)$ is 
$\displaystyle \lim_{z\to ni}\frac{(z-ni)\pi\cot(\pi z)}{\sinh^{2}(\pi z)}=\frac{1}{\sinh^{2}(\pi n)}$
So, by the residue theorem:
$\displaystyle \oint\frac{\pi \cot(\pi z)}{\sinh^{2}(\pi z)}dz=\frac{-2}{3}+4\sum_{n=1}^{N}\frac{1}{\sinh^{2}(\pi n)}$
As $N\to \infty$, the left side goes to 0, then solve for the sum at hand.
It would appear the 1/6 is in there, but I have failed to arrive at the correct solution.
Where does the $\frac{1}{2\pi}$ come into play?.
No doubt, I am doing it incorrectly. Can someone point me in the right direction?
Thanks a lot.

REPLY [6 votes]: I worked this out for a different problem in a bit more generality, so I will post the generalization here.
We are going to use the contour integral
$$
\oint\pi\cot\left(\frac{2\pi}{x}z\right)\left(\mathrm{csch}^2(z)-\frac1{z^2}\right)\mathrm{d}z=-4\pi i\tag{1}
$$
where the contours of interest are, for real $R\to\infty$ and integer $n\to\infty$,
$$
\small\textstyle\color{#00A000}{[R,-R]+(n+\frac12)\pi i}\cup\color{#C00000}{-R+(n+\frac12)\pi i[1,-1]}\cup\color{#00A000}{[-R,R]-(n+\frac12)\pi i}\cup\color{#C00000}{R+(n+\frac12)\pi i[-1,1]}
$$
The integral along the red paths becomes negligible as $R\to\infty$. Along the upper green path, where $\mathrm{Im}(z)\approx+\infty$, $\cot(z)\approx-i$. Along the lower green path, where $\mathrm{Im}(z)\approx-\infty$, $\cot(z)\approx+i$. Since $\mathrm{csch}^2(z+\frac\pi2i)=-\mathrm{sech}^2(z)$ is the derivative of $-\tanh(z)$, the integral along each of the green paths tends to $-2\pi i$. Therefore, the full integral is $-4\pi i$.
Since
$$
\pi\cot\left(\frac{2\pi}{x}z\right)\text{ has residue }\frac x2\text{ at }z=\frac x2n\tag{2}
$$
and
$$
\mathrm{csch}^2(z)-\frac1{z^2}=-\frac13+O(z^2)\text{ at }z=0\tag{3}
$$
the contribution from the singularities on the real axis is
$$
2\pi i\frac x2\left[2\sum_{n=1}^\infty\left(\mathrm{csch}^2\left(\frac x2n\right)-\frac4{x^2n^2}\right)-\frac13\right]\tag{4}
$$
Since
$$
\mathrm{csch}^2(z)=\frac1{(z-\pi in)^2}+O(1)\text{ at }z=\pi in\text{ for }n\ne0\tag{5}
$$
and
$$
\begin{align}
\left.\frac{\mathrm{d}}{\mathrm{d}z}\pi\cot\left(\frac{2\pi}{x}z\right)\right|_{z=\pi in}
&=\left.-\frac{2\pi^2}{x}\csc^2\left(\frac{2\pi}{x}z\right)\right|_{z=\pi in}\\
&=\frac{2\pi^2}{x}\mathrm{csch}^2\left(\frac{2\pi^2}{x}n\right)\tag{6}
\end{align}
$$
the contribution from the singularities on the imaginary axis is
$$
2\pi i\frac{2\pi^2}{x}\left[2\sum_{n=1}^\infty\mathrm{csch}^2\left(\frac{2\pi^2}{x}n\right)\right]\tag{7}
$$
Putting together $(1)$, $(4)$, and $(7)$ gives
$$
\frac x2\sum_{n=1}^\infty\mathrm{csch}^2\left(\frac x2n\right)
+\frac{2\pi^2}{x}\sum_{n=1}^\infty\mathrm{csch}^2\left(\frac{2\pi^2}{x}n\right)
=-1+\frac{\pi^2}{3x}+\frac x{12}\tag{8}
$$
Setting $x=2\pi$ in $(8)$ yields
$$
\sum_{n=1}^\infty\mathrm{csch}^2(\pi n)=\frac16-\frac1{2\pi}\tag{9}
$$