About HPC Systems Software User Guides Education Partners

  / gears / hpc / education / tutorials / mathematica / win


Introduction

Definition

Example 01

Example 02

Example 03

Example 04

Example 05

Example 06

Example 07

Example 08

Example 09

Example 10

Example 11

Example 12

Example 13

Example 14

Example 15

Example 16

Example 17

Example 18

References

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