I need major help in evaluating the following infinite sum: $$\sum_{k=1}^{\infty} \frac{k\sin(kx)}{(k^2+a^2)^2}\tag{1}\label{whatiwant}$$
where a is a constant. I know that (from Gradshteĭn et al, 2014, page 47) $$\sum_{k=1}^{\infty} \frac{k\sin(kx)}{(k^2+a^2)}=(\pi/2)\frac{\sinh(a(\pi-x))}{\sinh(a\pi)}\tag{2}\label{whatihave}$$ so that \eqref{whatiwant} is simply the left-hand side of \eqref{whatihave} with its denominator squared, but I am extremely confused as to how to proceed.
I'm afraid there is no too easy way to evaluate this sum. The regular approach to evaluate sums like $\sum_{k=-\infty}^{k=+\infty}f(k)$ is to apply integration in the complex plane with a special factor, which residuals give the required sum.
In our case $\sum_{k=1}^{\infty} \frac{k\sin(kx)}{(k^2+a^2)^2}=-\frac{1}{2a}\frac{\partial}{\partial{a}}\sum_{k=1}^{\infty} \frac{k\sin(kx)}{(k^2+a^2)}$, so we just have to evaluate $S(a,x)=2\sum_{k=1}^{k=\infty} \frac{k\sin(kx)}{(k^2+a^2)}=\sum_{k=-\infty}^{k=\infty}\frac{k\sin(kx)}{(k^2+a^2)}=\Im(\sum_{k=-\infty}^{k=\infty}\frac{k\exp(ikx)}{(k^2+a^2)})=\Im(\hat{S})$
Let's now consider $F(t)=\frac{t\exp(itx)}{t^2+a^2}\pi\frac{\exp(-i\pi{t})}{\sin(\pi{t})}$, where the factor $\pi\frac{\exp(-i\pi{t})}{\sin(\pi{t})}=2\pi{i}\frac{1}{\exp(2\pi{i}t)-1}$ has simple poles at integers $t$ ($t=0$, $-1$, $+1$, ...) with the residuals equal to $1$. The factor $\frac{t\exp(itx)}{t^2+a^2}$ in turn has two poles at $t=-ia$ and $t=ia$.
Let's consider the integral of $F(t)$ along a big circle of the radius $R$: $$I(a,x)=\oint\frac{t\exp(itx)}{t^2+a^2}\frac{2\pi{i}}{\exp(2\pi{i}t)-1}dt$$
According to the residual theorem $I(a,x)=2\pi{i}\sum_{\text{all poles}}{Res}(\frac{t\exp(itx)}{t^2+a^2}\frac{2\pi{i}}{\exp(2\pi{i}t)-1})=2\pi{i}\left(\sum_{k=-\infty}^{k=\infty}\frac{k\exp(ikx)}{k^2+a^2}+\sum_{t=+-ia}{Res}\frac{t\exp(itx)}{t^2+a^2}\frac{2\pi{i}}{\exp(2\pi{i}t)-1}\right)=2\pi{i}\left(\hat{S}(a,x)+2\pi{i}[\frac{ia\exp(-ax)}{2ia(\exp(-2\pi{a})-1)}+\frac{-ia\exp(ax)}{-2ia(\exp(2\pi{a})-1)}]\right)$ $$I(a,x)=2\pi{i}\left(\hat{S}(a,x)+\pi{i}\frac{\sinh(a(x-\pi))}{\sinh(a\pi)}\right)$$
On the other hand, if $0<x<2\pi$ at $R\to\infty$ in the lower half-plane the integrand has a factor $\sim\frac{e^{itx}}{e^{2\pi{i}t}}\sim\exp(it(x-2\pi))$, and in the upper half-plane the factor becomes $\sim\exp(itx)$. Also, $\frac{t}{t^2+a^2}\to0$ at $|t|\to\infty$. So, at $0<x<2\pi$ Jordan's lemma is applicable in the whole complex plane, and the integrale along a big circle $\to0$ as soon as $R\to0$
$I(a,x)=0$ $\Rightarrow$ $\hat{S}(a,x)=-\pi{i}\frac{\sinh(a(x-\pi))}{\sinh(a\pi)}$ $\Rightarrow$ $$\sum_{k=1}^{\infty} \frac{k\sin(kx)}{k^2+a^2}= \frac{\pi}{2}\frac{\sinh(a(\pi-x))}{\sinh(a\pi)}, x\in(0, 2\pi)$$ $$\sum_{k=1}^{\infty} \frac{k\sin(kx)}{(k^2+a^2)^2}= -\frac{\pi}{2a}\frac{\partial}{\partial{a}}\left(\frac{\sinh(a(\pi-x))}{\sinh(a\pi)}\right)$$