Half-Range Fourier Cosine Series/Identity Function/0 to Pi

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


 * $f \left({x}\right) = x$

Then its Fourier series can be expressed as:

Proof
By definition of half-range Fourier cosine series:


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

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

Thus by definition of $f$:

For $n > 0$:

When $n$ is even, $\left({-1}\right)^n = 1$.

We can express $n = 2 r$ for $r \ge 1$.

Hence in that case:

When $n$ is odd, $\left({-1}\right)^n = -1$.

We can express $n = 2 r - 1$ for $r \ge 1$.

Hence in that case:

Finally: