Fourier Series/x squared over Minus Pi to Pi

Theorem
For $x \in \left[{- \pi \,.\,.\, \pi}\right]$:
 * $\displaystyle x^2 = \frac {\pi^2} 3 + \sum_{n \mathop = 1}^\infty \left({\left({-1}\right)^n \frac 4 {n^2} \cos n x}\right)$

Proof
By the definition of a Fourier Series, for $x \in \left[{-\pi \,.\,.\, \pi}\right]$:


 * $(1): \quad \displaystyle x^2 = \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty \left({a_n \cos n x + b_n \sin n x}\right)$

where:


 * $\displaystyle a_n = \frac 1 \pi \int_{-\pi}^\pi x^2 \cos \left({n x}\right) \, \mathrm d x$
 * $\displaystyle b_n = \frac 1 \pi \int_{-\pi}^\pi x^2 \sin \left({n x}\right) \, \mathrm d x$

From Even Power is Even Function, $x^2$ is an even function.

Then:
 * by Sine Function is Odd, $\sin \left({n x}\right)$ is an odd function

and
 * by Cosine Function is Even, $\cos \left({n x}\right)$ is an even function.

By Odd Function Times Even Function is Odd:
 * $x^2 \sin \left({n x}\right)$ is an odd function.

Hence by Definite Integral of Odd Function:
 * $b_n = 0$

for all $n$.

By Even Function Times Even Function is Even:
 * $x^2 \cos \left({n x}\right)$ is an even function.

Hence:

Then:

Substituting for $a_n$ in $(1)$:


 * $\displaystyle x^2 = \frac {\pi^2} 3 + \sum_{n \mathop = 1}^\infty \left({\left({-1}\right)^n \frac 4 {n^2} \cos n x}\right)$

as required.