NotebookFileName[]

To evaluate commands below do Shift+Enter. For more information visit my Mathematica page.

This notebook is not readable using Wolfram Player. I will make it readable soon.

Square function approximation

Since we are approximating an even function we only need to consider the function 1 and the even trigonometric functions Cos[n x].

First calculate the squares of the norms of the trigonometric functions:

Integrate[Cos[n t]*Cos[n t],{t,-Pi,Pi}]

FullSimplify[Integrate[Cos[n t]*Cos[n t],{t,-Pi,Pi}],And[n∈Integers]]

Now prove that multiple angle cosine functions with different frequences are orthogonal:

Integrate[Cos[m t]*Cos[n t],{t,-Pi,Pi}]

FullSimplify[Integrate[Cos[m t]*Cos[n t],{t,-Pi,Pi}],And[n∈Integers,m∈Integers]]

FullSimplify[Integrate[Cos[n t]*Cos[n t],{t,-Pi,Pi}],And[n∈Integers]]

Integrate[1*(t^2),{t,-Pi,Pi}]

Integrate[1*1,{t,-Pi,Pi}]

The Fourier coefficients for the function 1

(((2 (π^3))/3)/(2 π))

The Fourier coefficients for the function Cos[n t]

FullSimplify[Integrate[(t^2)*Cos[n t],{t,-Pi,Pi}],And[n∈Integers,m∈Integers]]

FullSimplify[Integrate[Cos[n t]*Cos[n t],{t,-Pi,Pi}],And[n∈Integers,m∈Integers]]

The Fourier coefficients for the function Cos[n t]

(((4 (((-1))^n) π)/(n^2))/( π))

The projection of (t^2) onto the span of 1 and ten cosines is

(((2 (π^3))/3)/(2 π))*1 + Sum[(((4 (((-1))^n) π)/(n^2))/( π))*Cos[n t],{n,1,10}]

This is the error of the approximation:

(Sqrt[Integrate[((((((2 (π^3))/3)/(2 π))*1 + Sum[(((4 (((-1))^n) π)/(n^2))/( π))*Cos[n t],{n,1,10}]-(t^2)))^2),{t,-Pi,Pi}]])

N[%]

(((2 (π^3))/3)/(2 π))*1

(((4 (((-1))^n) π)/(n^2))/( π))

((π^2)/3)*1 + Sum[((4 (((-1))^n))/(n^2))*Cos[n t],{n,1,3}]

TeXForm[((π^2)/3)-4 Cos[t]+Cos[2 t]-(4/9) Cos[3 t]]

nn=3;SquareApp3=Plot[{(t^2),((π^2)/3)*1 + Sum[((4 (((-1))^k))/(k^2))*Cos[k t],{k,1,nn}]},{t,-3Pi,3Pi},
PlotPoints->{100,200},PlotStyle->{{RGBColor[0,0,0.5],Thickness[0.01]},{RGBColor[1,0,0],Thickness[0.005]}},Ticks->{Range[-2Pi,2 Pi,Pi/2],Range[-14,14,2]},PlotRange->{{-Pi-0.1,Pi+0.1},{-1,(Pi^2)+0.2}},AspectRatio->(1/GoldenRatio),ImageSize->600]

Introduce the periodic extension:

Plot[{Mod[t,2Pi,-Pi]},{t,-3Pi,3Pi},PlotStyle->{{RGBColor[0,0,0],Thickness[0.005]}},Ticks->{Range[-5Pi,5 Pi,Pi/2],Range[-5Pi,5 Pi,Pi/2]},PlotRange->{{-3Pi-0.1,3Pi+0.1},{-Pi-1,Pi+1}},
GridLines->{Range[-5Pi,5 Pi,Pi/4],Range[-5Pi,5 Pi,Pi/4]},AspectRatio->Automatic,ImageSize->600]

nn=10;SquareApp10pe=Plot[{((Mod[t,2 Pi,-Pi])^2),((π^2)/3)*1 + Sum[((4 (((-1))^k))/(k^2))*Cos[k t],{k,1,nn}]},{t,-4Pi,4Pi},PlotPoints->{100,200},PlotStyle->{{RGBColor[0,0,0.5],Thickness[0.01]},{RGBColor[1,0,0],Thickness[0.005]}},Ticks->{Range[-4Pi,4 Pi,Pi/2],Range[-14,14,2]},PlotRange->{{-3Pi-0.1,3Pi+0.1},{-1,(Pi^2)+1}},AspectRatio->Automatic,ImageSize->600]

Identity function approximation

FullSimplify[Integrate[Sin[n t]*Sin[n t],{t,-Pi,Pi}],And[n∈Integers]]

Integrate[Sin[m t]*Sin[n t],{t,-Pi,Pi}]

FullSimplify[Integrate[Sin[m t]*Sin[n t],{t,-Pi,Pi}],And[n∈Integers,m∈Integers]]

FullSimplify[Integrate[t*Sin[n t],{t,-Pi,Pi}],And[n∈Integers,m∈Integers]]

nn=10;IdenApp10pe=Plot[{Mod[t,2 Pi,-Pi], Sum[-((2 (((-1))^k))/k)*Sin[k t],{k,1,nn}]},{t,-4Pi,4Pi},PlotPoints->{100,200},PlotStyle->{{RGBColor[0,0,0.5],Thickness[0.01]},{RGBColor[1,0,0],Thickness[0.005]}},Ticks->{Range[-4Pi,4 Pi,Pi/2],Range[-4Pi,4 Pi,Pi/2]},GridLines->{Range[-4Pi,4 Pi,Pi/4],Range[-4Pi,4 Pi,Pi/4]},PlotRange->{{-3Pi-0.5,3Pi+0.5},{-Pi-1,Pi+1}},AspectRatio->Automatic,ImageSize->600]

(* 
SetDirectory["C:\\Dropbox\\Work\\myweb\\Courses\\Math_pages\\Math_304\\Pictures"]; 
Export["SquareApp3.png",SquareApp3,"PNG","ImageSize"->600] 
 *)