Splitting a signal into notes
Play a chord on a piano and a microphone records a single wiggly voltage. Yet your ear hears three notes, and a trained musician can name them. Somewhere between the air and your brain, the signal has been split into its frequencies. A prism does the same to light, and an equaliser on a music player does it to sound, turning some frequencies up and others down.
Joseph Fourier's claim, made in a memoir on heat in 1807 and met with scepticism by some of the greatest mathematicians of his day, was that this splitting always works: essentially any signal can be written as a sum of sinusoids. Engineers care about this for a reason you met at the end of Signals, systems and convolution: complex exponentials pass through LTI systems unchanged in shape, merely multiplied by a number. So if a signal is a sum of exponentials, the output of any LTI system is the same sum with each term rescaled. Convolution, a tangle of sums or integrals, becomes multiplication, one frequency at a time.
This lesson builds the two tools that do the splitting. The Fourier series handles periodic signals, such as a clock or a PWM waveform, and uses a discrete set of frequencies. The Fourier transform handles signals of any shape, such as a pulse or a spoken word, and uses a continuum of them. Along the way you will compute the overshoot that never goes away, measure what fraction of a signal's power lies in each harmonic, and meet the uncertainty relation that forbids a signal from being both short and narrow-band.
Why complex exponentials?
Feed the complex exponential , with any complex number, into an LTI system with impulse response . Convolution gives The output is the input times a constant , provided the integral converges. Complex exponentials are eigenfunctions of every LTI system, and is the corresponding eigenvalue.
On the imaginary axis, , the input is a pure oscillation and is the frequency response, the same quantity you measured for filters in Frequency response and filters. For a system with a real impulse response, , and adding the responses to and gives the rule for real sinusoids: The magnitude scales the amplitude and the angle shifts the phase. For the RC low-pass with impulse response , the integral gives , exactly the phasor result from AC and phasors. The phasor method was Fourier analysis all along, applied one frequency at a time.
The program of the rest of the lesson is now clear: learn to write a signal as a sum (or integral) of complex exponentials, and learn what that representation tells you.
Fourier series of periodic signals
A signal is periodic with period if for all . Its fundamental frequency is , or in radians per second. The only complex exponentials with period are the harmonics for integers , so a periodic signal should be a combination of them.
Definition— Fourier series
A periodic signal with period has the Fourier series The first formula is the synthesis equation (build the signal from harmonics); the second is the analysis equation (find how much of each harmonic it contains). The coefficient is the average (DC) value. For a real signal, , and pairing the terms and gives the real form .
Theorem— The analysis formula
If (with the sum converging well enough to integrate term by term), then for every integer .
Proof
The harmonics are orthogonal over one period: for integers , because . For the integrand is 1 and the average is 1. So multiplying the series by and averaging over a period kills every term except .
∎
Example— The square wave
Let for and for . Its average is zero, so . For , using and . So for odd and 0 for even . Pairing with : Only odd harmonics appear (because the second half of each period is the negative of the first), and their amplitudes fall like , slowly, because of the jumps.
The program below computes the coefficients numerically, straight from the analysis integral, and compares them with the formula. Then it adds up the harmonics to see how well the partial sums reproduce the square wave.
import numpy as np
# One period (T = 1) of a square wave: +1 for the first half, -1 for the second.
M = 200_000
t = (np.arange(M) + 0.5) / M # midpoints of M equal slices
x = np.where(t < 0.5, 1.0, -1.0)
def coefficient(k):
"""c_k = (1/T) * integral over one period of x(t) exp(-j 2 pi k t / T) dt, by the midpoint rule."""
return np.mean(x * np.exp(-2j * np.pi * k * t))
print(" k numerical c_k formula 2/(j pi k), odd k")
for k in range(0, 8):
c = np.round(coefficient(k), 5) + 0.0 # + 0.0 turns -0.0 into 0.0
formula = 2 / (1j * np.pi * k) if k % 2 else 0
print(f"{k:2} {c.real:+.5f}{c.imag:+.5f}j {complex(formula).imag:+.5f}j")
# Partial sums S_K(t) = (4/pi) * sum over odd k <= K of sin(2 pi k t) / k.
tt = np.linspace(0, 0.5, 100_001)
print("\nharmonics up to K peak of S_K overshoot (% of the jump) distance of peak from jump")
for K in (1, 3, 9, 19, 99, 999):
S = np.zeros_like(tt)
for k in range(1, K + 1, 2):
S += 4 / np.pi * np.sin(2 * np.pi * k * tt) / k
i = np.argmax(S)
print(f"{K:17} {S[i]:.5f} {100 * (S[i] - 1) / 2:6.2f} {min(tt[i], 0.5 - tt[i]):.4f}")
# Parseval: the power of the square wave is 1; how much is in the first few harmonics?
print("\nharmonics up to K fraction of the power")
for K in (1, 3, 5, 9, 99):
frac = sum(8 / (np.pi ** 2 * k ** 2) for k in range(1, K + 1, 2))
print(f"{K:17} {frac:.4f}")The Gibbs phenomenon
Look at the middle table. As more harmonics are added, the partial sum hugs the square wave more closely almost everywhere, yet the peak next to each jump does not shrink towards 1. It settles at 1.17898, an overshoot of 8.95% of the jump (which is 2 here), and the only thing that changes is where it happens: the peak sits at a distance from the jump, closer and closer, but never lower. This is the Gibbs phenomenon. It happens at every jump of every signal, whatever its shape, because near a jump every signal looks like a square wave.
So in what sense does the series converge? At each fixed point where is continuous, : the overshoot moves past any given point eventually. At a jump, the series converges to the midpoint of the jump (here 0). And the energy of the error, , tends to zero. What fails is uniform convergence: the overshoot of about 0.18 never goes away, so the largest error over a period does not tend to zero.
The Gibbs overshoot is not just a curiosity. Any system that cuts off all frequencies above some limit, an ideal low-pass filter, turns a sharp step into a step with this 9% ringing. That is why Digital filters tapers its filter coefficients with a window instead of truncating them abruptly, and why JPEG images show ripples beside sharp edges.
Power and Parseval
The last table answers a practical question: how much of the square wave's power is in each harmonic? Because the harmonics are orthogonal, their powers add with no cross terms. This is Parseval's relation for Fourier series: For the square wave the left side is 1, and harmonics contribute for odd .
The Fourier transform
A pulse, a spoken word or a single radar echo is not periodic. Imagine stretching the period of a periodic signal to infinity: the harmonics crowd closer together, spaced apart, and the sum over harmonics becomes an integral over all frequencies.
Definition— Fourier transform
The Fourier transform of a signal and its inverse are is the spectrum of : its magnitude says how much of each frequency the signal contains, and its angle says with what phase. Engineers often use ordinary frequency in hertz instead, with : and , which has no to remember. We write for a transform pair.
Notice that the frequency response of the previous section is the Fourier transform of the impulse response . A handful of pairs are worth knowing by heart:
| Signal | Spectrum | Note |
|---|---|---|
| an impulse contains every frequency equally | ||
| for , else 0 | , zeros at | |
| , | the RC circuit's impulse response, up to scale | |
| the Gaussian is its own transform | ||
| a power signal: its spectrum is two impulses |
The transform's usefulness comes from its properties. Each can be proved in a line or two from the definition.
| Property | Time domain | Frequency domain |
|---|---|---|
| Linearity | ||
| Time shift | ||
| Frequency shift (modulation) | ||
| Scaling | ||
| Differentiation | ||
| Convolution | ||
| Multiplication | ||
| Parseval |
Theorem— The convolution theorem
If , then .
Proof
Substitute the convolution into the transform and exchange the order of integration (valid when and are absolutely integrable): The inner integral, with the substitution , is whatever is, so it comes out, leaving .
∎
This is the result promised in the last lesson: convolution in time is multiplication in frequency. A filter's output spectrum is the input spectrum times the frequency response, one frequency at a time. The time-shift property says a delay changes only the phase, by an amount proportional to frequency, never the magnitude. The modulation property is the basis of radio: multiplying by a carrier slides the whole spectrum up to the carrier frequency, as Modulation will show.
The program below checks three of these claims numerically, computing each transform as a Riemann sum of the defining integral.
import numpy as np
dt = 1e-6 # 1 microsecond time step
t = np.arange(-5e-3, 5e-3, dt) + dt / 2 # a 10 ms window of time, midpoints
def ft(x, f):
"""X(f) = integral of x(t) exp(-j 2 pi f t) dt, as a midpoint sum, at each frequency in f."""
return np.array([np.sum(x * np.exp(-2j * np.pi * fk * t)) * dt for fk in f])
tau = 1e-3
rect = np.where(np.abs(t) < tau / 2, 1.0, 0.0) # a 1 ms pulse of height 1, centred at 0
f = np.array([0, 250, 500, 1000, 1500, 2000, 2500])
X = ft(rect, f)
print(" f (Hz) |X(f)| numerical tau |sinc(f tau)|")
for fk, Xk in zip(f, X):
print(f"{fk:8} {abs(Xk) * 1e3:.5f} ms {tau * abs(np.sinc(fk * tau)) * 1e3:.5f} ms")
# Time shift: delay the pulse by 0.4 ms. The magnitude is unchanged; the phase gains -2 pi f t0.
t0 = 0.4e-3
shifted = np.where(np.abs(t - t0) < tau / 2, 1.0, 0.0)
Xs = ft(shifted, np.array([250.0]))[0]
print(f"\nshifted pulse at 250 Hz: |X| = {abs(Xs) * 1e3:.5f} ms, phase = {np.angle(Xs):+.4f} rad,"
f" predicted -2 pi f t0 = {-2 * np.pi * 250 * t0:+.4f} rad")
# Convolution theorem: rect * rect is a triangle; its transform should be X(f)^2.
tri = np.convolve(rect, rect, mode="same") * dt
f2 = np.array([0, 300, 700, 1200])
print("\n f (Hz) transform of rect*rect X(f)^2")
for fk, a, b in zip(f2, ft(tri, f2), ft(rect, f2) ** 2):
print(f"{fk:8} {a.real * 1e6:+.5f} ms^2 {b.real * 1e6:+.5f} ms^2")
# Parseval: energy in time = energy in frequency. How much lies inside the main lobe |f| < 1/tau?
E_time = np.sum(rect ** 2) * dt
df = 0.1 # Hz
ff = np.arange(-1 / tau, 1 / tau, df) + df / 2
E_lobe = np.sum(np.abs(tau * np.sinc(ff * tau)) ** 2) * df
print(f"\nenergy in time: {E_time * 1e3:.4f} ms; fraction inside the main lobe |f| < 1 kHz: {E_lobe / E_time:.4f}")The numerical transform of the 1 ms pulse matches to five figures, with zeros at 1 kHz and 2 kHz. Delaying the pulse by 0.4 ms leaves at 0.90032 ms and turns the phase by exactly rad. The triangle, which is the pulse convolved with itself, has transform . And Parseval's theorem says that 90.28% of the pulse's energy lies in the main lobe of its spectrum, between and kHz.
Spectra and bandwidth
The bandwidth of a signal is, loosely, the width of the range of frequencies it occupies. It matters because every channel, a cable, a radio band, an amplifier, an analogue-to-digital converter, passes only a limited range of frequencies, and the spectrum is a shared and regulated resource. But "the width" of a spectrum like a sinc, which never quite ends, needs a definition, and engineers use several:
- Half-power (3 dB) bandwidth: the width of the band where is at least half its peak, the definition used for filters in Frequency response and filters.
- Null-to-null bandwidth: the width of the main lobe, from the first zero on one side to the first on the other; for a pulse of duration .
- Fractional-energy (occupied) bandwidth: the narrowest band holding a given fraction of the energy, often 99%. Radio regulators use this kind of definition, because it captures the spill into neighbouring channels that the other two ignore.
For real signals the spectrum is symmetric, , and one usually quotes the one-sided bandwidth, counting only positive frequencies. A signal whose spectrum is concentrated near is called baseband; one concentrated around a carrier frequency is bandpass, and its bandwidth is measured around .
Example— Bandwidths of everyday signals
- Speech on a traditional telephone line was limited to about 300–3400 Hz, enough for intelligibility but not for the "s" and "f" sounds, which is why they are easy to confuse on the phone.
- An AM broadcast station occupies about 9 or 10 kHz (the channel spacing in different regions of the world); an FM station about 200 kHz.
- A Wi-Fi channel is 20 MHz wide in its basic form, and Wi-Fi 7 allows channels of up to 320 MHz; a 5G carrier below 7 GHz is up to 100 MHz wide (as of 2026).
- A digital clock edge that rises in 1 ns has significant spectral content up to several hundred megahertz, whatever its clock rate. A first-order system whose 10–90% rise time is has a 3 dB bandwidth of , here 350 MHz, and engineers use the same figure as a rule of thumb for any edge.
The rectangular pulse shows the trade-off at the heart of all of this. Its spectrum has its first zero at : halve the pulse and you double the bandwidth. This is the scaling property at work, : compressing a signal in time stretches its spectrum by the same factor.
The time–bandwidth trade-off
Is there a limit? Could a clever pulse be both very short and very narrow in frequency? No. To make this precise, measure spread by root-mean-square widths. For a pulse centred at whose spectrum is centred at , with energy , define
Theorem— The uncertainty relation (Gabor's form)
For any signal with finite and , , with equality only for Gaussian pulses (up to shifts in time and frequency).
Proof
By the differentiation property and Parseval, . Take real for simplicity. Integrating by parts (the boundary terms vanish when is finite), . The Cauchy–Schwarz inequality gives , that is, , so . Equality in Cauchy–Schwarz needs for a constant , whose solutions are exactly the Gaussians.
∎
The proof also gives a way to compute without computing a transform at all: . The program uses it to measure several pulse shapes. Time is in milliseconds, so comes out in radians per millisecond.
import numpy as np
dt = 2e-5
t = np.arange(-12, 12, dt) + dt / 2 # time in milliseconds, say
def spreads(x):
"""RMS duration and RMS bandwidth (in rad per unit time) of a pulse centred at t = 0.
The bandwidth uses Parseval: integral of w^2 |X|^2 dw / 2 pi equals integral of |x'(t)|^2 dt."""
E = np.sum(x ** 2) * dt
sigma_t = np.sqrt(np.sum(t ** 2 * x ** 2) * dt / E)
dx = np.gradient(x, dt)
sigma_w = np.sqrt(np.sum(dx ** 2) * dt / E)
return sigma_t, sigma_w
pulses = {
"Gaussian, width 0.5": np.exp(-t ** 2 / (2 * 0.5 ** 2)),
"Gaussian, width 0.1": np.exp(-t ** 2 / (2 * 0.1 ** 2)),
"triangle": np.clip(1 - np.abs(t), 0, None),
"raised cosine (Hann)": np.where(np.abs(t) < 1, np.cos(np.pi * t / 2) ** 2, 0.0),
"two-sided e^(-|t|)": np.exp(-np.abs(t)),
}
print(f"{'pulse':22} {'sigma_t':>8} {'sigma_w':>8} {'product':>8}")
for name, x in pulses.items():
st, sw = spreads(x)
print(f"{name:22} {st:8.4f} {sw:8.4f} {st * sw:8.4f}")
print("lower bound: 0.5000, reached only by the Gaussian")Making the Gaussian five times narrower (0.5 to 0.1) makes its bandwidth five times wider (1.41 to 7.07), and the product stays at exactly 0.5. Every other shape does worse: 0.513 for the smooth raised cosine, 0.548 for the triangle, 0.707 for the two-sided exponential with its sharp peak. A rectangular pulse is worse still: its jumps make infinite, because its spectrum falls only as , so its RMS bandwidth is infinite even though its main lobe is finite. That is a reminder that "bandwidth" depends on the definition.
Why engineers care
The same mathematics appears in quantum mechanics as Heisenberg's uncertainty principle, but for an engineer it is a design constraint met daily:
- Radar and sonar. A short pulse locates a target precisely in range but needs a wide bandwidth; a long pulse carries more energy but blurs range. Pulse compression escapes the dilemma by transmitting a long pulse whose frequency sweeps (a chirp): its bandwidth is wide although its duration is long, and a matched filter in the receiver compresses it.
- Digital communications. Sending symbols faster means each is shorter, so the signal needs more bandwidth. OFDM, used by Wi-Fi, 4G and 5G, splits a channel into many narrow subcarriers whose symbols are long. In LTE the subcarriers are 15 kHz apart and each symbol lasts s, a time–bandwidth product of exactly 1 by design.
- Spectrum analysis. To tell apart two tones 1 Hz apart, you must listen for roughly a second. Sampling and the FFT makes this precise as the frequency resolution of the DFT.
- Music. A note that lasts only 10 ms has a spread in frequency of the order of 100 Hz, so a very short note has no clearly defined pitch: drummers' clicks are heard as clicks, not as notes.
Fourier analysis at work
Fourier analysis is so pervasive in electrical engineering that it is almost invisible. A few places it does daily work:
- Instruments. A spectrum analyser displays of a live signal. Classic swept analysers tune a narrow filter across the band; modern ones digitise the signal and compute FFTs, and "real-time" analysers do so fast enough not to miss brief events. Every oscilloscope now has an FFT button.
- Power quality. Rectifiers in computer power supplies and LED drivers draw current in short pulses, which are rich in odd harmonics of 50 or 60 Hz. These harmonic currents heat transformers and distort the grid's voltage, so standards such as IEC 61000-3-2 limit the harmonic currents that equipment may draw, and power-factor-correction circuits reshape the current to be sinusoidal (see Power electronics).
- Compression. Audio codecs (MP3, AAC, Opus) and image and video codecs (JPEG, H.264 and their successors) transform short blocks of the signal into frequency-like coefficients using close relatives of the Fourier transform, then spend bits only on the coefficients that people can perceive.
- Communications. Every radio standard specifies a spectral mask: how much power a transmitter may emit at each offset from its channel. Modulation, filtering and OFDM are all designed in the frequency domain; Modulation and Wireless systems take this up.
- Imaging. An MRI scanner measures the two- or three-dimensional Fourier transform of the body's magnetisation directly, and the image is reconstructed by an inverse transform.
Common misconceptions
Misconception
"Negative frequencies are unphysical, so they can be ignored." For a real signal the negative-frequency half of the spectrum is the mirror image (complex conjugate) of the positive half, so it carries no new information. But it is not zero, and the formulas need it: is half plus half . For complex signals, used throughout radio receivers, positive and negative frequencies are genuinely different.
Misconception
"With enough harmonics the Gibbs overshoot disappears." It gets narrower, not lower: about 9% of the jump for any number of terms. Reducing it needs a different way of summing, for example tapering the high harmonics instead of cutting them off.
Misconception
"Only the magnitude spectrum matters; phase is a detail." Two signals with the same and different phases can look nothing alike: a click and a slow chirp can have identical magnitude spectra. Phase carries the timing: where the edges and events are. For images, keeping the phase and replacing the magnitude produces a recognisable picture, while the reverse does not.
Misconception
"Every signal has a Fourier transform." The defining integral converges for absolutely integrable signals, and the theory extends to finite-energy ones. A sinusoid or a constant needs impulses in the spectrum, and a growing exponential has no Fourier transform at all. That gap is one reason for the Laplace transform of The Laplace transform and stability, which damps the signal first.
Misconception
"A signal's bandwidth is a single, well-defined number." It depends on the definition: 3 dB, null-to-null, 99% energy or RMS. For the rectangular pulse these give finite values except the RMS width, which is infinite. Always ask which definition is meant.
A short history
Fourier submitted his memoir on heat flow to the Paris Academy in 1807; its claim that arbitrary functions could be expanded in sines and cosines troubled Lagrange, and the work appeared in full only in his book of 1822, Théorie analytique de la chaleur. Dirichlet gave the first rigorous conditions for convergence in 1829. The overshoot at jumps was found by the English mathematician Henry Wilbraham in 1848, forgotten, and rediscovered in 1898–99 in an exchange of letters in Nature prompted by Albert Michelson, who had built a mechanical harmonic analyser, and settled by Josiah Willard Gibbs. In the twentieth century the Fourier transform became the language of radio and telephony; in 1946 Dennis Gabor, then working in Britain, framed the time–frequency trade-off for communication engineers in the paper listed in the further reading. The publication of the fast Fourier transform algorithm in 1965 moved the whole subject onto computers, which is where the next lesson goes.
Exercises
1. Fourier series and the Fourier transform
Warm-upHumanA rectangular pulse lasts 2 ms. At what positive frequency, in hertz, is the first zero of its spectrum?
2. Fourier series and the Fourier transform
CoreHumanA 1 kHz square wave switching between V and V passes through an ideal low-pass filter that passes everything below 4 kHz unchanged and blocks everything above. What percentage of the square wave's average power reaches the output? Give the nearest whole number.
3. Fourier series and the Fourier transform
Warm-upHumanYou add more and more harmonics to the Fourier series of a square wave. What happens to the overshoot just beside each jump?
4. Fourier series and the Fourier transform
CoreHumanA pulse is delayed by ms. What happens to its spectrum?
5. Fourier series and the Fourier transform
Warm-upHumanYou want to tell apart two tones at 1000.0 Hz and 1000.5 Hz by measuring the spectrum of a recording. Using the rule of thumb that duration × bandwidth is at least about 1, roughly how many seconds must the recording last?
6. Fourier series and the Fourier transform
CoreComputationalWrite fourier_coefficient(x, k). The array x holds samples of one period of a signal, taken at the midpoints . Return the complex Fourier coefficient , approximated by the midpoint rule. The tests use a square wave, a sawtooth and a shifted cosine.
7. Fourier series and the Fourier transform
CoreComputationalWrite fourier_transform(x, t, f): given samples x of a signal at equally spaced times t (in seconds) and an array of frequencies f (in hertz), return the array of values , approximated by a Riemann sum. The tests check the Gaussian , a rectangular pulse, and the time-shift property.
Further reading and resources
- MIT OpenCourseWare 6.003: Signals and Systems · Dennis Freeman · 2011Lecture notes, recitations and problem sets on Fourier series and transforms for engineers.
- Stanford EE261: The Fourier Transform and its Applications · Brad OsgoodA free lecture course, with notes, that treats the transform with both care and humour.
- Mathematics of the Discrete Fourier Transform · Julius O. Smith IIIA free online book that builds Fourier analysis from complex numbers up, with audio in mind.
- Theory of communication. Part 1: The analysis of information · Dennis Gabor · 1946The paper that brought the time–frequency uncertainty relation into engineering.