I would like prove this equality
$$1-\frac{1}{n-1}+\frac{1}{n+1}-\frac{1}{2n-1}+\frac{1}{2n+1}-\frac{1}{3n-1}+\frac{1}{3n+1}+... =\frac{\pi}{n\tan{\frac{\pi}{n}}}$$
I would like prove this equality
$$1-\frac{1}{n-1}+\frac{1}{n+1}-\frac{1}{2n-1}+\frac{1}{2n+1}-\frac{1}{3n-1}+\frac{1}{3n+1}+... =\frac{\pi}{n\tan{\frac{\pi}{n}}}$$
The series is equal to
$$1-2 \sum_{k=1}^{\infty} \frac1{k^2 n^2-1} - 1-\frac{2}{n^2} \sum_{k=1}^{\infty} \frac1{k^2-\frac1{n^2}}$$
Now, we can evaluate the sum
$$\sum_{k=-\infty}^{\infty} \frac1{k^2-\frac1{n^2}} $$
by the residue theorem. I will omit the proof; the sum is equal to
$$-\pi \sum_{\pm}\operatorname*{Res}_{z=\pm \frac1n} \frac{\cot{\pi z}}{z^2-\frac1{n^2}} = -\pi n\cot{\frac{\pi}{n}} $$
Therefore the sum is
$$1-\frac{2}{n^2} \frac12 \left (-\pi n\cot{\frac{\pi}{n}} + n^2 \right ) = \frac{\pi}{n} \cot{\frac{\pi}{n}}$$
as was to be shown.