Worksheet: fcs.mw 

Fourier Cosine  Series 

 

This worksheet examines the convergence of the Fourier cosine series for : 

 

y=|x|       - π < x< π 

 

A Fourier Cosine Series 

> restart:
 

> f:=abs(x);
 

abs(x) (1.1)
 

> plot(f, x=-Pi..Pi);
 

Plot_2d
 

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

`+`(`/`(`*`(2, `*`(`+`(cos(`*`(Pi, `*`(n))), `*`(n, `*`(sin(`*`(Pi, `*`(n))), `*`(Pi))), `-`(1)))), `*`(`^`(n, 2), `*`(Pi)))) (1.2)
 

> assume(n,integer);#Letting MAPLE know n is an integer simplifies the calculation
an:=int(f*cos(n*x),x=-Pi..Pi)/(Pi);
 

`+`(`/`(`*`(2, `*`(`+`(`^`(-1, n), `-`(1)))), `*`(`^`(n, 2), `*`(Pi)))) (1.3)
 

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

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

> seq(A(n),n=1..10);
 

`+`(`-`(`/`(`*`(4), `*`(Pi)))), 0, `+`(`-`(`/`(`*`(`/`(4, 9)), `*`(Pi)))), 0, `+`(`-`(`/`(`*`(`/`(4, 25)), `*`(Pi)))), 0, `+`(`-`(`/`(`*`(`/`(4, 49)), `*`(Pi)))), 0, `+`(`-`(`/`(`*`(`/`(4, 81)), `*`(P... (1.5)
 

> g:= M->A(0)/2 +sum(A(n)*cos(n*x),n=1..M);
 

proc (M) options operator, arrow; `+`(`*`(`/`(1, 2), `*`(A(0))), sum(`*`(A(n), `*`(cos(`*`(n, `*`(x))))), n = 1 .. M)) end proc (1.6)
 

> h:=g(3);
 

`+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi))), `-`(`/`(`*`(`/`(4, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(Pi)))) (1.7)
 

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

Plot_2d
 

> s:=seq(g(2*M+1),M=0..4);
 

`+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi)))), `+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi))), `-`(`/`(`*`(`/`(4, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(Pi...
`+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi)))), `+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi))), `-`(`/`(`*`(`/`(4, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(Pi...
`+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi)))), `+`(`*`(`/`(1, 2), `*`(Pi)), `-`(`/`(`*`(4, `*`(cos(x))), `*`(Pi))), `-`(`/`(`*`(`/`(4, 9), `*`(cos(`+`(`*`(3, `*`(x)))))), `*`(Pi...
(1.8)
 

> plot({s,f},x=-3*Pi..3*Pi);
 

Plot_2d
 

> plot({s,f},x=0..0.5,y=0..0.5);
 

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 

> norm2:=h->int(h^2,x=-Pi..Pi);
 

proc (h) options operator, arrow; int(`*`(`^`(h, 2)), x = `+`(`-`(Pi)) .. Pi) end proc (2.1)
 

Compute the L^2 norm of f 

> f2:=norm2(f);
 

`+`(`*`(`/`(2, 3), `*`(`^`(Pi, 3)))) (2.2)
 

And now compare it to the n-term approximation for n=1 to 20. Note the difference is always positive (as a result of Bessel's inequality) and converges to zero (as a result of Parseval's Theorem). 

> E2:=seq(evalf(f2-norm2(g(N))),N=1..20);
 

0.7475461e-1, 0.7475461e-1, 0.1187858e-1, 0.1187858e-1, 0.372985e-2, 0.372985e-2, 0.160867e-2, 0.160867e-2, 0.83241e-3, 0.83241e-3, 0.48456e-3, 0.48456e-3, 0.30624e-3, 0.30624e-3, 0.20563e-3, 0.20563e...
0.7475461e-1, 0.7475461e-1, 0.1187858e-1, 0.1187858e-1, 0.372985e-2, 0.372985e-2, 0.160867e-2, 0.160867e-2, 0.83241e-3, 0.83241e-3, 0.48456e-3, 0.48456e-3, 0.30624e-3, 0.30624e-3, 0.20563e-3, 0.20563e...
0.7475461e-1, 0.7475461e-1, 0.1187858e-1, 0.1187858e-1, 0.372985e-2, 0.372985e-2, 0.160867e-2, 0.160867e-2, 0.83241e-3, 0.83241e-3, 0.48456e-3, 0.48456e-3, 0.30624e-3, 0.30624e-3, 0.20563e-3, 0.20563e...
(2.3)
 

Parseval's Identity tells us that  

‖f‖2=π[a02 + ∑(a02 /2+ b02 ) 

which yields for this problem that 

> Sum (1/(2*n-1)^4,n=1..infinity)=sum (1/(2*n-1)^4,n=1..infinity);
 

Sum(`/`(1, `*`(`^`(`+`(`*`(2, `*`(n)), `-`(1)), 4))), n = 1 .. infinity) = `+`(`*`(`/`(1, 96), `*`(`^`(Pi, 4)))) (2.4)
 

>