Fourier Series/Absolute Value of x over Minus Pi to Pi

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

Proof
By definition, the absolute value function is an even function:


 * $\left\vert{-x}\right\vert = x = \left\vert{x}\right\vert$

Thus by Fourier Series for Even Function over Symmetric Range, $\left\vert{x}\right\vert$ can be expressed as:


 * $\displaystyle \left\vert{x}\right\vert \sim \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty a_n \cos n x$

where for all $n \in \Z_{\ge 0}$:
 * $a_n = \displaystyle \frac 2 \pi \int_0^\pi \left\vert{x}\right\vert \cos n x \rd x$

On the real interval $\left[{0 \,.\,.\, \pi}\right]$:
 * $\left\vert{x}\right\vert = x$

and so for all $n \in \Z_{\ge 0}$:
 * $a_n = \displaystyle \frac 2 \pi \int_0^\pi x \cos n x \rd x$

Thus Fourier Cosine Series for $x$ over $\left[{0 \,.\,.\, \pi}\right]$ can be applied directly.

So for $x \in \left[{-\pi \,.\,.\, \pi}\right]$


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