Fourier Series: $-\pi< x< \pi$
$\begin{array}{rcl} f(x) & \sim & \frac12 a_0 + a_1 \cos x + a_2 \cos 2x + a_3 \cos 3x + \cdots \\
&& \mm + b_1 \sin x + b_2 \sin 2x + b_3 \sin 3x + \cdots \end{array}$
$\mm\mm $ $a_n = \frac1\pi\int_{-\pi}^\pi f(x) \cos nx dx $
$\mm\mm $ $b_n = \frac1\pi\int_{-\pi}^\pi f(x) \sin nx dx $
The example we did during the lecture:
$f(x) = \left\{ \begin{array}{ll} 0, & -\pi < x \le 0 \\ 1, & 0 < x <\pi \end{array}\right.$
$f(x) \sim \frac12 +\frac2\pi\Big( \frac{\sin x}1 + \frac{\sin 3x}3 + \frac{\sin 5x}5+\cdots \Big)$
N = 100;
x = -pi:.01:pi;
f = ones(1,length(x))*0.5;
for i = 1:2:N
f = f + (2/(pi*i)) * sin(i*x);
end
plot(x,f)