How can I evaluate the infinite series $$\sum_{k=1}^\infty \frac{k\sin(kx)}{k^2+a^2}$$ using the residue theorem?
My approach was to use the function $$f(z)=\frac{z\sin(zx)}{z^2+a^2}\frac{\pi}{\tan(\pi z)}$$ integrated about a circle centered at the origin, but I kept coming up with the wrong answer.
I think it is more efficient to exploit the Fourier series of $e^{-ax}$ over $(0,2\pi)$.
We have $$ \int_{0}^{2\pi}e^{-ax}\sin(k x)\,dx = \frac{k}{k^2+a^2}(1-e^{-2a\pi})$$ $$ \int_{0}^{2\pi}e^{-ax}\cos(k x)\,dx = \frac{a}{k^2+a^2}(1-e^{-2a\pi})$$ hence $$ \sum_{k\geq 1}\frac{k\sin(kx)}{k^2+a^2}=\frac{\pi}{2}\cdot\frac{e^{-ax}-e^{-2a\pi+ax}}{1-e^{-2a\pi}}=\frac{\pi \sinh(\pi a-ax)}{2\sinh(\pi a)}. $$