MATH 300 -- Directed Readings: RAAA II
February 1 -- A Fourier Series Example
Example 1)
For the function
on the interval
we saw that the Fourier coefficients were
, and
if
using
and
for integral m!
Because Maple will not assume that
is an integer unless we
tell it to, let's start by doing that:
> assume(m,integer);
Then we compute the value of the Fourier coefficient
using the
int (integrate) command:
> a[m] := (1/Pi)*int(x^2*cos(m*x),x=-Pi..Pi);
Similarly,
> b[m] := (1/Pi)*int(x^2*sin(m*x),x=-Pi..Pi);
Here is the partial sum of the series for m = 0..k :
> FS := k -> Pi^2/3 + sum(a[m]*cos(m*x),m=1..k);
(This is set up in Maple as function that takes the integer k to the k th partial
sum.)
Plots of the partial sums of the Fourier series, together with
> plot({x^2,FS(2)},x=-Pi..Pi);
> plot({x^2,FS(5)},x=-Pi..Pi);
> plot({x^2,FS(10)},x=-Pi..Pi);
The absolute error if we approximate
by the partial sum of the Fourier series:
> plot(abs(x^2 - FS(10)),x=-Pi..Pi);
This shows good agreement! (The absolute error is always less than .4).