Phys 238
Fourier Series Representation of a Sawtooth Wave

Clear["Global`*"]

f[t_] := A * t

A = 5.0;
T = 10.0;

Plot[f[t], {t, -T/2, T/2}]

Fourier Transform

Nmax = 20;

ω[n_] := n * (2 π/T)

a[n_] := (2/T) Integrate[f[t] Sin[ω[n] t], {t, -T/2, T/2}]

a[1]

a[1] / (8 A/(π^2))

as = Table[a[n], {n, 1, Nmax}]

as = Chop[as]

as / (8 A / (π^2))

ListPlot[as, Joined->True, Mesh->All, PlotRange->All]

ListPlot[as, Filling -> Axis, FillingStyle->Black, PlotRange->All]

Reconstructing the original waveform

fs[nmax_, t_] :=  Sum[as[[n]] Sin[ω[n] t], {n, 1, nmax}]

fs[3, t]

Manipulate[Plot[{f[t], fs[nmax, t], as[[nmax]] Sin[ω[nmax] t]}, {t, -T/2, T/2},
LabelStyle->Larger, AxesLabel -> {"t", "f(t)"}, ImageSize -> Scaled[0.8]],
 {nmax, 1, Nmax, 1, Appearance->"Open"}]

Analyitic Version

Clear[A, T]

an[n_] :=Integrate[(2/T) f[t] Sin[ω[n] t], {t, -T/2, T/2}]

Table[an[n], {n, 1, 10}] / (A T/π)

fsa[nmax_, t_] := Sum[an[n] Sin[ω[n] t], {n, 1, nmax}]

fsa[5, t]

A = 5.0;
T = 10.0;

Plot[Evaluate[fsa[99, t]], {t, -T/2, 3T/2}]