For perpendicular unit vectors e1,e2,e3, any vector is v=∑i(v⋅ei)ei: each coefficient comes from one dot product, untouched by the other directions, because they are perpendicular. Signals with period T0 work the same way. The directions are the harmonics ejkω0t, with ω0=2π/T0 rad/s and integer k. The dot product becomes the inner product ⟨x,g⟩=∫0T0x(t)g∗(t)dt; the conjugate makes ⟨x,x⟩=∫0T0∣x(t)∣2dt a squared length, never negative. Orthogonal (perpendicular) means ⟨x,g⟩=0.
HARMONICS ARE ORTHOGONAL
∫0T0ejkω0te−jmω0tdt={T0,0,k=mk=m
k,m are integers; T0 is the period in seconds and ω0T0=2π. This is ⟨ejkω0t,ejmω0t⟩. For k=m the integrand is 1. For k=m the antiderivative ej(k−m)ω0t/(j(k−m)ω0) takes the same value at 0 and T0, because ej2π(k−m)=1, so the integral is zero.
FOURIER COEFFICIENT AS A PROJECTION
x(t)=k=−∞∑∞akejkω0t⟹am=T01∫0T0x(t)e−jmω0tdt
Holds for x(t) periodic with period T0, assuming the series converges well enough to integrate term by term. Multiply the series by e−jmω0t and integrate over one period: each term with k=m gives zero and k=m gives amT0; divide by T0. a0 is the average value of x, in the units of x.
So am is the inner product of x with the m-th harmonic, divided by that harmonic's squared length T0: a projection. Now do the square wave slowly. Let x(t)=1 for 0<t<T0/2 and x(t)=−1 for T0/2<t<T0, repeating every T0.
SQUARE WAVE COEFFICIENTS
ak=T01[∫0T0/2e−jkω0tdt−∫T0/2T0e−jkω0tdt]=T01[jkω01−e−jkπ−jkω0e−jkπ−e−j2kπ]=jkω0T0(1−(−1)k)−((−1)k−1)=jkω0T02(1−(−1)k)=jπk1−(−1)k
For k=0. Line 2: ∫abectdt=(ecb−eca)/c with c=−jkω0, and ω0T0/2=π. Line 3: e−jkπ=(−1)k, e−j2kπ=1. Line 4: collect terms, then ω0T0=2π. For k=0 the halves cancel: a0=0. Odd k: ak=2/(jπk). Even k=0: ak=0.
SQUARE WAVE AS A SINE SERIES
x(t)=π4(sinω0t+3sin3ω0t+5sin5ω0t+⋯)
Because x is real, a−k is the conjugate of ak, so the pair gives 2Re{jπk2ejkω0t}=πk4sinkω0t for odd k. Holds at every t away from the jumps; at a jump the sum is 0, halfway between −1 and 1.
The sums swing above and below 1 and settle towards it. Near a jump they behave differently: this is the Gibbs phenomenon, described here without proof. Once many terms are kept, the partial sums overshoot by about 9% of the jump, so by about 0.18 here, where the jump is 2. More terms squeeze the overshoot closer to the jump, but its height does not shrink to zero. Smooth sines cannot switch instantly, so a finite sum rings.