Example 15
Fourier Series
GIVEN: a function of x
REQUIRED: Fourier sine series.
SOLUTION:Generate example15.nb
Block[{f,a,b,s,coeff,plot1,plot2,output},
f[x_] = Input["\n
Enter the function f
\n
\n"];
a = Input["\n
Enter the lef endpoint of the interval
\n
\n"];
b = Input["\n
Enter the right endpoint of the interval
\n
\n"];
c[n_] :=2/(b-a) N[Integrate[f[t]Sin[n Pi t/(b-a)],
{t, a, b}]];
coeff = Table[c[i], {i, 1, n}];
s[x_] = Sum[coeff[[i]]Sin[i Pi x/(b-a)], {i, 1, n}];
Print[""];
Print["The coefficients are"];
Print[""];
Print[coeff];
Print[""];
stringn = ToString[n];
stringf = ToString[f[x]];
llabel = StringJoin["The graph of the ",stringn,
"-th ","partial sum of ", stringf];
Print["llabel"];
Print[""];
plot1 = Plot[f[x], {x, a, b}, DisplayFunction -> Identity];
plot2 = Plot[s[x], {x, a, b}, DisplayFunction -> Identity];
output = Show[plot1, plot2, DisplayFunction -> $DisplayFunction];
Example
The coefficients are:
Table[c[i],{i,1,n}]
Homework:
Please send questions or suggestions about this web page to beatnic@aset.psu.edu
ASET | ITS | Penn State
|