Fourier Series & Transforms
Fourier Series & Transforms
Any reasonable signal is a sum of pure rotations — and the complex exponentials are orthogonal, so each rotation's weight can be read off independently by an inner product. That single idea, "project onto a pure frequency," is the whole of Fourier analysis. We build it here in continuous time so the discrete and quantum versions later feel inevitable.
Learning Objectives
By the end of this lesson you will be able to:
- Prove the orthogonality of complex exponentials on an interval and use it to extract Fourier coefficients.
- Compute the complex Fourier series of a periodic function and state the convergence guarantees you can rely on.
- Define the continuous Fourier transform and its inverse, and apply linearity, time/frequency shift, and the convolution theorem.
- Derive Parseval/Plancherel and interpret it as conservation of energy between time and frequency domains.
- Implement a numerical Fourier-series approximation and demonstrate the convolution theorem with
np.fft.
Intuition
Picture a signal — a sound, a voltage, an image row — as a recipe. The Fourier idea is that the recipe is always a blend of pure tones: each tone is a complex rotation spinning at its own frequency , weighted by a complex amplitude that carries both how much (modulus) and what phase (argument). The Fourier transform is the machine that hands you the recipe; the inverse transform stirs the tones back into the signal.
Why does reading off one tone not disturb the others? Because the pure tones are orthogonal: over a full period, and have zero overlap unless . This is the continuous sibling of the roots-of-unity vanishing sum from lesson 1 — distinct frequencies average to nothing. Orthogonality is what makes "project onto frequency " a clean, independent measurement, exactly as orthonormal basis vectors let you read off coordinates in linear algebra.
Two domains, one object. The time domain answers "what is the value now?"; the frequency domain answers "what is it made of?" Operations that are tangled in one domain become trivial in the other — most spectacularly, convolution (smearing/filtering, expensive in time) becomes plain multiplication in frequency. Keep this dual picture in mind; the discrete version in lesson 3 turns it into an algorithm, and the quantum version turns that algorithm into a circuit.
Theory
Orthogonality of complex exponentials
Work on the interval and define, for integer , the functions . These are exactly the tones whose period divides . Equip the space of (square-integrable) functions on with the Hermitian inner product (conjugate the left factor, matching Appendix C §1):
Lemma (orthogonality).
Proof. The integrand is . If it equals and integrates to . Otherwise let and integrate the exponential:
since for integer .
This is the continuous analog of the roots-of-unity orthogonality $\tfrac1N\sum_x \omega^{x(j-k)} = \delta_{jk}N$ sample points by an integral over the period. The form an orthonormal family.
Fourier series of a periodic function
Let be -periodic and square-integrable on a period. Because is a complete orthogonal system (a theorem of analysis we use, not reprove), has the complex Fourier series
The coefficients fall out of orthogonality: take the inner product of both sides with and use the lemma. Only the term survives,
so the analysis formula is
Each is the (normalized) overlap of with the pure tone of frequency — the amount of that tone in the blend. Note is the average (DC) value.
Reality and symmetry. If is real then (conjugate-symmetric spectrum), because conjugating the integrand flips the sign of the exponent. Pairing then recovers the familiar real sine/cosine series:
Convergence (what you can rely on). For the partial sums converge to in the (mean-square) sense: . If is piecewise-, the series converges pointwise to where is continuous and to the midpoint at jumps; near a jump the partial sums overshoot by a fixed (the Gibbs phenomenon), which never disappears but moves toward the jump as grows. We will see Gibbs in the code.
The continuous Fourier transform
Let the period : the discrete frequencies crowd into a continuum , the sum becomes an integral, and the Fourier series becomes the Fourier transform. For an integrable (or ) function we use the convention
with frequency in cycles per unit time, and the inversion formula
The kernel and the sign convention match the DFT forward/inverse pair in lesson 3 and the program-wide choice in Appendix C §4 (no stray factors with this "ordinary frequency" convention — a convenience we exploit below).
Key properties
Let , , and . The following are direct consequences of the integral definition.
Linearity. (the integral is linear).
Time shift. .
Proof. Substitute , : . A delay in time is a linear phase in frequency — modulus unchanged, phase tilted. (The relative-phase intuition from lesson 1 reappears: shifting a signal does not change its energy spectrum, only its phases.)
Frequency shift (modulation). — multiplying by a tone in time slides the spectrum (dual of the time-shift rule).
Convolution theorem. Define the convolution $(f * g)(t) = \int_{-\infty}^{\infty} f(\tau),g(t-\tau),d\tau$. Then
Proof. Write out and swap the order of integration (justified for functions by Fubini):
The inner integral is the time-shift rule: $\int_t g(t-\tau)e^{-i2\pi\xi t}dt = e^{-i2\pi\xi\tau} \hat g(\xi)$. Hence
This is the property that makes the FFT a workhorse of computation: convolution costs directly but via "transform, multiply, inverse-transform." We use it in the code.
Parseval / Plancherel — derivation. With the ordinary-frequency convention above, the transform preserves energy:
Proof. Start from the left and write , expressing by inversion and by the conjugate of inversion:
Swap the order of integration (Fubini) and group the -integral:
The bracket is just the forward transform . The polarized version (Plancherel) follows identically with in place of the second — i.e. the Fourier transform is unitary on , an inner-product-preserving map. This is the continuous shadow of the fact, proved in lesson 3, that the normalized DFT matrix is unitary — and ultimately of why the Quantum Fourier Transform is a legal (unitary) quantum operation.
Reading the frequency domain
The spectrum is itself complex: is the magnitude spectrum (how much energy at frequency ) and is the phase spectrum (the alignment of that component). Sharp features in time spread out in frequency and vice versa — a delta in time is flat in frequency; a single tone in time is a spike in frequency. This reciprocity (formalized by the uncertainty principle and by the sampling theorem in lesson 3) is the recurring theme: localizing in one domain costs spread in the other.
Worked Examples
Example 1 — Fourier series of a square wave
Let be the odd square wave of period with on and on (so -periodic). Compute its complex coefficients $c_n = \tfrac1T\int_{-\pi}^{\pi} f(t)e^{-int},dt2\pi n/T = n$).
For : (equal and areas; zero average).
For , split the integral and use :
The first integral is ; the second is . Using and simplifying,
So for even and for odd . Reassembling the real series (pairing , only odd survive) gives the classic
Only odd harmonics appear (by the symmetry ), and their amplitudes decay like — slow decay characteristic of a jump discontinuity, which is why truncating the series produces Gibbs overshoot near .
Example 2 — Transform of a Gaussian (a fixed point)
Let . Its transform is itself:
Sketch. Complete the square in the exponent: . Pulling out leaves , which equals (the Gaussian integral, with a contour-shift justification). Hence . The Gaussian is the eigenfunction with eigenvalue : maximally "spread-balanced" between domains, the extremal case of the time–frequency reciprocity. (Wide Gaussians in time become narrow in frequency and vice versa, as the scaling property shows.)
Example 3 — Convolution as filtering
Let be a normalized box of width : for , else . Then $(f * g)(t) = \tfrac1w\int_{t-w/2}^{t+w/2} f(\tau),d\tauf$ — a smoother. Its transform is, by the convolution theorem, where $\hat g(\xi) = \operatorname{sinc}(w\xi) = \sin(\pi w\xi)/(\pi w\xi)\hat g\xi=0$, multiplication suppresses high frequencies: smoothing in time = low-pass filtering in frequency. This is the entire logic of digital filtering, and the next code cell verifies it numerically.
Hands-on (Python)
import numpy as np
import matplotlib.pyplot as plt
# =====================================================================
# 1. Numerically approximate a Fourier series (square wave) and see Gibbs
# =====================================================================
def square_wave(t):
"""Odd square wave, period 2π: +1 on (0, π), -1 on (-π, 0)."""
return np.sign(np.sin(t))
def fourier_partial_sum(t, M):
"""Sum the odd harmonics through (2M-1): (4/π) Σ sin((2k+1)t)/(2k+1)."""
out = np.zeros_like(t)
for k in range(M):
n = 2 * k + 1
out += np.sin(n * t) / n
return (4 / np.pi) * out
t = np.linspace(-np.pi, np.pi, 2000, endpoint=False)
plt.figure(figsize=(8, 4))
plt.plot(t, square_wave(t), "k--", lw=1, label="target square wave")
for M in (1, 3, 10, 50):
plt.plot(t, fourier_partial_sum(t, M), lw=1, label=f"M={M} harmonics")
plt.title("Fourier partial sums → square wave (note Gibbs overshoot at jumps)")
plt.xlabel("t"); plt.ylabel("f(t)"); plt.legend(fontsize=8); plt.tight_layout(); plt.show()
# Cross-check the *coefficients* numerically against the closed form 2/(iπn) for odd n.
# square_wave(t) = sign(sin t) is exactly the Example-1 signal: +1 on (0,π), -1 on (π,2π).
T = 2 * np.pi
M = 200_000
ts = np.linspace(0, T, M, endpoint=False) # one period, uniform grid
dt = T / M
f = square_wave(ts)
for n in (1, 2, 3, 5):
# cn = (1/T)∫_0^T f e^{-int} dt, as a Riemann sum (version-robust; np.trapz was
# removed in NumPy 2.0). For odd n this matches 2/(iπn); for even n it is 0.
cn = np.sum(f * np.exp(-1j * n * ts)) * dt / T
closed = (1 - (-1) ** n) / (1j * np.pi * n) # = 2/(iπn) for odd n, 0 for even n
print(f"n={n}: numeric c_n = {cn: .4f} closed form = {closed: .4f}")
# =====================================================================
# 2. Demonstrate the convolution theorem with np.fft
# Claim: conv(f, g) == IFFT( FFT(f) * FFT(g) ) (circular convolution)
# =====================================================================
rng = np.random.default_rng(0)
N = 256
f = rng.standard_normal(N) # a noisy signal
# A small normalized box kernel (moving-average / low-pass filter), zero-padded to length N.
w = 9
g = np.zeros(N); g[:w] = 1.0 / w
# (a) Direct CIRCULAR convolution (matches what the DFT computes):
direct = np.array([np.sum(f * np.roll(g[::-1], k + 1)) for k in range(N)])
# (b) Via the convolution theorem: multiply spectra, transform back.
via_fft = np.fft.ifft(np.fft.fft(f) * np.fft.fft(g)).real
print("\nconvolution theorem holds:",
np.allclose(direct, via_fft, atol=1e-10)) # True
# Show that convolving with the box suppresses high-frequency content (low-pass).
F = np.fft.rfft(f)
FG = np.fft.rfft(via_fft)
freq = np.fft.rfftfreq(N)
plt.figure(figsize=(8, 4))
plt.plot(freq, np.abs(F), label="|FFT(signal)|")
plt.plot(freq, np.abs(FG), label="|FFT(signal ∗ box)|")
plt.title("Convolution with a box = multiplication by a sinc = low-pass filter")
plt.xlabel("frequency"); plt.ylabel("magnitude"); plt.legend(); plt.tight_layout(); plt.show()What you should observe: the partial sums visibly converge to the square wave, with the persistent
~9% Gibbs overshoot hugging the jumps as grows; the numerically computed match
for odd and vanish for even ; np.allclose(direct, via_fft) prints True, confirming
; and the filtered spectrum is visibly attenuated at high
frequencies — convolution in time is multiplication in frequency.
Note on circular vs. linear convolution.
np.fftcomputes circular convolution (the DFT treats data as one period of a periodic signal — see lesson 3). For linear convolution, zero-pad both inputs to length before transforming. This periodicity is the bridge from the continuous theory here to the discrete machinery next.
Exercises
1. (Easy) Linearity and shift. Given , write the transform of $h(t) = 3f(t) - f(t-5)\hat f$.
Solution
By linearity and the time-shift rule, $\hat h(\xi) = 3\hat f(\xi) - e^{-i2\pi\xi\cdot 5}\hat f(\xi) = \big(3 - e^{-i10\pi\xi}\big)\hat f(\xi)$. The delay contributes a frequency-dependent phase factor ; the magnitude spectrum is reshaped by .
2. (Easy) DC coefficient. Show that the Fourier coefficient equals the average of over a period, and compute it for .
Solution
, which is the mean by definition. For the cosine integrates to over a full period, leaving . (The contributes each, since .)
3. (Medium) Parseval for a finite series. For a real -periodic with coefficients , prove the series form of Parseval: .
Solution
Write and with . Then
using the orthogonality lemma . Energy in time = energy in the coefficients.
4. (Medium) Convolution by hand. Let (indicator of ). Compute directly and confirm via the convolution theorem that its transform is .
Solution
= length of the overlap of and . This is the triangle function: for , rising as for , falling as for , and for . For the transform, $\hat f(\xi) = \int_0^1 e^{-i2\pi\xi t}dt = \frac{1-e^{-i2\pi\xi}}{i2\pi\xi} = e^{-i\pi\xi} \operatorname{sinc}(\xi)\operatorname{sinc}(\xi)=\sin\pi\xi/\pi\xi$). By the convolution theorem , the well-known transform of a triangle (a squared sinc) — consistent with the direct computation.
5. (Hard) Plancherel ⇒ unitarity intuition. Using the convention in this lesson, show that the operator preserves the inner product , i.e. , and explain in one sentence why this is the continuous analog of "the DFT matrix is unitary."
Solution
Repeat the Parseval derivation with in the second slot: expand $\langle f,g\rangle = \int_t f(t)^{}g(t),dtg(t) = \int_\xi \hat g(\xi)e^{i2\pi\xi t}d\xi$, swap integrals (Fubini), and recognize $\int_t f(t)^{}e^{i2\pi\xi t}dt = \big(\int_t f(t)e^{-i2\pi\xi t}dt\big)^{} = \hat f(\xi)^{}\int_\xi \hat f(\xi)^{*}\hat g(\xi),d\xi = \langle\hat f,\hat g\rangle$. Preserving the inner product is exactly the defining property of a unitary operator (); in finite dimensions the same statement is "the normalized DFT matrix satisfies ," proved in lesson 3.
6. (Hard) Smoothness ⇒ decay. Argue that if is -periodic and (k continuous derivatives), then its Fourier coefficients satisfy as . Connect this to the slow decay seen for the (discontinuous) square wave.
Solution
Integrate the coefficient formula by parts. Each integration by parts moves a derivative off the exponential and onto : $\int_0^T f(t)e^{-i2\pi n t/T}dt = \frac{T}{i2\pi n}\int_0^T f'(t)e^{-i2\pi n t/T}dtc_n = \frac{T}{i2\pi n}\cdot c_n^{(f')}i2\pi n/T$; equivalently a smooth has bounded coefficients, so for . Repeating times gives $c_n = O(|n|^{-k})f^{(k)}\in L^2k=0$ effectively, with a jump), so its coefficients decay only like — the slowest case — which is precisely why its truncated series converges slowly and exhibits Gibbs overshoot. Smoothness in time ⇔ rapid decay in frequency, the reciprocity theme again.
Checkpoint
1. State the orthogonality relation for $e_n(t)=e^{i2\pi nt/T}$ on $[0,T]$ and why it matters.
. It lets you read off each Fourier coefficient independently by an inner product: — projecting onto one pure frequency without interference from the others.
2. Write the analysis and synthesis formulas for the continuous Fourier transform (this lesson's convention).
Analysis: . Synthesis (inverse): $f(t) = \int \hat f(\xi)e^{+i2\pi\xi t}d\xi\mp1/2\pi$ factors match the program's DFT/QFT conventions.
3. What does the convolution theorem say, and why is it computationally important?
: convolution in time is pointwise multiplication in frequency. It turns an convolution into "FFT, multiply, inverse-FFT," which is .
4. State Parseval/Plancherel and interpret it physically.
(and ). Total energy is conserved between time and frequency domains; equivalently, is unitary on .
5. Why does a time delay leave the magnitude spectrum unchanged?
Because : the delay multiplies by a unit-modulus phase factor, so is unchanged and only the phase spectrum tilts.
6. How does this continuous theory foreshadow the quantum Fourier transform?
The Fourier transform is unitary (Plancherel), built from orthogonal complex exponentials, and diagonalizes convolution. Its finite-dimensional version (the DFT, lesson 3) is a unitary matrix, and the quantum version implements that same unitary on amplitudes — see Term 2.4.
Further Reading
- [NC, §A4] — Fourier analysis appendix; the orthogonality and transform conventions the program uses.
- [KLM, Ch. 6] — Fourier transform as preparation for the QFT and phase estimation.
- Appendix E §6 — geometric sums, orthogonality, the QFT kernel.
- Appendix B §1–2 — complex arrays and inner products used in the code.
← Prev: Complex Numbers & Functions · Up: Term 0 · Next: The Discrete Fourier Transform →