Fourier Series/1 over -1 to 0, Cosine of Pi x over 0 to 1

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


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

1 & : -1 < x < 0 \\ \cos \left({\pi x}\right) & : 0 < x < 1 \end{cases}$

Then its Fourier series can be expressed as:


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

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 \pi x + b_n \sin n \pi x}\right)$

where:

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

Thus:

For $n > 0$:

Splitting this up into bits:

For $n \ne 0$, there are two cases that need to be addressed: when $n = 1$ and when $n > 1$.

First let $n > 1$.

We have:

Now let $n = 1$.

We have:

There is only one non-vanishing term:


 * $a_1 = \dfrac 1 2$

Now for the $\sin n \pi x$ terms:

Splitting this up into bits:

For $0 < x < 1$, there are two cases that need to be addressed: when $n = 1$ and when $n > 1$.

First let $n > 1$.

Now let $n = 1$.

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


 * $b_n = \displaystyle \left({-\frac 1 {n \pi} }\right) + \left({\frac {\left({-1}\right)^n} {n \pi} }\right) + \left({\frac {-\cos \left({n - 1}\right) \pi} {2 \left({n - 1}\right) \pi} - \frac {\cos \left({n + 1}\right) \pi} {2 \left({n + 1}\right) \pi} }\right) + \frac 1 {2 \left({n - 1}\right) \pi} - \frac 1 {2 \left({n + 1}\right) \pi}$

Finally: