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

Start with the infinite product expansion
$$\frac{\sin z}{z} = \prod_{k=1}^{\infty}\left(1 - \frac{z^2}{k^2\pi^2}\right)$$
Taking logarithm, substitute $z$ by $\pi\sqrt{x}$ and differentiate with respect to $x$, we find
$$
\sum_{k=1}^{\infty} \frac{1}{k^2 - x} 
= -\frac{d}{dx} \left[ \sum_{k=1}^{\infty}\log\left(1 - \frac{x}{k^2}\right)\right]
= -\frac{d}{dx} \left[ \log\left(\frac{\sin(\pi \sqrt{x})}{\pi \sqrt{x}}\right) \right]
$$
Differentiate both sides with respect to $x$ for $\ell - 1 $ more times and then divide by $-(\ell-1)!$, we get in general:
$$
\sum_{k=1}^{\infty} \frac{1}{(k^2 - x)^\ell} = -\frac{1}{(\ell-1)!}
\frac{d^{\ell}}{dx^{\ell}} \left[ \log\left(\frac{\sin(\pi \sqrt{x})}{\pi \sqrt{x}}\right) \right]
$$
In the case $\ell = 2$, the RHS simplifies to
$$-\frac{1}{2x^2} + \frac{\pi}{4x}\left( 
\frac{1}{\sqrt{x}}\cot(\pi\sqrt{x}) + \pi \csc(\pi\sqrt{x})^2  
\right)$$
Substitute $x$ by $\frac{n}{m}$ will give you the formula you have for $\ell = 2$. Formula for other $\ell$ can be obtained by taking corresponding number of derivatives.
