MATH 373 -- Applied Mathematics (PDE)

February 20, 2001 -- First examples of Fourier Series

A) Consider the function f(x) = - 1 if [Maple Math] <= x < 0, and 1 if 0 <= x <= [Maple Math]

The Fourier coefficients are given by

> assume(n,integer);

> f := x->piecewise(x<0,-1,1):

> af := n->int(f(x)*cos(n*x),x=-Pi..Pi)/Pi;

[Maple Math]

Since f is an odd function, [Maple Math] for all n >= 0:

> af(n);

[Maple Math]

> bf := n->int(f(x)*sin(n*x),x=-Pi..Pi)/Pi;

[Maple Math]

> bf(n);

[Maple Math]

To visualize the Fourier series, we can plot partial sums:

> PSf:=(N,x)->add(bf(n)*sin(n*x),n=1..N);

Warning, `n` in call to `add` is not local

[Maple Math]

> plot({f(x),PSf(10,x)},x=-Pi..Pi);

B) Now, consider g(x) = [Maple Math] on [Maple Math]

> g:=x -> x^2;

[Maple Math]

> ag := n->int(g(x)*cos(n*x),x=-Pi..Pi)/Pi;

[Maple Math]

> ag(0);

[Maple Math]

> ag(n);

[Maple Math]

> bg := n->int(g(x)*sin(n*x),x=-Pi..Pi)/Pi;

[Maple Math]

Now, the [Maple Math] coefficients are zero, because g is even.

> bg(n);

[Maple Math]

To visualize the Fourier series, we can plot partial sums:

> PSg:=(N,x)->ag(0)/2+add(ag(n)*cos(n*x),n=1..N);

Warning, `n` in call to `add` is not local

[Maple Math]

> plot({g(x),PSg(5,x)},x=-Pi..Pi);

Note that the approximation to the function g given by the partial sum of the

Fourier series seems much closer in this case than in example A.