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

Theorem
Let $f \left({x}\right)$ be the real function defined on $\left({0 \,.\,.\, 2 \pi}\right)$ as:


 * $f \left({x}\right) = \begin{cases} \left({x - \pi}\right)^2 & : 0 < x \le \pi \\ \pi^2 & : \pi < x < 2 \pi \end{cases}$

Then its Fourier series can be expressed as:


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

Proof
By definition of Fourier series:


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

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: