How do I calculate the value of this series? I want to find the value to which this series converges $$\sum_{n=0}^\infty \frac{(-1)^n}{n^2+1}$$
I tried looking at the sequence of partial sums $$S_k = \sum_{n=0}^k \frac{(-1)^n}{n^2+1}$$ and I noticed that $$\frac{-1}{n^2+1} \leq \frac{(-1)^n}{n^2+1} \leq \frac{1}{n^2 +1}$$ and so I think that by the squeeze rule I can see ( I could have just noticed it by logic, but okay) that the terms converge to zero. How do I find the value of the original series though? I could only show that it converged
 A: You may notice that:
$$ \frac{1}{n^2+1} = \int_{0}^{+\infty}\sin(x)e^{-nx}\,dx\tag{1}$$
from which$^{(*)}$:
$$ S=\sum_{n\geq 0}\frac{(-1)^n}{n^2+1}=1+\int_{0}^{+\infty}\sin(x)\sum_{n\geq 1}(-1)^n e^{-nx}\,dx \tag{2}$$
and:
$$ S = 1-\int_{0}^{+\infty}\frac{\sin(x)}{e^x+1}\,dx =\color{red}{\frac{1}{2}\left(1+\frac{\pi}{\sinh\pi}\right)}\tag{3}$$
where the last equality follows from integration by parts and the residue theorem. The same can be proved by considering the Fourier cosine series of $\cosh(x)$ over the interval $(-\pi,\pi)$.

Yet another (Eulerian) approach. It is clearly enough to compute $\sum_{n\geq 1}\frac{1}{n^2+1}$ and $\sum_{n\geq 1}\frac{1}{4n^2+1}$.
From the Weierstrass product for the $\sinh$ function we have
$$ \frac{\sinh(\pi z)}{\pi z}=\prod_{n\geq 1}\left(1+\frac{z^2}{n^2}\right)\tag{4}$$
and by applying $\frac{d}{dz}\log(\cdot)$ to both sides:
$$ -\frac{1}{z}+\pi\coth(\pi z) = \sum_{n\geq 1}\frac{2z}{z^2+n^2}\tag{5}$$
At last we just need to evaluate the LHS of $(5)$ at $z=1$ and $z=\frac{1}{2}$.

$(*)$ The exchange of $\sum$ and $\int$ is allowed by the absolute convergence of the series $\sum_{n\geq 0}\frac{(-1)^n}{n^2+1}$, the trivial inequality $\left|\sin(x)\right|\leq x$ and the dominated convergence theorem. For any $x>0$ we have
$$ \sum_{n=1}^{N} e^{-nx}\leq \frac{1}{e^x-1} $$
and $\frac{x}{e^x-1}$ is a function belonging to $\mathcal{L}^1(\mathbb{R}^+)$, whose integral over $\mathbb{R}^+$ equals $\zeta(2)=\frac{\pi^2}{6}$.
A: Extend the sum $S$ to
$$ 2S-1 = \sum_{n=-\infty}^{\infty} \frac{(-1)^n}{n^2+1}, $$
which we can get away with because the summand is even in $n$. We want to find something that gives these as residues, then use Cauchy's theorem, hoping the integral goes to zero. Therefore we take
$$ \frac{\pi\csc{\pi z}}{z^2+1}: $$
this has poles at $z=n$ with residue $ (-1)^n/(n^2+1) $, and two others, at $\pm i$, with residues $ \frac{\pi \operatorname{csch}{(\pm \pi)}}{\mp 2i} $. Also, if we take the integral to be around a large square that between the poles, one can show using $ \lvert\sin{(x+iy)} \rvert^2 = \sin^2{x}+\sinh^2{y} $ and the corresponding one for cosine that the integrand is bounded on the border of the square by a multiple of $1/(x^2+y^2)$, and hence the integral tends to zero as we make the square larger and larger. Hence
$$ \frac{1}{2\pi i}\left( 2S_k-1 - \frac{2\pi\operatorname{csch}{\pi}}{2} \right) = \int_{\square_k} \frac{\pi\csc{\pi z}}{z^2+1} \, dz \to 0 $$
as $k \to \infty$, and then you can rearrange to get the answer.

The general idea is that $\pi\cot{\pi z}$ has residue $1$ at every integer $n$, while $\csc{\pi z}$ has residue $(-1)^n$ at every integer $n$. The same technique works on any sum of the form $1/p(n^2)$ (or $(-1)^n/p(n^2)$) where $p$ is a nonconstant polynomial, although you do have to find the roots.
