Evaluating sums using residues $(-1)^n/n^2$

This question already has an answer here:

  • Complex Analysis Solution to the Basel Problem ($\sum_{k=1}^\infty \frac{1}{k^2}$) [duplicate]

    4 answers

Solutions Collecting From Web of "Evaluating sums using residues $(-1)^n/n^2$"

Using $\boldsymbol{\pi\csc(\pi z)}$

Since $\pi\csc(\pi z)$ has residue $(-1)^n$ at $z=n$ for $n\in\mathbb{Z}$, we will use the contours
$$
\gamma_\infty=\lim\limits_{R\to\infty}Re^{2\pi i[0,1]}\qquad\text{and}\qquad\gamma_0=\lim\limits_{R\to0}Re^{2\pi i[0,1]}
$$
To sum over all $n\in\mathbb{Z}$ except $n=0$, we use the difference of the contours, which circles the non-zero integers once counter-clockwise.
$$
\begin{align}
2\sum_{n=1}^\infty\frac{(-1)^n}{n^2}
&=\frac1{2\pi i}\left(\int_{\gamma_\infty}\frac{\pi\csc(\pi z)}{z^2}\mathrm{d}z-\int_{\gamma_0}\frac{\pi\csc(\pi z)}{z^2}\mathrm{d}z\right)\\
&=\color{#C00000}{\frac1{2\pi i}\int_{\gamma_\infty}\frac{\pi\csc(\pi z)}{z^2}\mathrm{d}z}-\operatorname*{Res}_{z=0}\left(\color{#00A000}{\frac{\pi\csc(\pi z)}{z^2}}\right)\\
&=\color{#C00000}{0}-\operatorname*{Res}_{z=0}\left(\color{#00A000}{\frac1{z^2}\frac\pi{\pi z-\pi^3z^3/6+O\left(z^5\right)}}\right)\\
&=\color{#C00000}{0}-\operatorname*{Res}_{z=0}\left(\color{#00A000}{\frac1{z^3}+\frac{\pi^2}{6z}+O(z)}\right)\\
&=-\frac{\pi^2}6
\end{align}
$$
because, for $k\in\mathbb{Z}$ and $|z|=\pi\left(k+\frac12\right)$, $|\csc(z)|\le1$.

Therefore,
$$
\sum_{n=1}^\infty\frac{(-1)^n}{n^2}=-\frac{\pi^2}{12}
$$


Extending A Previous Result

In this answer, it is shown that
$$
\sum_{k=1}^\infty\frac1{k^2}=\frac{\pi^2}6
$$
Note that
$$
\begin{align}
\hphantom{=}&\frac1{1^2}{+}\frac1{2^2}+\frac1{3^2}{+}\frac1{4^2}+\frac1{5^2}{+}\frac1{6^2}+\frac1{7^2}+\dots\\
\hphantom{=}&\hphantom{\frac1{1^2}}\color{#C00000}{-\frac2{2^2}\hphantom{+\frac1{3^2}}-\frac2{4^2}\hphantom{+\frac1{5^2}}-\frac2{6^2}\hphantom{+\frac1{7^2}}-\dots}\\
=&\frac1{1^2}{-}\frac1{2^2}+\frac1{3^2}{-}\frac1{4^2}+\frac1{5^2}{-}\frac1{6^2}+\frac1{7^2}-\dots
\end{align}
$$
where the series in red is two times one quarter of the series above it; that is, one half of the series above it. Therefore, the alternating series is one half of the non-alternating series; that is,
$$
\sum_{n=1}^\infty\frac{(-1)^{n-1}}{n^2}=\frac{\pi^2}{12}
$$

For a complex variable $s$, whose real part is greater than zero, the Dirichlet eta function is defined by the series $$\eta(s) := -\sum_{n=1}^{\infty} \frac{(-1)^n}{n^s}.$$

In particular, one has that

$$\eta(s) = \left(1-2^{1-s}\right)\zeta(s),$$

where $\zeta$ denotes the Riemann zeta function. With that in mind, one need only substitute $s=2$ into the above equation. I presume that you are familiar with the famed Basel problem.