The equation/formula $$ \frac{\pi^2}{12} = \sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n^2}$$ is to be derived.
I know that the Fourier expansion of $f(x)=x$ for $x \in (-\pi,\pi)$ is $$f(x)=x=\sum_{n=1}^{\infty} \frac{2\,(-1)^{n+1}}{n}\,\sin{nx}$$ and there was an example of how for $x=\frac{\pi}{2}$ you'd get $\frac{\pi}{4} = 1-\frac{1}{3}+\frac{1}{5}- \cdots = \sum_{l=0}^\infty \frac{(-1)^{l}}{2l+1}$, but here it's not the square of $n$. I got a Fourier series for $$f_1(x)=x^2=\sum_{n=1}^{\infty} \frac{4\,(-1)^n}{n^2}\,\cos{nx}$$ but then the exponent of the $(-1)$ isn't the same.
I'm obviously missing something, so any hints are appreciated.
We have that: $$ \sum_{n\geq 1}\frac{2(-1)^{n+1}}{n}\,\sin(nx) $$ is the Fourier series of the $2\pi$-periodic extension of $f(x)=x$, so, by termwise integration, $$\begin{eqnarray*} \forall x\in(-\pi,\pi),\qquad x^2&=&\sum_{n\geq 1}\frac{4(-1)^{n+1}}{n^2}\left(1-\cos(nx)\right)\\&=&\color{blue}{\left(\sum_{n\geq 1}\frac{4(-1)^{n+1}}{n^2}\right)}-\sum_{n\geq 1}\frac{4(-1)^{n+1}}{n^2}\cos(nx)\end{eqnarray*}$$ and it follows that the blue term is the mean value of the function $g(x)=x^2$ over the interval $(-\pi,\pi)$, so: $$\color{blue}{\sum_{n\geq 1}\frac{4(-1)^{n+1}}{n^2}}=\frac{1}{2\pi}\int_{-\pi}^{\pi}x^2\,dx = \color{blue}{\frac{\pi^2}{3}}$$ and
readily follows.