next up previous
Next: Determining Coefficients in Fourier Up: Fourier Series-What, How, and Why Previous: Fourier Series-What, How, and Why

Examples of Fourier Series

Fourier series are used to represent periodic functions. An example is the Sawtooth function, S(t). In IDL, this would be represented by the lines:

IDL> t=findgen(1024)/32.         ; times ranging from 0 to 32
IDL> S=t/(2*!pi)-fix(t/(2*!pi)) ; sawtooth function

The values of S represent samples of a sawtooth function of t, with a period of 1.0 and a peak-to-peak amplitude of 1.0. One could look for a rough approximation to S(t) using a sine function:

IDL> s1=0.5-0.31831*sin(t)
IDL> plot,t,s
IDL> oplot,t,s1

This function has the same period and it even goes to zero at all the same places as the sawtooth, but it is not a very good approximation except close to multiples of $\pi$. A better approximation is given by:

IDL> s1=0.5 - 0.31831*sin(t) - 0.159155*sin(2*t) - 0.106103*sin(3*t) $

IDL>         -0.0795775*sin(4*t)-0.0636620*sin(5*t);

And an even better approximation is given by a sum with 100 terms:

IDL> c=-1./(!pi*(findgen(100)>1))
IDL> s1=0.5
IDL> for k=1,99 do s1=s1+c(k)*sin(k*t)

If you plot this new function s1(t), you will see that it oscillates around the Sawtooth function. This is partially due to the finite length of the series, but also due to an intrinsic imperfection in Fourier series. Unfortunately, these wiggles do not disappear as the number of terms goes to infinity, although they do become infinitely narrow. This effect, discovered by J.W. Gibbs in 1899, shows that even if Fourier series can be accurate approximations in some regions of the independent variable, they may be inaccurate in the neighborhood of discontinuities.


But how did we find those magic coefficients c(k)?


next up previous
Next: Determining Coefficients in Fourier Up: Fourier Series-What, How, and Why Previous: Fourier Series-What, How, and Why
Ed Schmahl
1999-07-01