Here is a Maple worksheet to illustrate the Fourier Series approximation of a Triangle Wave. If you don't want to copy the lines below, you can click here to download the source file (very small, and zipped). On the page below, the red lines are the crutial Maple lines .. the green lines are just comments to help clarify what is being done.
> restart;
with(plots):
> m:=10: # Number
of terms to keep
> # calculate the array of f(x) terms -
one for each term up to M (successively smaller!)
> # myseq[1] = the first term of the
fourier series
> # myseq[2] = the second term of the
fourier series (smaller than the first) .. etc.
> myseq := seq(
(8/((2*n-1)*(2*n-1)*Pi*Pi))*cos((2*n-1)*Pi*x/2),n=1..m):
# notice only odd terms calculated
> # calculate the array of the sums of
each terms
> myseqsum :=
seq(sum(myseq[nn],nn=1..n),n=1..m):
> # myseqsum[1] = the sum of only ONE
term in series
> # myseqsum[2] = the sum of the first
TWO terms in the series (combined)
> # myseqsum[3] = the sum of the first
THREE terms - looking more like square wave
> # now plot the above sums individually
- animated - shows evolution to the squarewave
> display(seq(plot(myseqsum[i],
x=-1..3,color=blue, thickness=2),i=1..m), insequence=true, title=`Evolution of
Fourier series to Triangle Wave`);
Here is an animation of the sequence as you add more terms to the series .. notice that it quickly starts approaching the triangle wave .. there is no discontinuity as in the Square Wave or the SawTooth Wave. Look at these other pages :
|
|
> # Note: Watch the top corner .. the series will very quickly approach the triangle function - there is no "ringing" of the Gibb's Phenomena as in the Square Wave.