Fourier Series

Author

Eric W. Weisstein
January 14, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Calculus/FourierSeries.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/FourierSeries.html.

©2010 Wolfram Research, Inc. except for portions noted otherwise

Plots of Examples

V5

RectangleFunction[{a_,b_},x_]:=UnitStep[x-a]-UnitStep[x-b]
Plus@@Table[RectangleFunction[{i,i+2},x](x-i)/2,{i,-2,2,2}]

Off[Plot::"plnr"]

Show[GraphicsArray[Partition[
Plot[Evaluate[{
#1/.L->1,
Sequence@@Take[Union[FourierPartialSums[#1/.L->1,{x,0,2},10]],5]
}],{x,-.02,2.02},
DisplayFunction->Identity,
PlotStyle->{Thickness[.01],Red,Orange,Yellow,Green,Blue,Violet},
PlotLabel->StyleForm[#2,FontFamily->"Times",FontSlant->"Italic"],
PlotRange->All,AxesLabel->TraditionalForm/@{x/L,""}]&@@@
{
{2(UnitStep[x/L]-UnitStep[x/L-1])-1,"square wave"},
{(1/2) (-2+x) (-UnitStep[-4+x]+UnitStep[-2+x])+(1/2) x (-UnitStep[-2+x]+UnitStep[x])+(1/2) (2+x) (-UnitStep[x]+UnitStep[2+x]),"sawtooth wave"},
{((2 (-2 L+x) (-UnitStep[-2 L+x]+UnitStep[-((3 L)/2)+x]))/L)+((2 x (UnitStep[x]-UnitStep[-(L/2)+x]))/L)+(1-((2 (-(L/2)+x))/L)) (-UnitStep[-((3 L)/2)+x]+UnitStep[-(L/2)+x]),"triangle wave"},
{(Sqrt[(2 L-x) x]),"semicircle"}
},2]
]]//Timing

V6

Needs["Graphics`Colors`"]//Quiet

RectangleFunction[{a_,b_},x_]:=UnitStep[x-a]-UnitStep[x-b]
Total[Table[RectangleFunction[{i,i+2},x](x-i)/2,{i,-2,2,2}]]

Show[GraphicsGrid[Partition[
Plot[Evaluate[{
#1/.L->1,
Sequence@@Take[Union[FourierPartialSums[#1/.L->1,{x,0,2},10]],5]
}],{x,-.02,2.02},
PlotStyle->{Thickness[.01],Red,Orange,Yellow,Green,Blue,Violet},
PlotLabel->Style[#2,Italic],
PlotRange->All,AxesLabel->{x/L,""}]&@@@
{
{2(UnitStep[x/L]-UnitStep[x/L-1])-1,"square wave"},
{(1/2) (-2+x) (-UnitStep[-4+x]+UnitStep[-2+x])+(1/2) x (-UnitStep[-2+x]+UnitStep[x])+(1/2) (2+x) (-UnitStep[x]+UnitStep[2+x]),"sawtooth wave"},
{((2 (-2 L+x) (-UnitStep[-2 L+x]+UnitStep[-((3 L)/2)+x]))/L)+((2 x (UnitStep[x]-UnitStep[-(L/2)+x]))/L)+(1-((2 (-(L/2)+x))/L)) (-UnitStep[-((3 L)/2)+x]+UnitStep[-(L/2)+x]),"triangle wave"},
{(Sqrt[(2 L-x) x]),"semicircle"}
},2]
]]

Gibbs Phenomenon for Square Wave

V6

f[x_]:=2(UnitStep[x/L]-UnitStep[x/L-1])-1

FourierA[0,f[x],{x,0,2L}]

FourierA[n,f[x],{x,0,2L}]

FullSimplify[FourierB[n,f[x],{x,0,2L}]]

V7

FourierCosCoefficient[SquareWave[x],x,n]

Table[FourierCosCoefficient[SquareWave[x],x,n],{n,0,4}]

FourierSinCoefficient[SquareWave[x],x,n]

Table[FourierSinCoefficient[SquareWave[x],x,n],{n,4}]

Plot

(series=Rest[FoldList[Plus,0,Table[Sin[n Pi x]/n,{n,1,9,2}]]]4/Pi)//ColumnForm//TraditionalForm

Plot[Evaluate[{
2UnitStep[x]-2UnitStep[x-1]+2UnitStep[x-2]-1,
Sequence@@series
}],{x,-.02,2.02},
PlotStyle->{Thickness[.01],Red,Yellow,Green,Blue,Violet},
PlotRange->All,AxesLabel->TraditionalForm/@{x,f[x]}]