There are lots of tutorials about Fourier series online...
google found these for me:
http://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Freq/Freq4.html
http://www.ecst.csuchico.edu/~amk/foo/grads/java/loyd/
http://www.falstad.com/fourier/
http://en.wikipedia.org/wiki/Fourier_series
To make the calculations easier let's consider the case where the
repeat-period L=2 Pi, then the formula for the Fourier coefficient a_m is:
1/Sqrt[2 Pi] Integrate[f[x] Exp[-I m x],{x,0,2 Pi}]
Note that since the function is periodic, we are free to select a more centered
interval: (-Pi,Pi):
1/Sqrt[2 Pi] Integrate[f[x] Exp[-I m x],{x,-Pi,Pi}]
Find formulas for the Fourier coefficents for the functions:
1) f(x)=0 except in the range (-c,c) where it is 1,
i.e., a symmetric square unit-high pulse that happens around x=0
Note that since this function is real and symmetric we expect
a_m to be real, which means an expansion with just Cos (no Sin).
2) f(x)=0 except in the range (-c,c) where it equals Cos[Pi x/(2 c)]
i.e., a symmetric unit-high cosine pulse that happens around x=0
and smothly goes to zero at x=+-c (as Cos[Pi/2]=0).
Note that since this function is real and symmetric we expect
a_m to be real, which means an expansion with just Cos (no Sin).
For one of these cases find numerical values for the first four
a_m that are non-zero in the case c=Pi/2 and convert the series to
Cosine form and plot the resulting four-term sum in the range (-2 Pi,2 Pi).