Proving $\sum\limits_{m=1}^\infty\dfrac{x^2}{m^2-x^2} = \dfrac{1}{2}- \dfrac{\pi x\cot(\pi x)}{2}$ How can we prove
$$\sum_{m=1}^\infty\dfrac{x^2}{m^2-x^2} = \dfrac{1}{2} - \dfrac{\pi x\cot(\pi x)}{2}$$
using complex analysis or Fourier series or Integrals? I have proved it using elementary techniques like splitting and sum, telescoping by grouping the terms and stuff, however I'm most interested in an approach making use of complex analysis or Fourier series or Integrals, however any approach (given that it isn't too elementary) is most welcomed.
Thanks in advance.
 A: Let $f(z)=\frac{\cot(\pi z)}{z^2-x^2}$ and $C$ be the contour $|z|=N+1/2$.  Then, we have
$$\lim_{N\to \infty }\oint_{|z|=N+1/2} \frac{\cot(\pi z)}{z^2-x^2}\,dz=0$$
In addition, we have from the residue theorem,
$$\oint_{|z|=N+1/2} \frac{\cot(\pi z)}{z^2-x^2}\,dz=2\pi i \left(\frac{\cot(\pi x)}{x}+\sum_{n=-N}^N \frac{1}{\pi(n^2-x^2)}\right)$$
Letting $N\to \infty$ reveals
$$\sum_{n=-\infty}^\infty \frac{1}{(n^2-x^2)}=-\frac{\pi \cot(\pi x)}{x}$$
and hence
$$\sum_{n=1}^\infty \frac{x^2}{(n^2-x^2)}=\frac12-\frac{\pi x\cot(\pi x)}{2}$$
A: Probably too elementary
$$\frac{x^2}{m^2-x^2}=\frac x 2 \left(\frac 1{m-x}-\frac 1{m+x} \right)$$
$$S_1=\sum_{m=1}^p \frac 1{m-x}=\psi (p-x+1)-\psi (1-x)=H_{p-x}-H_{-x}$$
$$S_2=\sum_{m=1}^p \frac 1{m+x}=\psi(p+x+1)-\psi (x+1)=H_{p+x}-H_x$$ Now, using the asymptotics of the digamma function or the asymptotics of the generalized harmonic numbers
$$\frac x 2(S_1-S_2)=\frac{1-\pi  x \cot (\pi  x)}{2} -\frac{x^2}{p}+\frac{x^2}{2 p^2}+O\left(\frac{1}{p^3}\right)$$
A: $f(x)=\sum_{m=1}^\infty\dfrac{x}{m^2-x^2} - \dfrac{1}{
2x} + \dfrac{\pi \cot(\pi x)}{2}$ is a $1$-periodic entire function.
$g(x)=f(x)/x$ is entire and bounded on $\Re(x)\in [0,1]$ thus everywhere.
Whence $g(x)=g(i\infty)=0$.
