Fourier Series/Square of x minus pi, Square of pi

Theorem
Let $\map f x$ be the real function defined on $\openint 0 {2 \pi}$ as:


 * $\map f x = \begin{cases} \paren {x - \pi}^2 & : 0 < x \le \pi \\ \pi^2 & : \pi < x < 2 \pi \end{cases}$

Then its Fourier series can be expressed as:


 * $\map f x \sim \displaystyle \frac {2 \pi^2} 3 + \sum_{n \mathop = 1}^\infty \paren {\frac {2 \cos n x} {n^2} + \paren {\frac {\paren {-1}^n \pi} n + \frac {2 \paren {\paren {-1}^n - 1} } {\pi n^3} } \sin n x}$

Proof
By definition of Fourier series:


 * $\displaystyle \map f x \sim \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty \paren {a_n \cos n x + b_n \sin n x}$

where:

for all $n \in \Z_{>0}$.

Thus:

For $n > 0$:

Splitting this up into bits:

Reassembling $a_n$ from the remaining non-vanishing terms:

Now for the $\sin n x$ terms:

Splitting this up into bits:

Reassembling $b_n$ from the remaining non-vanishing terms:

Finally: