Fourier Series and Fourier Transform: Intuition with Worked Examples
The central idea of Fourier analysis is that almost any signal can be built by adding sine waves of different frequencies, amplitudes and phases. This is not just mathematics. A spectrum analyser displays exactly these components, an audio equaliser boosts or cuts them, and the harmonics of a PWM signal are what an EMI test lab measures. This tutorial develops the intuition first, then works through the Fourier series of a square wave, the power in its harmonics, the Fourier transform of a rectangular pulse, and a short NumPy check you can run yourself.
Fourier Series for Periodic Signals
A periodic signal x(t) with period T and fundamental angular frequency ω0 = 2π/T can be written as a DC term plus cosines and sines at integer multiples of ω0. These multiples are called harmonics. The coefficients measure how much of each harmonic the signal contains, and are found by multiplying x(t) by the matching sinusoid and averaging over one period.
x(t) = a0 + Σ [ an cos(nω0t) + bn sin(nω0t) ] n = 1, 2, 3, ... a0 = (1/T) ∫ x(t) dt (average or DC value) an = (2/T) ∫ x(t) cos(nω0t) dt bn = (2/T) ∫ x(t) sin(nω0t) dt (all integrals over one period) Exponential form: x(t) = Σ cn e^(jnω0t), cn = (1/T) ∫ x(t) e^(-jnω0t) dt
Symmetry saves a lot of work. An even signal, x(-t) = x(t), has only cosine terms, so bn = 0. An odd signal, x(-t) = -x(t), has only sine terms, so a0 = an = 0. A signal with half-wave symmetry, x(t + T/2) = -x(t), contains only odd harmonics.
Worked Example: Square Wave
Take a square wave of amplitude A that is +A for the first half of each period and -A for the second half, centred so that it is an odd function. It is odd and has half-wave symmetry, so only odd sine terms survive.
bn = (2/T) [ ∫(0 to T/2) A sin(nω0t) dt - ∫(T/2 to T) A sin(nω0t) dt ] = (2A / nπ) (1 - cos nπ) = 4A / (nπ) for odd n, 0 for even n x(t) = (4A/π) [ sin ω0t + (1/3) sin 3ω0t + (1/5) sin 5ω0t + ... ] Harmonic amplitudes for A = 1: n = 1 : 1.273 n = 3 : 0.424 n = 5 : 0.255 n = 7 : 0.182
Two lessons follow. First, a fast edge needs high harmonics: they fall only as 1/n, so a square wave has significant energy far above its fundamental. This is why sharp digital edges cause EMI and why a slower edge rate reduces it. Second, when you truncate the series, the sum overshoots near each edge by roughly 9 percent of the jump, no matter how many terms you add. This is the Gibbs phenomenon, and it shows up as ringing when a signal passes through a sharp low-pass filter.
Power in the Harmonics: Parseval's Theorem
Parseval's theorem says the average power of a periodic signal equals the sum of the powers of its individual components. A sinusoid of peak amplitude B contributes B squared over 2.
Total power of square wave (amplitude A): P = A^2 Power in fundamental: (4A/π)^2 / 2 = 8A^2 / π^2 = 0.811 A^2 -> about 81% of the power is in the fundamental. Total harmonic distortion (relative to fundamental): THD = sqrt(P - P1) / sqrt(P1) = sqrt(0.189 / 0.811) = 0.483 -> about 48%
This calculation explains why a simple LC filter after a square-wave inverter can produce a reasonable sine wave: removing the harmonics leaves most of the power intact, and the 3rd harmonic, the nearest one, is already a factor of three lower in amplitude.
From Series to Transform
If the period T grows without limit, the harmonics crowd closer together, spaced 1/T apart, until the line spectrum becomes a continuous function. That function is the Fourier transform, which applies to non-periodic signals such as a single pulse.
X(f) = ∫ x(t) e^(-j2πft) dt x(t) = ∫ X(f) e^(j2πft) df
Worked example: rectangular pulse, height A, width τ, centred at t = 0
X(f) = ∫(-τ/2 to τ/2) A e^(-j2πft) dt = Aτ . sin(πfτ) / (πfτ)
= Aτ sinc(fτ)
First zeros at f = ±1/τThe result shows the inverse relationship between time and frequency. A 1 µs pulse has its first spectral null at 1 MHz; a 1 ns pulse spreads out to 1 GHz. Narrow in time means wide in frequency. This is why a data link with short bit periods needs more bandwidth.
| Property | Time domain | Frequency domain |
|---|---|---|
| Time shift | x(t - t0) | X(f) e^(-j2πft0), only phase changes |
| Scaling | x(at) | (1/|a|) X(f/a) |
| Modulation | x(t) cos(2πfct) | [X(f - fc) + X(f + fc)] / 2 |
| Convolution | x(t) * h(t) | X(f) . H(f) |
| Multiplication | x(t) . y(t) | X(f) * Y(f) |
| Exponential pair | e^(-at) u(t), a > 0 | 1 / (a + j2πf) |
The convolution property is the most useful one in practice: passing a signal through an LTI system multiplies its spectrum by the frequency response H(f), which is simply the Fourier transform of the impulse response.
From the transform to the FFT
Computers cannot integrate over all time, so they use the discrete Fourier transform (DFT) on N samples taken at a sampling rate fs. The result has frequency bins spaced fs/N apart, so a longer record gives finer resolution. The FFT is simply a fast algorithm for computing the DFT. Two practical effects matter. If the record does not contain a whole number of signal periods, energy smears into neighbouring bins, which is called spectral leakage; multiplying the samples by a window such as Hann reduces it. And any component above fs/2 folds back as a false lower frequency, which is aliasing, so an anti-aliasing filter must come before the ADC.
Check It Numerically
import numpy as np
fs = 10000 # sample rate, Hz
f0 = 50 # square wave frequency, Hz
t = np.arange(0, 1, 1 / fs) # 1 second -> 1 Hz FFT bin spacing
x = np.where((t * f0) % 1 < 0.5, 1.0, -1.0) # amplitude A = 1
X = np.fft.rfft(x) * 2 / len(x) # scale to peak amplitude
for k in (50, 100, 150, 250): # bins equal frequency in Hz here
print(k, round(abs(X[k]), 3))
50 1.273 100 0.0 150 0.425 250 0.255
The fundamental matches 4/π, the even harmonic at 100 Hz is absent, and the 3rd and 5th harmonics match the theory to within the small error introduced by sampling.
Summary
- Periodic signals decompose into harmonics of the fundamental; use symmetry to skip zero coefficients.
- A square wave contains only odd harmonics with amplitudes 4A/(nπ), and its fundamental carries about 81 percent of its power.
- The Fourier transform extends the idea to non-periodic signals; a rectangular pulse gives a sinc spectrum with nulls at multiples of 1/τ.
- Short in time means wide in frequency, and convolution in time becomes multiplication in frequency.