# Fourier Series/1 over 0 to 2, x-2 over 2 to 4

## Theorem

Let $\map f x$ be the real function defined on $\openint 0 4$ as:

$\map f x = \begin{cases} 1 & : 0 < x \le 2 \\ x - 2 & : 2 < x < 4 \end{cases}$

Then its Fourier series can be expressed as:

$\map f x \sim \displaystyle 1 + \frac 4 \pi \sum_{n \mathop = 1}^\infty \frac {\paren {-1}^{r - 1} } {2 r - 1} \paren {1 + \frac {4 \paren {-1}^r} {\paren {2 r - 1} \pi} } x \cos \frac {\paren {2 r - 1} \pi x} 4$

## Proof

Let $\map f x$ be the function defined as:

$\forall x \in \openint 0 4: \begin{cases} 1 & : 0 < x \le 2 \\ x - 2 & : 2 < x < 4 \end{cases}$

Let $f$ be expressed by a half-range Fourier cosine series:

$\displaystyle \map f x \sim \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty a_n \cos \frac {n \pi x} 4$

where for all $n \in \Z_{> 0}$:

$a_n = \displaystyle \frac 2 l \int_0^l \map f x \cos \frac {n \pi x} l \rd x$

In this context, $l = 4$ and so this can be expressed as:

 $\displaystyle a_n$ $=$ $\displaystyle \frac 2 4 \paren {\int_0^2 \cos \frac {n \pi x} 4 \rd x + \int_2^4 \paren {x - 2} \cos x \frac {n \pi x} 4 \rd x}$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {\int_0^2 \cos \frac {n \pi x} 4 \rd x + \int_2^4 \paren {x - 2} \cos x \frac {n \pi x} 4 \rd x}$

First the case when $n = 0$:

 $\displaystyle a_0$ $=$ $\displaystyle \frac 1 2 \paren {\int_0^2 \rd x + \int_2^4 \paren {x - 2} \rd x}$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {\bigintlimits x 0 2 + \intlimits {\frac {x^2} 2 - 2 x} 2 4}$ Primitive of Power $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {\paren {2 - 0} + \paren {\paren {\frac {4^2} 2 - 2 \times 4} - \paren {\frac {2^2} 2 - 2 \times 2} } }$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {\paren {2 - 0} + \paren {\paren {\frac {16} 2 - 8} - \paren {\frac 4 2 - 4} } }$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {2 + 0 + 2}$ $\displaystyle$ $=$ $\displaystyle 2$

When $n \ne 0$:

 $\displaystyle a_n$ $=$ $\displaystyle \frac 1 2 \paren {\int_0^2 \cos \frac {n \pi x} 4 \rd x + \int_2^4 \paren {x - 2} \cos \frac {n \pi x} 4 \rd x}$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \paren {\int_0^2 \cos \frac {n \pi x} 4 \rd x + \int_2^4 x \cos \frac {n \pi x} 4 \rd x - 2 \int_2^4 \cos \frac {n \pi x} 4 \rd x}$ Linear Combination of Integrals

Splitting it up into three:

 $\displaystyle$  $\displaystyle \frac 1 2 \int_0^2 \cos \frac {n \pi x} 4 \rd x$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \intlimits {\frac 4 {n \pi} \sin \frac {n \pi x} 4} 0 2$ Primitive of $\cos a x$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \cdot \frac 4 {n \pi} \paren {\sin \frac {2 n \pi} 4 - \sin \frac {0 n \pi} 4}$ $\displaystyle$ $=$ $\displaystyle \frac 2 {n \pi} \paren {\sin \frac {n \pi} 2 - \sin 0}$ simplifying $\displaystyle$ $=$ $\displaystyle \frac 2 {n \pi} \sin \frac {n \pi} 2$ Sine of Zero is Zero

 $\displaystyle$  $\displaystyle \frac 1 2 \int_2^4 x \cos \frac {n \pi x} 4 \rd x$ $\displaystyle$ $=$ $\displaystyle \frac 1 2 \intlimits {\frac {16} {n^2 \pi^2} \cos \frac {n \pi x} 4 + \frac 4 {n \pi} x \sin \frac {n \pi x} 4} 2 4$ Primitive of $x \cos a x$ $\displaystyle$ $=$ $\displaystyle \paren {\frac 8 {n^2 \pi^2} \cos n \pi + \frac 8 {n \pi} \sin n \pi} - \paren {\frac 8 {n^2 \pi^2} \cos \frac {n \pi} 2 + \frac 4 {n \pi} \sin \frac {n \pi} 2}$ $\displaystyle$ $=$ $\displaystyle \frac 8 {n^2 \pi^2} \paren {\cos n \pi - \cos \frac {n \pi} 2} - \frac 4 {n \pi} \sin \frac {n \pi} 2$ Sine of Multiple of Pi and simplification $\displaystyle$ $=$ $\displaystyle \frac 8 {n^2 \pi^2} \paren {\paren {-1}^n - \cos \frac {n \pi} 2} - \frac 4 {n \pi} \sin \frac {n \pi} 2$ Cosine of Multiple of Pi and simplification

 $\displaystyle$  $\displaystyle -\frac 1 2 \paren {2 \int_2^4 \cos \frac {n \pi x} 4 \rd x}$ $\displaystyle$ $=$ $\displaystyle -\intlimits {\frac 4 {n \pi} \sin \frac {n \pi x} 4} 2 4$ Primitive of $\cos a x$ $\displaystyle$ $=$ $\displaystyle -\frac 4 {n \pi} \paren {\sin \frac {4 n \pi} 4 - \sin \frac {2 n \pi} 4}$ $\displaystyle$ $=$ $\displaystyle \frac 4 {n \pi} \paren {\sin \frac {n \pi} 2 - \sin n \pi}$ $\displaystyle$ $=$ $\displaystyle \frac 4 {n \pi} \sin \frac {n \pi} 2$ Sine of Multiple of Pi

Putting it together:

 $\displaystyle a_n$ $=$ $\displaystyle \frac 2 {n \pi} \sin \frac {n \pi} 2 + \frac 8 {n^2 \pi^2} \paren {\paren {-1}^n - \cos \frac {n \pi} 2} - \frac 4 {n \pi} \sin \frac {n \pi} 2 + \frac 4 {n \pi} \sin \frac {n \pi} 2$ $\displaystyle$ $=$ $\displaystyle \frac 2 {n \pi} \paren {\sin \frac {n \pi} 2 + \frac 4 {n \pi} \paren {\paren {-1}^n - \cos \frac {n \pi} 2} }$