Deriving formula from Fourier series: $\frac{\pi^2}{12} = \sum\limits_{n=1}^{\infty} \frac{(-1)^{n+1}}{n^2}$ 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.
 A: 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

$$\sum_{n\geq 1}\frac{(-1)^{n+1}}{n^2}=\color{red}{\frac{\pi^2}{12}}$$

readily follows.
A: 
This does not directly answer the question posed in the OP regarding the use of Fourier Series to prove that 
$$\frac{\pi^2}{12}=\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n^2} \tag 1$$
But, I thought it might be instructive to present an approach that relies only on the Basel Problem
$$\frac{\pi^2}{6}=\sum_{n=1}^\infty \frac{1}{n^2} \tag 2$$
which was proven by Euler without use of Fourier Series.  To that end, we proceed.

Note that we can write the series in $(1)$ as 
$$\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n^2}=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right) \tag 3$$
Alongside this result, we can write the series in $(2)$ as 
$$\begin{align}
\frac{\pi^2}{6}&=\sum_{n=1}^\infty \frac{1}{n^2} \\\\
&=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}+\frac{1}{(2n)^2}\right) \\\\
&=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right)+2\sum_{n=1}^\infty\frac{1}{(2n)^2} \\\\
&=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right)+\frac12\sum_{n=1}^\infty\frac{1}{n^2} \\\\
&=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right)+\frac{\pi^2}{12}\\\\
\frac{\pi^2}{12}&=\sum_{n=1}^\infty \left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right)\tag 4
\end{align}$$
Substituting $(4)$ into $(3)$ yields the coveted result.
A: I believe you have an error in the Fourier series for the function $ f(x)=x^2 $. 
Recall that the real Fourier series can be written
$$ \frac{a_0}2+\sum_{n=1}^\infty[a_n\cos(nx)+b_n\sin(nx) ] $$
Where $$ a_n=\frac{1}\pi  \int_{-\pi}^\pi f(x)\cos(nx)dx $$
$$ b_n=\frac{1}\pi \int_{-\pi}^\pi f(x)\sin(nx)dx  $$
For even functions $f(-x)=f(x), b_n=0 $, for all $n\in\mathbb{N} $. 
For $f(x)=x^2$, $a_0$ is not equal to $ 0 $, as you have:
$$ a_0=\frac{1}\pi \int_{-\pi}^\pi x^2dx = \frac{1}{3\pi}[x^3]_{-\pi}^{\pi}=\frac{2}{3}\pi^2  $$
Hence (and by using your correct formula for $a_n$ for positive $n$):
$$f(x)=x^2=\frac{\pi^2}3+4\sum_{n=1}^{\infty}\frac{(-1)^n}{n^2}\cos(nx) $$
Now, evaluate this expression at $x=0$ to get the formula for $\frac{\pi^2}{12}$:
$$0=\frac{\pi^2}3+4\sum_{n=1}^{\infty}\frac{(-1)^n}{n^2} $$
$$\Rightarrow \frac{\pi^2}{12}=-\sum_{n=1}^{\infty}\frac{(-1)^n}{n^2}=\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n^2} $$
A: 
Another way forward relies on Parseval's Identity.  

Using the Fourier Series for $x$ on $[-\pi,\pi]$ as given by
$$x=\sum_{n=1}^{\infty}\frac{2(-1)^{n+1}}{n}\sin(nx)$$
Parseval's Identity reveals
$$\frac{1}{2\pi}\int_{-\pi}^{\pi}x\,dx=\frac12 \sum_{n=1}^{\infty}\left(\frac{(-1)^{n+1}2}{n}\right)^2$$
from which we find that
$$\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{6} \tag 1$$
Now, we use $(1)$ to find the series of interest.  We have
$$\begin{align}
\sum_{n=1}^{\infty}\frac{(-1)^{n-1}}{n^2}&=\sum_{n=1}^{\infty}\left(\frac{1}{(2n-1)^2}-\frac{1}{(2n)^2}\right)\\\\
&=\sum_{n=1}^{\infty}\left(\frac{1}{(2n-1)^2}+\frac{1}{(2n)^2}-\frac{2}{(2n)^2}\right)\\\\
&=\sum_{n=1}^{\infty}\frac{1}{n^2}-\frac12 \sum_{n=1}^{\infty} \frac{1}{n^2}\\\\
&=\frac12 \sum_{n=1}^{\infty} \frac{1}{n^2}\\\\
&=\frac{\pi^2}{12}
\end{align}$$
as was to be shown!
A: Consider the Riemann zeta function: $$\zeta(s)=1+\frac1{2^s}+\frac1{3^s}+\frac1{4^s}+\ldots +\frac1{n^s}+...$$
$$\frac2{2^s}\zeta(s)=\frac2{2^s}+\frac2{4^s}+\frac2{6^s}+\ldots+\frac2{(2n)^s}+...$$
subtracting $2$nd line from the first we get
$$\zeta(s)\left(1-\frac2{2^s}\right)=1-\frac1{2^s}+\frac1{3^s}-\frac1{4^s}+\ldots +(-1)^{n+1}\cdot \frac1{n^s}+...$$
Substitute $s=2$ in the above equation
we get
$$\frac12 \cdot \zeta(2)=1-\frac1{2^s}+\frac1{3^s}-\frac1{4^s}+\ldots+(-1)^{n+1}\cdot \frac1{n^s}+\ldots$$
$\zeta(2)$ is well known as $\frac{\pi^2}6$ due to Euler
so the RHS$=\frac{\pi^2}{12}$
