Computing $\sum_{n = 1}^{+ \infty} \frac{1}{n^2 + 1}$ using Fourier series. $f$ is a $2 \pi$ periodic function on $ ] - \pi,\pi[$ defined as :
$$f(x) = e^{-x}$$
Using Fourier series, compute the sums :
$$ \sum_{n = 1}^{+ \infty} \frac{1}{n^2 + 1} , \sum_{- \infty}^{+ \infty} \frac{1}{n^2 + 1} $$


How do I compute $\sum_{n = 1}^{+ \infty} \frac{1}{n^2 + 1}$ ?
I have computed the fourier coefficient and found that:
$$a_0 = \frac{2}{\pi} (1 - e^{- \pi}) $$
$$a_n = \frac{2}{\pi(n^2 + 1)} (1 - (-1)^n . e^{- \pi} ) $$
$$b_n = \frac{2n}{\pi(n^2 + 1)} (1 - (-1)^n . e^{- \pi} ) $$
Using Dirichlet theorem and taking $x = 0$ to make the $b_n$ disappear, I get:
$$S_f (1) = \frac{2}{\pi} (1 - e^{- \pi}) + \sum_{n = 1}^{+ \infty} \frac{2}{\pi(n^2 + 1)} (1 - (-1)^n . e^{- \pi} ) . (-1)^n = 1 $$
I do not see how to proceed to get the value of the sum?
The same problem for the second sum.
With the correct coefficients (see comments), you have for $x \in]-\pi,\pi[$:

$$
e^{-x} = \frac{2}{\pi} \sinh(\pi) + 2 \sinh(\pi) \sum_{n=1}^{\infty}\frac{ (-1)^n  (n\sin (nx) + \cos(nx)) }{\pi(n^2 + 1)} 
$$

so

$$
e^{x} + e^{-x} = \frac{4}{\pi} \sinh(\pi)  + 4 \sinh(\pi) \sum_{n=1}^{\infty}\frac{ (-1)^n \cos(nx) }{\pi(n^2 + 1)} 
$$ 

Now we can evaluate this for $x \to \pm\pi$. To be more precise (see the answer by @kvantour), the evaluation $x \to \pm\pi$ corresponds to the average of the two values at $\pm\pi$ which is exactly what the Fourier series converges to at this point of discontinuity. 

$$
\cosh (\pm \pi) = \frac{2}{\pi} \sinh(\pi)+ 2 \sinh(\pi) \sum_{n=1}^{\infty}\frac{1 }{\pi(n^2 + 1)} 
$$ 

and in turn

$$
\sum_{n=1}^{\infty}\frac{1 }{(n^2 + 1)}  = \frac{\pi \coth(\pi) -1}{2  }
$$ 

Then the second question follows:
$$
\sum_{- \infty}^{+ \infty} \frac{1}{n^2 + 1} = 1 + 2 \sum_{1}^{+ \infty} \frac{1}{n^2 + 1} = \pi \coth(\pi) \simeq 1.0037 \; \pi
$$

Comment: for comparison,
$$
\int_{- \infty}^{+ \infty} \frac{1}{x^2 + 1} {\rm{dx}} = \pi
$$
Try using Parseval's theorem,

$$\frac{1}{\pi}\int_{-\pi}^\pi |f(x)|^2 dx = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n^2+b_n^2$$

If it comes out too nasty, then I think your coeffecients might be off.