Fourier Series Example

Cosines and sines at integer frequencies form an orthogonal set in (L^2)[-ℼ,ℼ]:

Integrate[Cos[j t]^2,{t,-Pi,Pi}]

Integrate[Sin[j t]^2,{t,-Pi,Pi}]

Integrate[Cos[j t]Cos[ k t],{t,-Pi,Pi}]

Integrate[Sin[j t]Sin[ k t],{t,-Pi,Pi}]

Integrate[Cos[j t]Sin[ k t],{t,-Pi,Pi}]

Periodic extension with period 2ℼ of a piecewise constant function

Consider the following characteristic function as our template to be extended periodically:

f[t_]:=Piecewise[{{1,-Pi≤t≤0}},0];
Plot[f[t],{t,-Pi,Pi},PlotStyle->{Black,Thickness[.005]}]

c0=1/(2Pi) Integrate[f[t],{t,-Pi,Pi}]

c[k_]:=1/(2 Pi) Assuming[k∈Integers,Integrate[f[t]Exp[-I k t],{t,-Pi,Pi}]]
c[k]

partialsum=Sum[c[k]Exp[I k t],{k,-3,3}];
Plot[partialsum,{t,-4Pi,4Pi},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]

partialsum=Sum[c[k]Exp[I k t],{k,-10,10}];
Plot[partialsum,{t,-4Pi,4Pi},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]

partialsum=Sum[c[k]Exp[I k t],{k,-40,40}];
Plot[partialsum,{t,-4Pi,4Pi},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]

partialsum=Sum[c[k]Exp[I k t],{k,-80,80}];
Plot[partialsum,{t,-4Pi,4Pi},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]

At each jump discontinuity the partial sums of the Fourier series overshoot the function' s value.  The amount of overshoot tends to remain about the the same but it occurs closer and closer to the jump point.  This is called the Gibbs phenomenon.  Apart from the points with jump discontinuities, the Fourier series converges pointwise to the original function.

Next up are examples of even and odd extensions of a function defined on a half-interval:

f[t_]:=t;
Plot[f[t],{t,0,1},PlotStyle->{Black,Thickness[.005]},AspectRatio->1]

Even periodic extension with period 2 of f(t)=t on [0,1]

L=1;

a0=1/L Integrate[f[t],{t,0,L}]
a[k_]:=2/L Assuming[k∈Integers,Integrate[f[t]Cos[ Pi k t/L],{t,0 ,L}]]
a[k]

partialsum=a0+Sum[a[k]Cos[ Pi k t/L],{k,1,25}];
Plot[partialsum,{t,-4L,4L},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]

Odd periodic extension with period 2 of f(t)=t on [0,1]

L=1;

b[k_]:=2/L Assuming[k∈Integers,Integrate[f[t]Sin[ Pi k t/L],{t,0 ,L}]]
b[k]

partialsum=Sum[b[k]Sin[ Pi k t/L],{k,1,25}];
Plot[partialsum,{t,-4L,4L},PlotRange->All,AspectRatio->1/5,PlotStyle->{Black,Thickness[.002]}]