Using Fourier series to calculate infinite series. I am asked to devolop the function $f(x)=x^2$ in a series of sine and cosine (Fourier series) in the interval $[\frac{-1}{2},\frac{1}{2}]$. And use one of these series to calculate $$\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n^2} \space\space\space \sum_{n=1}^{\infty} \frac{1}{n^2}$$
Now, the Fourier series is
$S(f)(x)=a_0+2\sum_{n=1}^{\infty}a_ncos(2\pi nx)+2\sum_{n=1}^{\infty}b_nsin(2\pi nx)$
Since $f(x)=x^2$ is even, $b_n=0$. I understand this means that I have to use the cosine series the infinite series.
Using $a_0=\int_{0}^{1} f(x) dx$ and $a_n=\int_{0}^{1} f(x)cos(2\pi nx) dx$
I got that $S(f)(x)=\frac{1}{12}+2\sum_{n=1}^{\infty}\frac{(-1)^n}{\pi^2n^2}cos(2\pi nx)$
Now, how can I calculate the initial series?

The function $x^2$ is an even function in the given interval, $[\frac{-1}{2},\frac{1}{2}]$, thus the sine terms will vanish.
I calculated the Fourier series to be:
$$f(x)=x^2=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}cos({2\pi}nx)}$$
NOTE: There is a mistake in your equation above where you multiplied the summation by 2.

*

*In solving for $\sum_{n=1}^\infty {\frac{(-1)^{n+1}}{n^2}}$:
Let $x=0$. The Fourier series becomes:
$$f(0)=(0)^2=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}cos({2\pi}n{0})}$$
Simplifying:
$$0=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}cos(0)} = \frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}}$$
Multiplying by $-1$ gives:
$$0=-\frac{1}{12}-\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}} = -\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^{n+1}}{\pi^2n^2}}$$
Simplifying further:
$$\sum_{n=1}^\infty {\frac{(-1)^{n+1}}{\pi^2n^2}}=\frac{1}{12}$$
Finally, multiplying throughout by $\pi^2$ gives:
$$\sum_{n=1}^\infty {\frac{(-1)^{n+1}}{n^2}}=\frac{\pi^2}{12}$$


*In solving for $\sum_{n=1}^\infty {\frac{1}{n^2}}$:
If we substitute for $x=\frac{1}{2}$, the Fourier series gives:
$$f(\frac{1}{2})=(\frac{1}{2})^2=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}cos({2\pi}n\frac{1}{2})}$$
Simplifying:
$$\frac{1}{4}=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}cos(n\pi)} = \frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}(-1)^n}$$
But
$$\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^n}{\pi^2n^2}(-1)^n}=\frac{1}{12}+\sum_{n=1}^\infty {\frac{(-1)^{2n}}{\pi^2n^2}}=\frac{1}{12}+\sum_{n=1}^\infty {\frac{1}{\pi^2n^2}}$$
Therefore
$$\frac{1}{4}=\frac{1}{12}+\sum_{n=1}^\infty {\frac{1}{\pi^2n^2}}$$
Again simplifying gives:
$$\frac{1}{6}=\sum_{n=1}^\infty {\frac{1}{\pi^2n^2}}$$
And finally, multiplying both sides by $\pi^2$ gives:
$$\frac{\pi^2}{6}=\sum_{n=1}^\infty {\frac{1}{n^2}}$$
