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

Proof
By definition of half-range Fourier cosine series:


 * $\displaystyle \map f x \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 \map f x \cos n x \rd x$

Thus by definition of $f$:

For $n > 0$:

When $n$ is even, $\paren {-1}^n = 1$.

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

Hence in that case:

When $n$ is odd, $\paren {-1}^n = -1$.

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

Hence in that case:

Finally: