Reza Malek-Madani

Fourier Sine Series

Here is how one determines the Fourier sine series of the function f(x) = 1, defined over the interval (0, 2), and plots its partial sums.

(******** *****)

l=2; (* The domain *) 
nn= 20; (* Partial Sum *) 
f[x_] =1 ; (* Function Definition *) 
a[n_]:=Integrate[f[x] Sin[n Pi x/l], {x, 0, l}]; 
coeffs = Table[a[n], {n, 1, nn}]; 
S[n_, x_]:=Sum[2 coeffs[[i]]/l Sin[i Pi x/l], {i, 1, n}]; 
graph1=Plot[f[x], {x, 0, l}]; 
snapshots[i_]:=Plot[S[i,x], {x, 0, l}, DisplayFunction->Identity]; 
Do[ii=ToString[i]; 
        llabel=StringJoin["The function and its ",ii,"-th partial sum"]; 
        Show[graph1,snapshots[i], PlotLabel->llabel, 
        DisplayFunction->$DisplayFunction, PlotRange->All], 
{i, 5, nn, 5}] 
[Graphics:fourier1gr2.gif][Graphics:fourier1gr1.gif][Graphics:fourier1gr2.gif][Graphics:fourier1gr3.gif][Graphics:fourier1gr2.gif][Graphics:fourier1gr4.gif][Graphics:fourier1gr2.gif][Graphics:fourier1gr5.gif][Graphics:fourier1gr2.gif][Graphics:fourier1gr6.gif]

go to Top