Worksheet: Gibbs.mw 

Fourier Series and Gibb's Phenomena
 

This worksheet examines the Fourier Series of 


 

F(x)=piecewise(`and`(`<`(0, x), `<`(x, Pi)), 1, `and`(`<`(`+`(`-`(Pi)), x), `<`(x, 0)), -1, 0) 

 

 

 

> restart:with(plots):
 

Least Squares Approximation of The Initial Condition 

Let's approximate the initial condition f(x) with the sum of sines that came from separation of variables. 

> F:=piecewise(0<x and x<Pi,1, -Pi<x and x<0, -1,0);
 

piecewise(`and`(`<`(0, x), `<`(x, Pi)), 1, `and`(`<`(`+`(`-`(Pi)), x), `<`(x, 0)), -1, 0)
 

> plot(F, x=-Pi..Pi,thickness=2, discont=true, thickness=2);
 

Plot_2d
 

> f:=n-> sin (n*x);
 

proc (n) options operator, arrow; sin(`*`(x, `*`(n))) end proc
 

> c:=n->(1/Pi)*int(F*f(n),x=-Pi..Pi);
 

proc (n) options operator, arrow; `/`(`*`(int(`*`(F, `*`(f(n))), x = `+`(`-`(Pi)) .. Pi)), `*`(Pi)) end proc
 

> seq(c[n]=c(n),n=1..10);
 

c[1] = `+`(`/`(`*`(4), `*`(Pi))), c[2] = 0, c[3] = `+`(`/`(`*`(`/`(4, 3)), `*`(Pi))), c[4] = 0, c[5] = `+`(`/`(`*`(`/`(4, 5)), `*`(Pi))), c[6] = 0, c[7] = `+`(`/`(`*`(`/`(4, 7)), `*`(Pi))), c[8] = 0, ...
 

> g:= M->sum(c(m)*sin(m*x),m=1..M);
 

proc (M) options operator, arrow; sum(`*`(c(m), `*`(sin(`*`(m, `*`(x))))), m = 1 .. M) end proc
 

> h:=g(10);
 

`+`(`/`(`*`(4, `*`(sin(x))), `*`(Pi)), `/`(`*`(`/`(4, 3), `*`(sin(`+`(`*`(3, `*`(x)))))), `*`(Pi)), `/`(`*`(`/`(4, 5), `*`(sin(`+`(`*`(5, `*`(x)))))), `*`(Pi)), `/`(`*`(`/`(4, 7), `*`(sin(`+`(`*`(7, `...
 

> plot({F,h},x=-Pi..Pi);
 

Plot_2d
 

> s:=seq(g(2*M),M=1..21):
 

> plot({s,F},x=-Pi..Pi);
 

Plot_2d
 

> plot({s,F},x=0..1);
 

Plot_2d
 

Bessel's Inequality and Parseval's Theorem 

Let's compute the (norm)^2 of F(x) and the n-term approximation of F 

> normF:=int(F^2,x=-Pi..Pi); evalf(%);
 

 

`+`(`*`(2, `*`(Pi)))
6.283185308
 

> S:=N->(16/Pi)*sum(1/(2*j-1)^2,j=1..N);
 

proc (N) options operator, arrow; `+`(`/`(`*`(16, `*`(sum(`/`(1, `*`(`^`(`+`(`*`(2, `*`(j)), `-`(1)), 2))), j = 1 .. N))), `*`(Pi))) end proc
 

> seq(evalf(S(n)),n=1..20);
 

5.092958178, 5.658842420, 5.862560747, 5.966498669, 6.029374694, 6.071465259, 6.101601108, 6.124236477, 6.141859169, 6.155967087, 6.167515745, 6.177143263, 6.185291996, 6.192278223, 6.198334059, 6.203...
5.092958178, 5.658842420, 5.862560747, 5.966498669, 6.029374694, 6.071465259, 6.101601108, 6.124236477, 6.141859169, 6.155967087, 6.167515745, 6.177143263, 6.185291996, 6.192278223, 6.198334059, 6.203...
5.092958178, 5.658842420, 5.862560747, 5.966498669, 6.029374694, 6.071465259, 6.101601108, 6.124236477, 6.141859169, 6.155967087, 6.167515745, 6.177143263, 6.185291996, 6.192278223, 6.198334059, 6.203...
5.092958178, 5.658842420, 5.862560747, 5.966498669, 6.029374694, 6.071465259, 6.101601108, 6.124236477, 6.141859169, 6.155967087, 6.167515745, 6.177143263, 6.185291996, 6.192278223, 6.198334059, 6.203...
 

Gibb's Phenomena and the Sine Integral 

We can now compare the partial sums to the Sine Integral 

> h:=x->sin(x)/x;
 

proc (x) options operator, arrow; `/`(`*`(sin(x)), `*`(x)) end proc
 

> plot(h(x),x=0..3*Pi,thickness=2);
 

Plot_2d
 

> SI:=z->int(h(x),x=0..z);
 

proc (z) options operator, arrow; int(h(x), x = 0 .. z) end proc
 

> SI(infinity);SI(Pi)/(Pi/2);evalf(%);
 

 

 

`+`(`*`(`/`(1, 2), `*`(Pi)))
`+`(`/`(`*`(2, `*`(Si(Pi))), `*`(Pi)))
1.178979744
 

> G:=M->(2/Pi)*SI(x*(2*M));
 

proc (M) options operator, arrow; `+`(`/`(`*`(2, `*`(SI(`+`(`*`(2, `*`(x, `*`(M))))))), `*`(Pi))) end proc
 

> M:=11;G(M);
 

 

11
`+`(`/`(`*`(2, `*`(Si(`+`(`*`(22, `*`(x)))))), `*`(Pi)))
 

> plot({g(2*M),G(M)},x=0..Pi,thickness=2);
 

Plot_2d