The formula
For a signal f(t) that repeats with period T (fundamental frequency ω₀ = 2π/T):
f(t) = a₀/2 + Σₙ [ aₙ·cos(n·ω₀·t) + bₙ·sin(n·ω₀·t) ] — the waveform is a DC term plus one cosine and one sine at every integer multiple of the fundamental. Nothing else is needed; nothing between the harmonics exists.
aₙ = (2/T)·∫ f(t)·cos(n·ω₀·t) dt and bₙ = (2/T)·∫ f(t)·sin(n·ω₀·t) dt, integrated over one period — each coefficient is the correlation of the waveform against one harmonic: how much of that frequency the signal actually contains.
The complex form most instruments and textbooks reduce to:
f(t) = Σₙ cₙ·e^(j·n·ω₀·t), with cₙ = (1/T)·∫ f(t)·e^(−j·n·ω₀·t) dt — same content, one coefficient per harmonic, magnitude and phase in a single complex number. This is what a spectrum analyzer's line spectrum is showing you.
Parseval's theorem, the power bookkeeping:
(1/T)·∫ |f(t)|² dt = (a₀/2)² + Σₙ (aₙ² + bₙ²)/2 — the mean-square value of the waveform equals the sum of the mean-square values of its harmonics. RMS in the time domain and RMS summed across the spectrum are the same number, always.
The one everyone in test actually uses, which is Parseval wearing work clothes:
THD = √(V₂² + V₃² + V₄² + …) / V₁ — total harmonic distortion: RMS of everything above the fundamental, divided by the fundamental.
Where you meet it
- On the bench with a distortion analyzer or an audio analyzer, measuring THD on an amplifier or a power inverter. The instrument computes Fourier coefficients of the output, drops the fundamental, and ratios what's left. The 0.003% on the screen is a statement about
b₂, b₃, b₅…. - Power quality work. IEEE 519 harmonic limits, transformer K-factor ratings, neutral-conductor sizing on three-phase panels feeding switch-mode loads — all of it is written in terms of the Fourier coefficients of the line current. Triplen harmonics adding in the neutral is a Fourier series fact, not a wiring fact.
- Steady-state AC analysis of anything driven by a non-sinusoidal source. A square-wave drive into an RLC network is intractable as one problem and trivial as thirty: solve the phasor circuit at each harmonic, scale by that harmonic's coefficient, add the results. Superposition plus Fourier is the whole method.
- Vibration review boards. A rotating machine's spectrum shows lines at 1×, 2×, 3× shaft speed; which harmonics carry the energy is the diagnostic (misalignment shouts at 2×, looseness litters the whole comb). The analyzer computes it with an FFT, but the reasoning is Fourier series reasoning: periodic motion, discrete harmonics.
How it works
The machinery runs on orthogonality. Over one period, sin(n·ω₀·t) and cos(m·ω₀·t) integrate against each other to zero unless they're the same harmonic. So multiplying f(t) by one harmonic and integrating kills every other term and leaves that coefficient alone — each harmonic can be extracted independently, which is why the coefficient formulas work and why adding a 7th-harmonic trap to a filter doesn't disturb the 5th.
Symmetry does half your work before you integrate. An even waveform (f(−t) = f(t)) has only cosines; an odd one has only sines; half-wave symmetry (f(t + T/2) = −f(t)) kills every even harmonic. That last one is why a symmetric square wave, an idealized push-pull amplifier, and a healthy three-phase machine all show odd harmonics only — and why even harmonics appearing on a spectrum are themselves a finding: something broke the symmetry.
The benchmark example is the ±1 square wave:
f(t) = (4/π)·[ sin(ω₀t) + sin(3ω₀t)/3 + sin(5ω₀t)/5 + … ]
Odd harmonics only, falling as 1/n. The 3rd harmonic sits 9.5 dB below the fundamental, the 5th 14.0 dB down (numbers checked). How fast coefficients decay tracks how smooth the waveform is: a jump gives 1/n decay (square, sawtooth), a corner gives 1/n² (triangle), and each additional derivative of smoothness buys another power of n. That's why a triangle wave is easy to filter into a clean sine and a square wave never quite is — and it's the whole basis of soft-switching and trapezoidal motor drive: round the edges, starve the high harmonics.
Distortion figures for the classic shapes, each verified numerically: square wave THD is √(π²/8 − 1) ≈ 48.3%, sawtooth √(π²/6 − 1) ≈ 80.3%, triangle √(π⁴/96 − 1) ≈ 12.1%. If your "sine" inverter reads 45% THD, you bought a square-wave inverter.
Parseval as a bench check, worked with the same square wave. The harmonic amplitudes are 4/π, 4/3π, 4/5π, …; convert each to RMS and root-sum-square them:
V_rms = √[ (4/π)²/2 · (1 + 1/9 + 1/25 + 1/49 + …) ]
= √[ (8/π²) · (π²/8) ] = 1 (matches the time-domain RMS of a ±1 square wave exactly)
The first four terms alone recover 97.4% of the true RMS (checked) — which is also the practical warning: a true-RMS meter or analyzer with limited bandwidth reads low on harmonic-rich waveforms, and how low depends on where its bandwidth cuts the series off.
Convergence is where the fine print lives. For any waveform satisfying the Dirichlet conditions — finitely many jumps and wiggles per period, which covers every signal a lab produces — the series converges to the function wherever it's continuous, and at a jump it converges to the midpoint of the two sides [1][5]. But the convergence is not uniform near a jump: truncate the series anywhere and the partial sum overshoots the corner by about 9% of the jump height — 8.95%, checked numerically at 10, 100, and 1,000 terms. More terms squeeze the overshoot into a narrower spike; they never shrink it. That is the Gibbs phenomenon, and it is not a rounding error. It's the ringing on a band-limited scope trace of a fast edge, the preshoot/overshoot spec on a filter's step response, the ripple next to a brick-wall filter's cutoff. Any hardware that truncates a harmonic series reproduces it.
The mistakes people actually make:
- Adding harmonic voltages linearly. Harmonic RMS values add root-sum-square (Parseval), not arithmetically. A waveform with 10% third harmonic and 10% fifth is 14.1% THD, not 20%.
- Applying it to signals that don't repeat. The series only exists for periodic signals. A transient or a noise record needs the Fourier transform or a PSD; forcing a window of non-periodic data through periodic assumptions is exactly the spectral-leakage problem that FFT windowing exists to patch.
- Forgetting phase. Two waveforms with identical harmonic magnitudes and different phases can look wildly different on a scope and stress a rectifier's peak rating differently. THD throws phase away; crest factor doesn't.
- Chasing Gibbs ringing as if it were a circuit defect. If the overshoot next to a fast edge scales with the edge and won't respond to layout changes, you're fighting mathematics, not parasitics.
History
The pieces existed before the name. Daniel Bernoulli, working on musical strings in the mid-1700s, insisted a vibrating string's motion is a superposition of harmonic modes stacked on one another [7], and Euler and d'Alembert worked the same problem from other directions [2]. What nobody accepted was the strong claim — that an arbitrary shape could be built from sines.
Joseph Fourier made the strong claim. In December 1807 he submitted a memoir on heat propagation in solids to the Paris Institute, in which the trigonometric expansion was the working tool [2][3]. The review committee — Lagrange, Laplace, Monge, and Lacroix — was not persuaded; Lagrange and Laplace specifically objected to the trigonometric series representations [3]. The Institute then made heat propagation the subject of its 1811 prize; Fourier resubmitted, won, and still collected the committee's now-famous stipulation that his analysis "leaves something to be desired on the score of generality and even rigour" [2][3]. His full treatment, Théorie analytique de la chaleur, appeared in 1822 [2][3].
The rigor gap the committee complained about was real, and Gustav Lejeune Dirichlet closed the first stretch of it in 1829 with the first solid convergence proof, giving sufficient conditions and the midpoint-at-a-jump result [5][6]. The overshoot was found in stages: Henry Wilbraham analyzed it in 1848 and was ignored; J. Willard Gibbs described it in Nature in 1899 (after getting it wrong in an 1898 letter first); Maxime Bôcher did the full analysis in 1906 and hung Gibbs's name on it [4]. Wilbraham's priority was only recognized decades later — a standing reminder of what an unread paper is worth [4].
Related tools
- /tools/rms-peak — RMS, peak, and crest factor: Parseval is why spectrum-summed RMS matches the time-domain value
- /tools/rc-filter — first-order filtering is the standard tool for stripping harmonics off a fundamental
- /tools/frequency-period — the fundamental
f₀ = 1/Tthat every harmonic is a multiple of - /tools/series-rlc-impedance — per-harmonic phasor analysis of driven RLC networks
- /tools/lc-resonance — harmonic traps and tank circuits are tuned to land on specific harmonic numbers
- /tools/vibration-natural-freq — machine vibration spectra read as harmonics of shaft speed
- /tools/db-voltage-ratio — converting harmonic amplitude ratios to the dB values on the analyzer screen
Sources
- https://dlmf.nist.gov/1.8
- https://en.wikipedia.org/wiki/Fourier_series
- https://mathshistory.st-andrews.ac.uk/Biographies/Fourier/
- https://en.wikipedia.org/wiki/Gibbs_phenomenon
- https://en.wikipedia.org/wiki/Dirichlet_conditions
- https://mathshistory.st-andrews.ac.uk/Biographies/Dirichlet/
- https://mathshistory.st-andrews.ac.uk/Biographies/Bernoulli_Daniel/