Infinite Series $\sum_{k=1}^{\infty}\frac{1}{(mk^2-n)^2}$ How can we prove the following formula?
$$\sum_{k=1}^{\infty}\frac{1}{(mk^2-n)^2}=\frac{-2m+\sqrt{mn}\pi\cot\left(\sqrt{\frac{n}{m}}\pi\right)+n\pi^2\csc^2\left(\sqrt{\frac{n}{m}}\pi\right)}{4mn^2}$$
What is the general method for finding sums of the form $\sum\limits_{k=1}^{\infty}\frac{1}{(mk^2-n)^\ell}, \ell\in\mathbb{N}$?

This sum may be evaluated by considering the following contour integral in the complex plane:
$$\oint_C dz \frac{\pi \cot{\pi z}}{(m z^2-n)^2}$$
where $C$ is a rectangular contour that encompasses the poles of the integrand in the complex plane, up to $z=\pm \left ( N +\frac12\right)$, where we consider the limit as $N \to\infty$.
We note here that we assume that the ratio $n/m$ is not the square of an integer.  Now, the contour integral is zero because the individual integrals along each piece of the contour cancel.  On the other hand, the contour integral is equal to $i 2 \pi$ times the sum of the residues of the poles of the integrand.  Working this out, we find that
$$\sum_{k=-\infty}^{\infty} \frac{1}{(m k^2-n)^2} = -\sum_{\pm}\operatorname*{Res}_{z=\pm \sqrt{n/m}}  \frac{\pi \cot{\pi z}}{(m z^2-n)^2}$$
Since the pole is a double pole, we have
$$\sum_{\pm}\operatorname*{Res}_{z=\pm\sqrt{n/m}}  \frac{\pi \cot{\pi z}}{(m z^2-n)^2} =\sum_{\pm} \frac{\pi}{m^2} \left [\frac{d}{dz} \frac{\cot{\pi z}}{(z\pm \sqrt{n/m})^2} \right ]_{z=\pm\sqrt{n/m}}  $$
I assume that the reader can take the derivatives and do the subsequent algebra.  I get for the sum
$$-\frac{\pi}{m^2} \frac{m}{2 n} \left [\sqrt{\frac{m}{n}}\cot{\left(\pi \sqrt{\frac{n}{m}} \right)}+ \pi \csc^2{\left(\pi \sqrt{\frac{n}{m}} \right)}\right ] $$
So we now have
$$\sum_{k=-\infty}^{\infty} \frac{1}{(m k^2-n)^2} = \frac{\pi}{2 m n}  \left [\sqrt{\frac{m}{n}}\cot{\left(\pi \sqrt{\frac{n}{m}} \right)}+ \pi \csc^2{\left(\pi \sqrt{\frac{n}{m}} \right)}\right ] $$
We now exploit the evenness of the summand; the result is
$$\sum_{k=1}^{\infty} \frac{1}{(m k^2-n)^2} = -\frac{1}{2 n^2} + \frac{\pi}{4 m n}  \left [\sqrt{\frac{m}{n}}\cot{\left(\pi \sqrt{\frac{n}{m}} \right)}+ \pi \csc^2{\left(\pi \sqrt{\frac{n}{m}} \right)}\right ] $$
The result to be proven follows.
For the general sum
$$\sum_{k=1}^{\infty} \frac{1}{(m k^2-n)^{\ell}}$$
where $\ell \gt 2$ and $\ell \in \mathbb{Z}$, we take the same approach.  The residue is an $\ell-1$ derivative of the integrand.
