Fourier Series and Transform
Periodic signals sum harmonics at integer multiples and aperiodic ones integrate a continuum, with the same coefficients answering both.
Why Does This Exist?
A vibrating string moves at its fundamental plus overtones; a square wave carries odd harmonics; an image holds low smooth swells plus sharp edges. Fourier series write -periodic functions as sums of harmonics ; the Fourier transform extends this to aperiodic functions as an integral over a continuum of frequencies. Orthogonality makes coefficients independent (each computed by one inner product), which is why the expansion is practical rather than merely pretty. Discrete computation is the child DFT and FFT page; filtering via spectra is the convolution theorem.
The one idea you need first
Sines of distinct integer frequencies are orthogonal over one period: for . Each harmonic therefore contributes independently: changing one coefficient never disturbs the others' fit.
Think of It Like This
A chord broken into piano keys
A rich chord sounds as one blur until a tuner isolates strings: the A string hums at Hz, its octave at , a fifth above at . Each key's loudness is measured alone by pressing it softly while damping the rest (orthogonality: keys do not interfere).
Fourier coefficients are those per-key loudness readings. The series rebuilds the chord by pressing keys with the measured strengths. Aperiodic sounds (a handclap) need the whole keyboard continuum at once: the transform instead of the series.
How It Actually Works
For -periodic , coefficients and reconstruction . For aperiodic , transform with inversion . Parseval: energy matches across domains ( or equals signal energy), so no information hides.
Gibbs phenomenon. Near a jump, partial sums overshoot by about of the jump height, forever: more harmonics narrow the ringing without lowering its peak. A unit jump rings to about .
Worked example
Square wave with period : odd harmonics only, . Amplitudes: , , . Three terms at : : overshoot (, approaching the limit from above at finite terms). Energy check: against total ? Resolved honestly: Parseval for this normalization gives partial energy approaching (mean square of ) from below: normalized partials : three harmonics carry of the energy.
Code
import math
def square_partial(t: float, terms: int) -> float: total = 0.0 for k in range(terms): n = 2 * k + 1 # odd harmonics only total += math.sin(n * t) / n return 4 * total / math.pi # 4/pi times the odd sum
for terms in (1, 2, 3, 10): print(terms, round(square_partial(math.pi / 2, terms), 3))# -> 1 1.273# -> 2 0.849# -> 3 1.104# -> 10 1.063One term overshoots to , two undershoot at , three ring to , ten settle near : Gibbs ringing that narrows but persists.
Watch Out For
Truncating at a discontinuity and trusting pointwise values
Partial sums near jumps mislead by regardless of term count: control systems reading edge values from truncated series chatter. Filter (Lanczos sigma factors) or reconstruct away from jumps; never servo on the ringing peak.
Confusing harmonic index with physical frequency
Coefficient means Hz only with the period normalized correctly; resampling the same wave at a new renumbers everything. Label axes in Hz (index over period), not raw index, before comparing spectra across recordings.
The Quick Version
- Periodic functions sum harmonics; aperiodic ones integrate a frequency continuum.
- Orthogonality isolates each coefficient to one inner product.
- The square wave uses odd harmonics with amplitudes , , .
- Three harmonics carry of the wave's energy by Parseval.
- Gibbs ringing overshoots jumps by about at any truncation.
- Index means index over period: convert to Hz before comparing spectra.