# Fourier Series/1 over -1 to 0, Cosine of 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:

 $\displaystyle a_n$ $=$ $\displaystyle \int_{-1}^1 f \left({x}\right) \cos n \pi x \, \mathrm d x$ $\displaystyle b_n$ $=$ $\displaystyle \int_{-1}^1 f \left({x}\right) \sin n \pi x \, \mathrm d x$

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

Thus:

 $\displaystyle a_0$ $=$ $\displaystyle \int_{-1}^1 f \left({x}\right) \, \mathrm d x$ Cosine of Zero is One $\displaystyle$ $=$ $\displaystyle \int_{-1}^0 1 \, \mathrm d x + \int_0^1 \cos \left({\pi x}\right) \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \bigg[{x}\bigg]_{-1}^0 + \left[{\frac {\sin \left({\pi x}\right)} \pi}\right]_0^1$ Primitive of Power, Primitive of $\cos \pi x$ $\displaystyle$ $=$ $\displaystyle \left({0 - \left({-1}\right)}\right) - \left({\frac {\sin \pi} \pi - \frac {\sin 0} \pi}\right)$ $\displaystyle$ $=$ $\displaystyle 1 - 0$ Sine of Multiple of Pi $\displaystyle$ $=$ $\displaystyle 1$

$\Box$

For $n > 0$:

 $\displaystyle a_n$ $=$ $\displaystyle \int_{-1}^1 f \left({x}\right) \cos n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \int_{-1}^0 \cos n \pi x \, \mathrm d x + \int_0^1 \cos \pi x \cos n \pi x \, \mathrm d x$ Definition of $f$

Splitting this up into bits:

 $\displaystyle$  $\displaystyle \int_{-1}^0 \cos n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {\sin n \pi x} {n \pi} }\right]_{-1}^0$ Primitive of $\cos n \pi x$ $\displaystyle$ $=$ $\displaystyle \left({\frac {\sin 0} {n \pi} }\right) - \left({\frac {\sin \left({- n \pi}\right)} {n \pi} }\right)$ $\displaystyle$ $=$ $\displaystyle 0$ Sine of Multiple of Pi

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:

 $\displaystyle$  $\displaystyle \int_0^1 \cos \pi x \cos n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {\sin \left({\pi - n \pi}\right) x} {2 \left({\pi - n \pi}\right)} + \frac {\sin \left({\pi + n \pi}\right) x} {2 \left({\pi + n \pi}\right)} }\right]_0^1$ Primitive of $\cos \pi x \cos n \pi x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {\sin \left({1 - n}\right) \pi x} {2 \left({1 - n}\right) \pi} + \frac {\sin \left({1 + n}\right) \pi x} {2 \left({\left({1 + n}\right) \pi}\right)} }\right]_0^1$ $\displaystyle$ $=$ $\displaystyle \left({\frac {\sin \left({1 - n}\right) \pi} {2 \left({1 - n}\right) \pi} + \frac {\sin \left({1 + n}\right) \pi} {2 \left({\left({1 + n}\right) \pi}\right)} }\right) - \left({\frac {\sin 0} {2 \left({1 - n}\right) \pi} + \frac {\sin 0} {2 \left({\left({1 + n}\right) \pi}\right)} }\right)$ $\displaystyle$ $=$ $\displaystyle 0 - 0$ Sine of Multiple of Pi $\displaystyle$ $=$ $\displaystyle 0$

Now let $n = 1$.

We have:

 $\displaystyle$  $\displaystyle \int_0^1 \cos \pi x \cos \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \int_0^1 \cos^2 \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac x 2 + \frac {\sin 2 \pi x} {4 \pi} }\right]_0^1$ Primitive of $\cos^2 \pi x$ $\displaystyle$ $=$ $\displaystyle \left({\frac 1 2 + \frac {\sin 2 \pi} {4 \pi} }\right) - \left({\frac 0 2 + \frac {\sin 0} {4 \pi} }\right)$ $\displaystyle$ $=$ $\displaystyle \left({\frac 1 2 + 0}\right) - \left({0 + 0}\right)$ Sine of Multiple of Pi $\displaystyle$ $=$ $\displaystyle \frac 1 2$

There is only one non-vanishing term:

$a_1 = \dfrac 1 2$

$\Box$

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

 $\displaystyle b_n$ $=$ $\displaystyle \int_{-1}^1 f \left({x}\right) \sin n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \int_{-1}^0 \sin n \pi x \, \mathrm d x + \int_0^1 \cos \pi x \sin n \pi x \, \mathrm d x$

Splitting this up into bits:

 $\displaystyle$  $\displaystyle \int_{-1}^0 \sin n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {-\cos n \pi x} {n \pi} }\right]_{-1}^0$ Primitive of $\sin n \pi x$ $\displaystyle$ $=$ $\displaystyle \left({\frac {-\cos 0} {n \pi} }\right) - \left({\frac {-\cos \left({-n \pi}\right) } {n \pi} }\right)$ $\displaystyle$ $=$ $\displaystyle \left({-\frac 1 {n \pi} }\right) - \left({-\frac {\left({-1}\right)^n} {n \pi} }\right)$ Cosine of Multiple of Pi $\displaystyle$ $=$ $\displaystyle \left({-\frac 1 {n \pi} }\right) + \left({\frac {\left({-1}\right)^n} {n \pi} }\right)$

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

First let $n > 1$.

 $\displaystyle$  $\displaystyle \int_0^1 \cos \pi x \sin n \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {-\cos \left({n \pi - \pi}\right) x} {2 \left({n \pi - \pi}\right)} - \frac {\cos \left({n \pi + \pi}\right) x} {2 \left({n \pi + \pi}\right)} }\right]_0^1$ Primitive of $\cos \pi x \sin n \pi x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {-\cos \left({n - 1}\right) \pi x} {2 \left({n - 1}\right) \pi} - \frac {\cos \left({n + 1}\right) \pi x} {2 \left({n + 1}\right) \pi} }\right]_0^1$ $\displaystyle$ $=$ $\displaystyle \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) - \left({\frac {-\cos 0} {2 \left({n - 1}\right) \pi} - \frac {\cos 0} {2 \left({n + 1}\right) \pi} }\right)$ $\displaystyle$ $=$ $\displaystyle \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) - \left({\frac {-1} {2 \left({n - 1}\right) \pi} - \frac 1 {2 \left({n + 1}\right) \pi} }\right)$ Cosine of Zero is One $\displaystyle$ $=$ $\displaystyle \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}$ some simplification

Now let $n = 1$.

 $\displaystyle$  $\displaystyle \int_0^1 \cos \pi x \sin \pi x \, \mathrm d x$ $\displaystyle$ $=$ $\displaystyle \left[{\frac {\sin^2 \pi x} {2 \pi} }\right]_0^1$ Primitive of $\cos \pi x \sin \pi x$ $\displaystyle$ $=$ $\displaystyle \left({\frac {\sin^2 \pi} {2 \pi} }\right) - \left({\frac {\sin^2 \pi 0} {2 \pi} }\right)$ $\displaystyle$ $=$ $\displaystyle 0 - 0$ Sine of Multiple of Pi $\displaystyle$ $=$ $\displaystyle 0$

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}$

$\Box$

Finally:

 $\displaystyle f \left({x}\right)$ $\sim$ $\displaystyle \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty \left({a_n \cos n x + b_n \sin n x}\right)$ $\displaystyle$ $=$ $\displaystyle \dfrac 1 2 + \frac {\cos \pi x} 2 + \sum_{n \mathop = 1}^\infty \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} \sin n \pi x$ substituting for $a_0$, $a_n$ and $b_n$ from above $\displaystyle$ $=$ $\displaystyle ...$

$\blacksquare$