How to prove that $\sum_{n=1}^{+\infty}\frac{1}{n^2+1}=\frac{-1+\pi \coth (\pi)}{2}$? I typed into my Mathematica:$\sum _{n=1}^{\infty } \frac{1}{n^2+1}$ , and the result was: $$\frac{-1+\pi \coth (\pi)}{2}$$ I know how to estimate the aforementioned sum , but I have no idea how to get its closed form.
 A: Knowing the partial fraction decomposition of the cotangent [a standard (because it's easy to derive and very useful) example in complex analysis texts illustrating the Mittag-Leffler theorem],
$$\pi \cot \pi z = \frac{1}{z} + \sum_{n\neq 0} \frac{1}{z-n} + \frac{1}{n} = \lim_{N\to\infty} \sum_{n=-N}^N \frac{1}{z-n},$$
we can compute the sum of all series of the form
$$\sum_{n=1}^\infty \frac{1}{n^2 - a^2}$$
where $a$ is not an integer:
$$\begin{align}
\sum_{n=1}^\infty \frac{1}{n^2-a^2}
&= \lim_{N\to\infty}\sum_{n=1}^N \frac{1}{n^2-a^2}\\
&= -\frac{1}{2a}\lim_{N\to\infty} \sum_{n=1}^N \frac{1}{a-n} + \frac{1}{a+n}\\
&= -\frac{1}{2a}\lim_{N\to\infty} \left(-\frac{1}{a} +\sum_{n=-N}^N  \frac{1}{a-n}\right)\\
&= -\frac{1}{2a}\left(\pi \cot \pi a - \frac{1}{a}\right)\\
&= \frac{1-\pi a\cot \pi a}{2a^2}.
\end{align}$$
To obtain the terms $\frac{1}{n^2+1}$ we choose $a = i$ and get
$$\sum_{n=1}^\infty \frac{1}{n^2+1} = \frac{1 - \pi i \cot \pi i}{2i^2}.$$
Using $i^2 = -1$ in the denominator and
$$\cot \pi i = \frac{\cos \pi i}{\sin \pi i} = \frac{\cosh \pi}{i\sinh\pi} = \frac{1}{i}\coth \pi,$$
the result becomes
$$\sum_{n=1}^\infty \frac{1}{n^2+1} = \frac{\pi \coth\pi - 1}{2}.$$
