Fourier Series—Triangle Wave

Author

Eric W. Weisstein
August 17, 2008

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

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

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

Symmetric Triangle Wave

TriangleWave

V7

FourierCosCoefficient[TriangleWave[x],x,n]

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

FourierSinCoefficient[TriangleWave[x],x,n]

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

1-2 |1-2 (((x/(2 L))+(1/4)) mod 1)|

f[x_]:=1-2Abs[1-2Mod[x/L/2+1/4,1]]

Block[{L=1},Plot[f1[x],{x,0,2L},PlotStyle->Red]]

v5.2

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

FullSimplify[FourierA[n,f[x],{x,0,2L}],n>0&&n∈Integers]

FullSimplify[FourierB[n,f[x],{x,0,2L}],n>=0&&n∈Integers]

FullSimplify[(32/((n^2)(π^2)))Cos[(1/4)n π]((Sin[(1/4)n π])^3),n∈Integers&&n≥0]

FullSimplify[Subtract@@{((8 Sin[((n π)/2)])/((n^2) (π^2))),((2 I (n π+(((-1))^n) (4 I+n π)) Sin[((n π)/2)])/((n^2) (π^2)))},n>0&&n∈Integers]

Table[%,{n,0,10}]

v6

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

FullSimplify[FourierA[n,f[x],{x,0,2L}],n>0&&n∈Integers]

FullSimplify[FourierB[n,f[x],{x,0,2L}],n>0&&n∈Integers]

V7

(Piecewise[{{((2 (L-x))/L), L-2 x<0∧3 L-2 x>0}, {-((2 (2 L-x))/L), (x≤0∧3 L-2 x<0∧2 L-x>0)∨(L-2 x≤0∧3 L-2 x<0∧2 L-x>0)}, {((2 x)/L), x>0∧L-2 x>0}}])

f0[x_]:=Which[
0<x<L/2,(x/(L/2)),
L/2<x<3L/2,(1-2((x/L)-(1/2))),
3L/2<x<2L,(2((x/L)-(3/2))-1)]

Block[{L=1},Plot[f0[x],{x,0,2L},PlotStyle->Red]]

v5.2

FourierA[0,f0[x],{x,0,2L}]//Simplify

FullSimplify[FourierA[n,f0[x],{x,0,2L}],n∈Integers&&n>0]

FullSimplify[FourierB[n,f0[x],{x,0,2L}],n∈Integers&&n>0]

v6

FourierA[0,f0[x],{x,0,2L}]//Simplify

FullSimplify[FourierA[n,f0[x],{x,0,2L}],n>0&&n∈Integers]

FullSimplify[FourierB[n,f0[x],{x,0,2L}],n>0&&n∈Integers]

1-4 |(1/2)-frac((x/(2 L))+(1/4))|

f2[x_]:=1-4Abs[(1/2)-FractionalPart[(1/2)(x/L)+(1/4)]]

Block[{L=1},Plot[f2[x],{x,0,2L},PlotStyle->Red]]

v5.2

FourierA[0,f2[x],{x,0,2L}]//Simplify

FullSimplify[FourierA[n,f2[x],{x,0,2L}],n∈Integers&&n>0]

FullSimplify[FourierB[n,f2[x],{x,0,2L}],n∈Integers&&n>0]

v6

FourierA[0,f0[x],{x,0,2L}]//Simplify

FullSimplify[FourierA[n,f0[x],{x,0,2L}],n>0&&n∈Integers]

FullSimplify[FourierB[n,f0[x],{x,0,2L}],n>0&&n∈Integers]

Symmetric Triangle WavePlot

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

FourierPlot[Evaluate[f1[x]/.L:>1],{x,0,2},5,AxesLabel->TraditionalForm/@{InlineFraction[x,L],f[x]}]//Timing

Block[{L=1},
Plot[Evaluate[{
f1[x],
Sequence@@series
}],{x,-.02,2.02},
PlotStyle->{Thickness[.01],Red,Yellow,Green,Blue,Violet},
PlotRange->All,AxesLabel->TraditionalForm/@{x,HoldForm[f[x]]}]
]

Symmetric Triangle Wave Sums

(∑_(n=1, 3, ...)^∞)(((2 i ((((-1))^n) (π n+4 i)+π n) sin(((π n)/2))) sin(π n x))/((π^2) (n^2)))

Plot[Sum[((2 I (n π+(((-1))^n) (4 I+n π)) Sin[((n π)/2)])/((n^2) (π^2))) Sin[n Pi x],{n,1,30,2}],{x,-2,2}]

Plot[TriangleWave[x/2],{x,-2,2}]

V6

Sum[((2 I (n π+(((-1))^n) (4 I+n π)) Sin[((n π)/2)])/((n^2) (π^2))) Sin[n Pi x],{n,1,∞,2}]

FullSimplify[%]

V7

TimeConstrained[Sum[((2 I (n π+(((-1))^n) (4 I+n π)) Sin[((n π)/2)])/((n^2) (π^2))) Sin[n Pi x],{n,1,∞,2}],60]//Timing

(∑_(n=1, 3, ...)^∞)((8 (((-1))^((n-1)/2)) sin(π n x))/((π^2) (n^2)))

Plot[Sum[((8(-1)^((n-1)/2))/(Pi^2 n^2)) Sin[n Pi x],{n,1,30,2}],{x,-2,2}]

V6

Sum[((8(-1)^((n-1)/2))/(Pi^2 n^2)) Sin[n Pi x],{n,1,∞,2}]

V7

TimeConstrained[Sum[((8(-1)^((n-1)/2))/(Pi^2 n^2)) Sin[n Pi x],{n,1,∞,2}],60]//Timing

Arbitrary Triangle Wave

t[x_,m_]:=(m/L)x(UnitStep[x]-UnitStep[x-(L/m)])+(1-(m/((m-1)L))(x-(L/m)))(UnitStep[x-(L/m)]-UnitStep[x-(2L-(L/m))])+(m/L)(x-2L)(UnitStep[x-(2L-(L/m))]-UnitStep[x-2L])

Block[{L=1},
Plot[Evaluate[Table[t[x,m],{m,2,5}]],{x,0,2L},PlotStyle->List/@{Red,Yellow,Green,Blue},PlotRange->All]
]

v5.2

Simplify[FourierA[0,t[x,m],{x,0,2L}],L>0&&m>1]

Simplify[FourierA[n,t[x,m],{x,0,2L}],L>0&&m>1]

Simplify[FourierB[n,t[x,m],{x,0,2L}],L>0&&m>1]

v6

Simplify[FourierA[0,t[x,m],{x,0,2L}],L>0&&m>1]

Simplify[FourierA[n,t[x,m],{x,0,2L}],L>0&&m>1]

FullSimplify[FourierB[n,t[x,m],{x,0,2L}],L>0&&m>1&&n∈Integers]

m=2

FullSimplify[-((2 (((-1))^n) (m^2) Sin[(((-1+m) n π)/m)])/((-1+m) (n^2) (π^2)))/.m->2]

Table[-((8 (((-1))^n) Sin[((n π)/2)])/((n^2) (π^2))),{n,10}]

m=3

FullSimplify[-((2 (((-1))^n) (m^2) Sin[(((-1+m) n π)/m)])/((-1+m) (n^2) (π^2)))/.m->3,n∈Integers]

Table[-((9 (((-1))^n) Sin[((2 n π)/3)])/((n^2) (π^2))),{n,10}]

m=4

FullSimplify[-((2 (((-1))^n) (m^2) Sin[(((-1+m) n π)/m)])/((-1+m) (n^2) (π^2)))/.m->4,n∈Integers]

Table[-((32 (((-1))^n) Sin[((3 n π)/4)])/(3 (n^2) (π^2))),{n,10}]

Arbitrary Triangle WavePlots

<<Utilities`Typesetting`

series=Table[Rest[FoldList[Plus,0,Table[Sin[n Pi x](-((2 (((-1))^n) (m^2) Sin[(((-1+m) n π)/m)])/((-1+m) (n^2) (π^2)))),{n,5}]]],{m,2,5}];

Show[GraphicsArray[
Partition[Block[{L=1,$DisplayFunction=Identity},Table[Plot[Evaluate[{
f1[x,m],
Sequence@@series[[m-1]]
}],{x,-.02,2.02},
PlotStyle->{Thickness[.015],Red,Yellow,Green,Blue,Violet},
PlotRange->All,PlotLabel->TraditionalForm[HoldForm[m]==m],AxesLabel->TraditionalForm/@{x,HoldForm[f[x]]}],
{m,2,5}]
],2]
]]