Blog · updated 18 Nov 2026 · 100 min read

Fourier analysis, from first principles

What a frequency is, why sinusoids and no other basis, how to derive any Fourier pair you need, why partial sums overshoot, and how to read the spectrum of an image. Part 1 of Seeing in frequencies: every step derived, with figures that run live on my own sketches.

Contents
  1. Notation and conventions
  2. 1. Start from what you trust: coordinates
  3. 2. Functions are vectors
  4. 3. Fourier series
  5. Negative frequencies are a direction of rotation
  6. The square wave, by hand
  7. 4. How good is a partial sum?
  8. In energy: always
  9. Pointwise: the Gibbs phenomenon
  10. Smoothness is decay
  11. 5. Why sinusoids? The real reason
  12. 6. From series to transform
  13. 7. Properties, each with a proof
  14. 8. Filters and what “frequency response” means
  15. 9. Images: the 2-D Fourier transform
  16. The projection–slice theorem
  17. 10. Amplitude versus phase
  18. 11. What Fourier cannot tell you
  19. 12. Implementation and caveats
  20. 13. Where it is used, and what is open
  21. Self-check
  22. References

Seeing in frequencies, part 1 of 4. Fourier analysis → the discrete Fourier world (sampling, the FFT, the uncertainty principle) → wavelets → wavelets for images. Two earlier posts, random wavelet features and Fourier and wavelets on the sphere, become the applied end of the series.

Here is the outline of a tree I drew, traced once around as a point z(t)z(t) in the complex plane. Every closed curve like it is a sum of circles: each circle turns at a whole number of turns per lap, and placed tip to tail, largest first, the last tip draws the tree.

One circle gets within 28% of the tree, twenty within 3.7%, a hundred within 0.6% (the error, in the corner, is the relative L2L^2 distance; Section 4 explains why it costs nothing to compute). By the end of this post you will be able to say exactly what those circles are, why circles and not some other shape, and what the same idea does to an image.

This post is for anyone in computer vision or applied mathematics who uses Fourier transforms and wants to understand them. It assumes calculus and a little linear algebra; every other step is derived, in folded proofs with numbered steps. The thread is one idea: a Fourier coefficient is a coordinate. Section 1 recalls what coordinates are. Sections 2 to 4 build the Fourier series and test how good it is. Section 5 answers the question most courses skip, why sinusoids. Sections 6 to 8 move to the Fourier transform, its properties and filters. Sections 9 and 10 do all of it for images, on four of my sketches. Section 11 is about what Fourier analysis cannot do, which is where the rest of the series begins.

Notation and conventions

SymbolMeaning
xxposition or time; x=(x,y)\boldsymbol{x} = (x, y) in 2-D
ξ\xifrequency, in cycles per unit; ξ=(ξ,η)\boldsymbol{\xi} = (\xi, \eta) in 2-D
ek(x)=e2πikxe_k(x) = e^{2\pi i k x}the Fourier basis on [0,1)[0, 1)
⟨f,g⟩=∫f g‾\langle f, g\rangle = \int f\, \overline{g}inner product
ck=⟨f,ek⟩c_k = \langle f, e_k \rangleFourier coefficient
SNf=∑∣k∣≤NckekS_N f = \sum_{\lvert k\rvert \le N} c_k e_kpartial sum
f^(ξ)=∫f(x) e−2πixξ dx\hat f(\xi) = \int f(x)\, e^{-2\pi i x \xi}\, dxFourier transform
(f∗g)(x)=∫f(y) g(x−y) dy(f * g)(x) = \int f(y)\, g(x - y)\, dyconvolution
rect⁡(x)\operatorname{rect}(x)11 for ∣x∣<12\lvert x \rvert < \tfrac12, else 00
sinc⁡(ξ)\operatorname{sinc}(\xi)sin⁡(πξ)/(πξ)\sin(\pi\xi)/(\pi\xi), with sinc⁡(0)=1\operatorname{sinc}(0) = 1

Vectors are bold italic, matrices bold upright. Frequencies are in cycles per unit, not radians, so the transform and its inverse carry no stray factors of 2π2\pi; Section 6 has a table for translating to the ω\omega convention used in many textbooks.

1. Start from what you trust: coordinates

Take a vector v\boldsymbol{v} in the plane and two unit vectors u1,u2\boldsymbol{u}_1, \boldsymbol{u}_2 at right angles. Three facts about them will carry the whole post.

Proposition 1 (Coordinates in an orthonormal basis)

If ⟨ui,uj⟩=1\langle \boldsymbol{u}_i, \boldsymbol{u}_j\rangle = 1 when i=ji = j and 00 otherwise, then for every v\boldsymbol{v}:

  1. its coordinates are inner products, ai=⟨v,ui⟩a_i = \langle \boldsymbol{v}, \boldsymbol{u}_i\rangle;
  2. it is rebuilt from them, v=a1u1+a2u2\boldsymbol{v} = a_1 \boldsymbol{u}_1 + a_2 \boldsymbol{u}_2;
  3. its squared length is the sum of squared coordinates, ∥v∥2=a12+a22\lVert\boldsymbol{v}\rVert^2 = a_1^2 + a_2^2.
Proof

Step 1. Write v\boldsymbol{v} in the basis. Two orthonormal vectors in the plane span it, so v=a1u1+a2u2\boldsymbol{v} = a_1\boldsymbol{u}_1 + a_2\boldsymbol{u}_2 for some numbers a1,a2a_1, a_2. This is fact 2, once we know what the aia_i are.

Step 2. Take the inner product with u1\boldsymbol{u}_1. By linearity, ⟨v,u1⟩=a1⟨u1,u1⟩+a2⟨u2,u1⟩=a1⋅1+a2⋅0=a1\langle \boldsymbol{v}, \boldsymbol{u}_1\rangle = a_1\langle \boldsymbol{u}_1, \boldsymbol{u}_1\rangle + a_2\langle \boldsymbol{u}_2, \boldsymbol{u}_1\rangle = a_1 \cdot 1 + a_2 \cdot 0 = a_1. The same with u2\boldsymbol{u}_2 gives a2a_2. This is fact 1.

Step 3. Expand the length. ∥v∥2=⟨a1u1+a2u2, a1u1+a2u2⟩=a12⟨u1,u1⟩+2a1a2⟨u1,u2⟩+a22⟨u2,u2⟩=a12+a22\lVert\boldsymbol{v}\rVert^2 = \langle a_1\boldsymbol{u}_1 + a_2\boldsymbol{u}_2,\, a_1\boldsymbol{u}_1 + a_2\boldsymbol{u}_2\rangle = a_1^2\langle\boldsymbol{u}_1,\boldsymbol{u}_1\rangle + 2a_1a_2\langle\boldsymbol{u}_1,\boldsymbol{u}_2\rangle + a_2^2\langle\boldsymbol{u}_2,\boldsymbol{u}_2\rangle = a_1^2 + a_2^2. This is fact 3: Pythagoras.

Example 1 (By hand)

Let v=(3,1)\boldsymbol{v} = (3, 1), u1=(1,1)/2\boldsymbol{u}_1 = (1, 1)/\sqrt2 and u2=(−1,1)/2\boldsymbol{u}_2 = (-1, 1)/\sqrt2. Then a1=(3+1)/2=22a_1 = (3 + 1)/\sqrt2 = 2\sqrt2 and a2=(−3+1)/2=−2a_2 = (-3 + 1)/\sqrt2 = -\sqrt2. Rebuild: 22 u1−2 u2=(2,2)−(−1,1)=(3,1)2\sqrt2\,\boldsymbol{u}_1 - \sqrt2\,\boldsymbol{u}_2 = (2, 2) - (-1, 1) = (3, 1). Lengths: a12+a22=8+2=10=32+12a_1^2 + a_2^2 = 8 + 2 = 10 = 3^2 + 1^2.

a coordinate is a shadowu₁u₂va₁ = ⟨v, u₁⟩ = 2√2a₂ = ⟨v, u₂⟩ = −√2the same move, for functions:cₖ = ⟨f, eₖ⟩ = ∫ f(x) e−2πikx dxv = a₁u₁ + a₂u₂ ⟶ f = Σ cₖ eₖ|v|² = a₁² + a₂² ⟶ ‖f‖² = Σ |cₖ|²(check: 8 + 2 = 10 = 3² + 1²)coefficient = shadow, rebuild = sum,energy = Pythagoras

A coordinate is a shadow: drop a perpendicular from v\boldsymbol{v} onto an axis and measure where it lands. Nothing in the three facts needed the plane or two dimensions, only an inner product and an orthonormal set. Fourier analysis is these three facts again, with functions in place of arrows.

2. Functions are vectors

Functions on [0,1)[0, 1) add and scale like vectors: (f+g)(x)=f(x)+g(x)(f + g)(x) = f(x) + g(x) and (af)(x)=af(x)(af)(x) = af(x). What they need to become geometry is an inner product.

Definition 1 (Inner product and norm of functions)

For square-integrable complex functions on [0,1)[0, 1),

⟨f,g⟩=∫01f(x) g(x)‾ dx,∥f∥=⟨f,f⟩=(∫01∣f(x)∣2 dx)1/2.\langle f, g\rangle = \int_0^1 f(x)\, \overline{g(x)}\, dx, \qquad \lVert f\rVert = \sqrt{\langle f, f\rangle} = \Big(\int_0^1 \lvert f(x)\rvert^2\, dx\Big)^{1/2}.

The set of functions with ∥f∥<∞\lVert f \rVert < \infty is called L2[0,1)L^2[0, 1).

The bar on gg is there so that ⟨f,f⟩=∫∣f∣2\langle f, f\rangle = \int \lvert f\rvert^2 is real and non-negative, as a squared length must be. Think of ∫01f g‾\int_0^1 f\,\overline{g} as the dot product ∑ifigi‾\sum_i f_i \overline{g_i} with infinitely many, densely packed coordinates fi=f(xi)f_i = f(x_i).

Our basis will be the complex exponentials, and we need one fact about them first.

Definition 2 (The Fourier basis)

For each integer kk, ek(x)=e2πikx=cos⁡(2πkx)+isin⁡(2πkx)e_k(x) = e^{2\pi i k x} = \cos(2\pi k x) + i \sin(2\pi k x).

Lemma 1 (Euler’s formula)

For real θ\theta, eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta.

Proof

Here ez=∑n≥0zn/n!e^{z} = \sum_{n \ge 0} z^n / n!, which converges for every complex zz and can be differentiated term by term, so ddθeiθ=ieiθ\frac{d}{d\theta} e^{i\theta} = i e^{i\theta} and ddθe−iθ=−ie−iθ\frac{d}{d\theta} e^{-i\theta} = -i e^{-i\theta}.

Step 1. A function that should be constant. Let g(θ)=e−iθ(cos⁡θ+isin⁡θ)g(\theta) = e^{-i\theta}(\cos\theta + i\sin\theta).

Step 2. Differentiate with the product rule. g′(θ)=−ie−iθ(cos⁡θ+isin⁡θ)+e−iθ(−sin⁡θ+icos⁡θ)=e−iθ(−icos⁡θ+sin⁡θ−sin⁡θ+icos⁡θ)=0g'(\theta) = -i e^{-i\theta}(\cos\theta + i\sin\theta) + e^{-i\theta}(-\sin\theta + i\cos\theta) = e^{-i\theta}\big(-i\cos\theta + \sin\theta - \sin\theta + i\cos\theta\big) = 0.

Step 3. So gg is constant, equal to g(0)=1⋅(1+0)=1g(0) = 1 \cdot (1 + 0) = 1. Multiply g(θ)=1g(\theta) = 1 by eiθe^{i\theta} (using eiθe−iθ=e0=1e^{i\theta}e^{-i\theta} = e^0 = 1, which follows from the series): cos⁡θ+isin⁡θ=eiθ\cos\theta + i\sin\theta = e^{i\theta}.

Proposition 2 (The eₖ are orthonormal)

⟨ek,el⟩=1\langle e_k, e_l\rangle = 1 if k=lk = l, and 00 if k≠lk \ne l.

Proof

Step 1. Multiply. ek(x) el(x)‾=e2πikxe−2πilx=e2πimxe_k(x)\,\overline{e_l(x)} = e^{2\pi i k x} e^{-2\pi i l x} = e^{2\pi i m x} with m=k−lm = k - l, an integer. (The conjugate of eiαe^{i\alpha} is cos⁡α−isin⁡α=e−iα\cos\alpha - i\sin\alpha = e^{-i\alpha}.)

Step 2. If m=0m = 0, the integrand is 11 and ∫011 dx=1\int_0^1 1\, dx = 1.

Step 3. If m≠0m \ne 0, an antiderivative is e2πimx/(2πim)e^{2\pi i m x}/(2\pi i m), so ∫01e2πimxdx=e2πim−12πim=0\int_0^1 e^{2\pi i m x} dx = \frac{e^{2\pi i m} - 1}{2\pi i m} = 0, because e2πim=cos⁡(2πm)+isin⁡(2πm)=1e^{2\pi i m} = \cos(2\pi m) + i\sin(2\pi m) = 1 for every integer mm.

Question 1

Why complex exponentials and not plain sines and cosines?

Answer

Both work. The real set {1,2cos⁡2πkx,2sin⁡2πkx}k≥1\{1, \sqrt2\cos 2\pi k x, \sqrt2\sin 2\pi kx\}_{k \ge 1} is also orthonormal and gives the same expansions. A wave of one frequency has two numbers, an amplitude and a phase, and a complex coefficient stores exactly those two. The complex form is tidier for three reasons that appear below: products of exponentials add frequencies (ekel=ek+le_k e_l = e_{k+l}); a shift multiplies eke_k by a constant (Section 5), where it would mix a sine with a cosine; and one formula covers every coefficient.

So what does a Fourier coefficient measure? By fact 1, it is the inner product ⟨f,ek⟩=∫01f(x)cos⁡(2πkx) dx−i∫01f(x)sin⁡(2πkx) dx\langle f, e_k\rangle = \int_0^1 f(x)\cos(2\pi kx)\,dx - i\int_0^1 f(x)\sin(2\pi kx)\,dx: multiply the signal by a probe wave and add up the area. Try it.

The signal is f(x)=0.9cos⁡(2π⋅3x−0.7)+0.5cos⁡(2π⋅7x+1.2)f(x) = 0.9\cos(2\pi\cdot 3x - 0.7) + 0.5\cos(2\pi\cdot 7x + 1.2). At k=3k = 3 the product stays mostly on one side of zero and the areas add; at any other whole number they cancel exactly. That cancellation is orthogonality. The inset shows c(k)c(k) moving in the complex plane as you slide kk: it sits at the origin for every integer except 33 and 77, where it jumps out to a point whose length is half the wave’s amplitude and whose angle is its phase. Half, because the other half lives at −k-k, which is the subject of the next section.

3. Fourier series

Apply the three facts of Section 1 with ui\boldsymbol{u}_i replaced by eke_k.

Definition 3 (Fourier coefficients and partial sums)

For f∈L2[0,1)f \in L^2[0, 1) (extended periodically to the whole line),

ck=⟨f,ek⟩=∫01f(x) e−2πikx dx,SNf(x)=∑k=−NNck e2πikx.c_k = \langle f, e_k\rangle = \int_0^1 f(x)\, e^{-2\pi i k x}\, dx, \qquad S_N f(x) = \sum_{k=-N}^{N} c_k\, e^{2\pi i k x}.

The Fourier series of ff is the limit of SNfS_N f as N→∞N \to \infty.

With infinitely many basis functions there is a new question: does the sum get back to ff? Fact 2 needs care, and Section 4 answers it. Before that, two things the partial sum gets right for every NN.

Proposition 3 (The partial sum is the best approximation)

Among all trigonometric polynomials p=∑∣k∣≤Nbkekp = \sum_{\lvert k\rvert \le N} b_k e_k, the partial sum SNfS_N f is the closest to ff:

∥f−p∥2=∥f−SNf∥2+∑∣k∣≤N∣ck−bk∣2  ≥  ∥f−SNf∥2.\lVert f - p\rVert^2 = \lVert f - S_N f\rVert^2 + \sum_{\lvert k\rvert \le N} \lvert c_k - b_k\rvert^2 \;\ge\; \lVert f - S_N f\rVert^2 .

Taking p=0p = 0 gives Bessel’s inequality, ∑∣k∣≤N∣ck∣2≤∥f∥2\sum_{\lvert k\rvert \le N} \lvert c_k\rvert^2 \le \lVert f\rVert^2.

Proof

Step 1. The error is orthogonal to every eke_k with ∣k∣≤N\lvert k\rvert \le N. ⟨f−SNf,ek⟩=⟨f,ek⟩−∑∣l∣≤Ncl⟨el,ek⟩=ck−ck=0\langle f - S_N f, e_k\rangle = \langle f, e_k\rangle - \sum_{\lvert l\rvert \le N} c_l\langle e_l, e_k\rangle = c_k - c_k = 0, by orthonormality.

Step 2. So it is orthogonal to SNf−pS_N f - p, which is the combination ∑∣k∣≤N(ck−bk)ek\sum_{\lvert k\rvert \le N}(c_k - b_k)e_k of those eke_k.

Step 3. Pythagoras. Write f−p=(f−SNf)+(SNf−p)f - p = (f - S_N f) + (S_N f - p). Expanding ∥f−p∥2\lVert f - p\rVert^2, the two cross terms are inner products of orthogonal functions and vanish, leaving ∥f−SNf∥2+∥SNf−p∥2\lVert f - S_N f\rVert^2 + \lVert S_N f - p\rVert^2.

Step 4. The last term, by fact 3 for the orthonormal eke_k, is ∑∣k∣≤N∣ck−bk∣2\sum_{\lvert k\rvert \le N}\lvert c_k - b_k\rvert^2.

Step 5. Bessel. With p=0p = 0 (all bk=0b_k = 0): ∥f∥2=∥f−SNf∥2+∑∣k∣≤N∣ck∣2≥∑∣k∣≤N∣ck∣2\lVert f\rVert^2 = \lVert f - S_N f\rVert^2 + \sum_{\lvert k\rvert \le N}\lvert c_k\rvert^2 \ge \sum_{\lvert k\rvert \le N}\lvert c_k\rvert^2.

Negative frequencies are a direction of rotation

Ask a room of engineers what a negative frequency is and someone will say a mathematical artefact. It is a direction of rotation. As xx increases, e2πikxe^{2\pi i k x} walks around the unit circle ∣k∣\lvert k\rvert times per unit: anticlockwise if k>0k > 0, clockwise if k<0k < 0. A real oscillation moves back and forth on a line, and a single rotating point cannot do that. Two can, if they turn in opposite directions at the same speed.

Two phasors of length ½, turning in opposite directions and placed tip to tail. Their imaginary parts cancel, so the sum slides along the real axis; its history is the cosine.

Proposition 4 (A real signal pairs every frequency with its negative)

If ff is real-valued, then c−k=ck‾c_{-k} = \overline{c_k} for every kk, the mean c0c_0 is real, and each pair of terms is one real wave:

ck e2πikx+c−k e−2πikx=2∣ck∣cos⁡ ⁣(2πkx+arg⁡ck).c_k\, e^{2\pi i k x} + c_{-k}\, e^{-2\pi i k x} = 2\lvert c_k\rvert \cos\!\big(2\pi k x + \arg c_k\big).

Equivalently, f(x)=c0+∑k≥1(akcos⁡2πkx+bksin⁡2πkx)f(x) = c_0 + \sum_{k \ge 1}\big(a_k\cos 2\pi kx + b_k \sin 2\pi kx\big) with ak=2Re⁡ck=2∫01f(x)cos⁡2πkx dxa_k = 2\operatorname{Re} c_k = 2\int_0^1 f(x)\cos 2\pi kx\, dx and bk=−2Im⁡ck=2∫01f(x)sin⁡2πkx dxb_k = -2\operatorname{Im} c_k = 2\int_0^1 f(x)\sin 2\pi kx\, dx.

Proof

Step 1. Conjugate the definition. The conjugate of an integral is the integral of the conjugate: ck‾=∫01f(x)‾  e−2πikx‾ dx\overline{c_k} = \int_0^1 \overline{f(x)}\;\overline{e^{-2\pi i k x}}\, dx.

Step 2. Use that ff is real. f(x)‾=f(x)\overline{f(x)} = f(x) and e−iα‾=eiα\overline{e^{-i\alpha}} = e^{i\alpha}, so ck‾=∫01f(x) e2πikx dx\overline{c_k} = \int_0^1 f(x)\, e^{2\pi i k x}\, dx.

Step 3. Recognise c−kc_{-k}. By definition c−k=∫01f(x) e−2πi(−k)x dxc_{-k} = \int_0^1 f(x)\, e^{-2\pi i(-k)x}\, dx, the same integral. So c−k=ck‾c_{-k} = \overline{c_k}, and with k=0k = 0, c0=c0‾c_0 = \overline{c_0} is real.

Step 4. Add the pair. With α=2πkx\alpha = 2\pi kx, the second term is ck‾ eiα‾=ckeiα‾\overline{c_k}\,\overline{e^{i\alpha}} = \overline{c_k e^{i\alpha}}, and z+z‾=2Re⁡zz + \overline{z} = 2\operatorname{Re} z. So the pair equals 2Re⁡(ckeiα)2\operatorname{Re}(c_k e^{i\alpha}).

Step 5. Polar form. Write ck=∣ck∣eiφkc_k = \lvert c_k\rvert e^{i\varphi_k}. Then 2Re⁡(ckeiα)=2∣ck∣cos⁡(α+φk)2\operatorname{Re}(c_k e^{i\alpha}) = 2\lvert c_k\rvert\cos(\alpha + \varphi_k).

Step 6. Cartesian form. Write ck=αk+iβkc_k = \alpha_k + i\beta_k. Then 2Re⁡((αk+iβk)(cos⁡α+isin⁡α))=2αkcos⁡α−2βksin⁡α2\operatorname{Re}\big((\alpha_k + i\beta_k)(\cos\alpha + i\sin\alpha)\big) = 2\alpha_k\cos\alpha - 2\beta_k\sin\alpha, so ak=2αka_k = 2\alpha_k and bk=−2βkb_k = -2\beta_k. From ck=∫fcos⁡2πkx−i∫fsin⁡2πkxc_k = \int f\cos 2\pi kx - i\int f\sin 2\pi kx, αk=∫fcos⁡2πkx\alpha_k = \int f\cos 2\pi k x and βk=−∫fsin⁡2πkx\beta_k = -\int f \sin 2\pi kx.

So a real wave of amplitude AA is two phasors of length A/2A/2, one at +k+k and one at −k-k. That is why the probe above found ∣c3∣=0.45\lvert c_3\rvert = 0.45 for a wave of amplitude 0.90.9, and why the FFT of a real cosine shows two peaks, not one (Part 2 works that out by hand).

The square wave, by hand

Example 2 (Fourier coefficients of a square wave)

Let f=1f = 1 on [0,12)[0, \tfrac12) and f=−1f = -1 on [12,1)[\tfrac12, 1).

Step 1. The mean. c0=∫01/21 dx−∫1/211 dx=12−12=0c_0 = \int_0^{1/2} 1\, dx - \int_{1/2}^1 1\, dx = \tfrac12 - \tfrac12 = 0.

Step 2. Split the integral for k≠0k \ne 0: ck=∫01/2e−2πikxdx−∫1/21e−2πikxdxc_k = \int_0^{1/2} e^{-2\pi i k x}dx - \int_{1/2}^1 e^{-2\pi i k x}dx.

Step 3. First piece. With the antiderivative e−2πikx/(−2πik)e^{-2\pi i k x}/(-2\pi i k): e−πik−1−2πik=1−(−1)k2πik\frac{e^{-\pi i k} - 1}{-2\pi i k} = \frac{1 - (-1)^k}{2\pi i k}, using e−πik=(−1)ke^{-\pi i k} = (-1)^k.

Step 4. Second piece. e−2πik−e−πik−2πik=1−(−1)k−2πik\frac{e^{-2\pi i k} - e^{-\pi i k}}{-2\pi i k} = \frac{1 - (-1)^k}{-2\pi i k}.

Step 5. Subtract. ck=1−(−1)k2πik+1−(−1)k2πik=1−(−1)kπikc_k = \frac{1 - (-1)^k}{2\pi i k} + \frac{1 - (-1)^k}{2\pi i k} = \frac{1 - (-1)^k}{\pi i k}: zero for even kk, and 2πik=−2iπk\frac{2}{\pi i k} = -\frac{2i}{\pi k} for odd kk.

Step 6. Real form. ak=2Re⁡ck=0a_k = 2\operatorname{Re} c_k = 0 and bk=−2Im⁡ck=4πkb_k = -2\operatorname{Im} c_k = \frac{4}{\pi k} for odd kk, so

f(x)=4π(sin⁡2πx+sin⁡6πx3+sin⁡10πx5+⋯).f(x) = \frac{4}{\pi}\Big(\sin 2\pi x + \frac{\sin 6\pi x}{3} + \frac{\sin 10\pi x}{5} + \cdots\Big).

Numerically, c1=−0.6366ic_1 = -0.6366i, c3=−0.2122ic_3 = -0.2122i, c5=−0.1273ic_5 = -0.1273i: an FFT of 65,536 samples agrees to four decimals.

Now build partial sums yourself. The figure computes the coefficients of each shape, or of any curve you draw, and adds up the harmonics up to k=Nk = N.

Two things stand out. The square wave’s partial sums overshoot beside each jump, and the overshoot does not shrink as NN grows. And the coefficients of the triangle die off much faster than those of the square. The next section explains both.

4. How good is a partial sum?

There are two questions, and they have different answers. Does the energy of the error go to zero? Yes, for every square-integrable function. Does the error go to zero at every point? Not always, and the square wave is the classic failure.

In energy: always

Theorem 1 (Convergence in L² and Parseval’s identity)

For every f∈L2[0,1)f \in L^2[0, 1), ∥f−SNf∥→0\lVert f - S_N f\rVert \to 0 as N→∞N \to \infty, and

∥f∥2=∫01∣f(x)∣2 dx=∑k=−∞∞∣ck∣2.\lVert f\rVert^2 = \int_0^1 \lvert f(x)\rvert^2\, dx = \sum_{k=-\infty}^{\infty} \lvert c_k\rvert^2 .

The proof needs one new tool. The partial sums themselves can misbehave pointwise, but their running averages are well behaved, because they are averages of ff against a positive kernel.

Proof

Step 1. SNfS_N f is a convolution. Insert the definition of ckc_k: SNf(x)=∑∣k∣≤N(∫01f(y)e−2πikydy)e2πikx=∫01f(y) DN(x−y) dyS_N f(x) = \sum_{\lvert k\rvert\le N}\big(\int_0^1 f(y)e^{-2\pi i k y}dy\big)e^{2\pi i k x} = \int_0^1 f(y)\, D_N(x - y)\, dy, with the Dirichlet kernel DN(u)=∑∣k∣≤Ne2πikuD_N(u) = \sum_{\lvert k\rvert \le N} e^{2\pi i k u}.

Step 2. Closed form of DND_N. With q=e2πiu≠1q = e^{2\pi i u} \ne 1, the geometric sum is ∑k=−NNqk=q−Nq2N+1−1q−1\sum_{k=-N}^{N} q^k = q^{-N}\frac{q^{2N+1} - 1}{q - 1}. Multiply top and bottom by q−1/2q^{-1/2}: qN+1/2−q−N−1/2q1/2−q−1/2=sin⁡((2N+1)πu)sin⁡(πu)\frac{q^{N + 1/2} - q^{-N-1/2}}{q^{1/2} - q^{-1/2}} = \frac{\sin((2N+1)\pi u)}{\sin(\pi u)}, since eiθ−e−iθ=2isin⁡θe^{i\theta} - e^{-i\theta} = 2i\sin\theta.

Step 3. Average the partial sums. The Fejér mean is σNf=1N∑n=0N−1Snf=f∗FN\sigma_N f = \frac1N\sum_{n=0}^{N-1} S_n f = f * F_N with FN=1N∑n=0N−1DnF_N = \frac1N\sum_{n=0}^{N-1} D_n.

Step 4. Closed form of FNF_N. By Step 2, FN(u)=1Nsin⁡(πu)∑n=0N−1sin⁡((2n+1)πu)F_N(u) = \frac{1}{N\sin(\pi u)}\sum_{n=0}^{N-1}\sin((2n+1)\pi u). The identity 2sin⁡asin⁡((2n+1)a)=cos⁡(2na)−cos⁡((2n+2)a)2\sin a \sin((2n+1)a) = \cos(2na) - \cos((2n+2)a) makes the sum telescope: ∑n=0N−1sin⁡((2n+1)a)=1−cos⁡(2Na)2sin⁡a=sin⁡2(Na)sin⁡a\sum_{n=0}^{N-1}\sin((2n+1)a) = \frac{1 - \cos(2Na)}{2\sin a} = \frac{\sin^2(Na)}{\sin a}. Hence FN(u)=sin⁡2(Nπu)Nsin⁡2(πu)F_N(u) = \frac{\sin^2(N\pi u)}{N\sin^2(\pi u)}.

Step 5. Three properties of FNF_N. (a) FN≥0F_N \ge 0, by Step 4. (b) ∫01FN=1\int_0^1 F_N = 1, because each DnD_n integrates to 11 (only its k=0k = 0 term survives, by orthogonality). (c) For any 0<δ<120 < \delta < \tfrac12, on δ≤∣u∣≤12\delta \le \lvert u\rvert \le \tfrac12 we have FN(u)≤1Nsin⁡2(πδ)→0F_N(u) \le \frac{1}{N\sin^2(\pi\delta)} \to 0.

Step 6. Fejér means of continuous ff converge uniformly. By (b), σNf(x)−f(x)=∫FN(u)(f(x−u)−f(x))du\sigma_N f(x) - f(x) = \int F_N(u)\big(f(x - u) - f(x)\big)du. Given ε>0\varepsilon > 0, uniform continuity gives δ\delta with ∣f(x−u)−f(x)∣<ε\lvert f(x - u) - f(x)\rvert < \varepsilon for ∣u∣<δ\lvert u\rvert < \delta. Split the integral: the near part is at most ε∫FN=ε\varepsilon\int F_N = \varepsilon by (a) and (b); the far part is at most 2max⁡∣f∣⋅1Nsin⁡2(πδ)2\max\lvert f\rvert\cdot\frac{1}{N\sin^2(\pi\delta)} by (c), which is below ε\varepsilon for large NN.

Step 7. Partial sums of continuous ff converge in energy. σNf\sigma_N f is a trigonometric polynomial of degree below NN, so by the best-approximation property, ∥f−SNf∥≤∥f−σNf∥≤max⁡x∣f(x)−σNf(x)∣→0\lVert f - S_N f\rVert \le \lVert f - \sigma_N f\rVert \le \max_x\lvert f(x) - \sigma_N f(x)\rvert \to 0.

Step 8. All of L2L^2. Continuous periodic functions are dense in L2[0,1)L^2[0,1) (a standard fact of measure theory). Given ff and ε\varepsilon, pick a continuous gg with ∥f−g∥<ε\lVert f - g\rVert < \varepsilon. SNgS_N g is a polynomial of degree NN, so by best approximation ∥f−SNf∥≤∥f−SNg∥≤∥f−g∥+∥g−SNg∥<2ε\lVert f - S_N f\rVert \le \lVert f - S_N g\rVert \le \lVert f - g\rVert + \lVert g - S_N g\rVert < 2\varepsilon for large NN.

Step 9. Parseval. Step 5 of the best-approximation proof says ∥f∥2=∥f−SNf∥2+∑∣k∣≤N∣ck∣2\lVert f\rVert^2 = \lVert f - S_N f\rVert^2 + \sum_{\lvert k\rvert\le N}\lvert c_k\rvert^2. Let N→∞N \to \infty; the first term goes to 00.

Two consequences we have already used. The orthonormal set {ek}\{e_k\} is complete: nothing in L2L^2 is orthogonal to all of it, so fact 2 holds in the energy sense. And the squared error of a partial sum is exactly the energy of the coefficients left out, ∥f−SNf∥2=∑∣k∣>N∣ck∣2\lVert f - S_N f\rVert^2 = \sum_{\lvert k\rvert > N}\lvert c_k\rvert^2. That is how the epicycle figure at the top prints its error without comparing curves: it adds up the circles it is not drawing.

Pointwise: the Gibbs phenomenon

Energy convergence allows a thin spike of error to survive, as long as it gets thinner. Beside a jump, it does.

Proposition 5 (Gibbs overshoot)

For the square wave of Section 3, let SS be the partial sum with the odd harmonics k=1,3,…,2M−1k = 1, 3, \ldots, 2M - 1. Its first maximum to the right of the jump at x=0x = 0 is at xM=14Mx_M = \frac{1}{4M}, and as M→∞M \to \infty,

S(xM)→2π∫0πsin⁡tt dt=2πSi⁡(π)≈1.17898.S(x_M) \to \frac{2}{\pi}\int_0^{\pi}\frac{\sin t}{t}\, dt = \frac{2}{\pi}\operatorname{Si}(\pi) \approx 1.17898 .

The function jumps from −1-1 to 11, so the overshoot above 11 is about 8.95%8.95\% of the jump, for every MM large enough, however many terms are used.

Proof

Step 1. The partial sum. From the example in Section 3, S(x)=4π∑m=1Msin⁡(2π(2m−1)x)2m−1S(x) = \frac4\pi\sum_{m=1}^{M}\frac{\sin(2\pi(2m-1)x)}{2m-1}.

Step 2. Its derivative. S′(x)=4π∑m=1M2πcos⁡(2π(2m−1)x)=8∑m=1Mcos⁡((2m−1)θ)S'(x) = \frac4\pi\sum_{m=1}^M 2\pi\cos(2\pi(2m-1)x) = 8\sum_{m=1}^M\cos((2m-1)\theta) with θ=2πx\theta = 2\pi x.

Step 3. Sum the cosines. The identity 2sin⁡θcos⁡((2m−1)θ)=sin⁡(2mθ)−sin⁡((2m−2)θ)2\sin\theta\cos((2m-1)\theta) = \sin(2m\theta) - \sin((2m-2)\theta) (from 2sin⁡Acos⁡B=sin⁡(A+B)+sin⁡(A−B)2\sin A\cos B = \sin(A+B) + \sin(A-B)) telescopes: ∑m=1Mcos⁡((2m−1)θ)=sin⁡(2Mθ)2sin⁡θ\sum_{m=1}^M\cos((2m-1)\theta) = \frac{\sin(2M\theta)}{2\sin\theta}. Hence S′(x)=4sin⁡(4πMx)sin⁡(2πx)S'(x) = \frac{4\sin(4\pi M x)}{\sin(2\pi x)}.

Step 4. The first maximum. For small x>0x > 0 the denominator is positive and S′>0S' > 0 until the numerator first vanishes, at 4πMx=π4\pi M x = \pi. So SS rises to a maximum at xM=1/(4M)x_M = 1/(4M).

Step 5. Evaluate it. At xMx_M, 2π(2m−1)xM=tm2\pi(2m - 1)x_M = t_m with tm=(2m−1)π2Mt_m = \frac{(2m-1)\pi}{2M}, and 12m−1=π2Mtm\frac{1}{2m-1} = \frac{\pi}{2M t_m}. So S(xM)=4π∑m=1Msin⁡(tm)π2Mtm=2π∑m=1Msin⁡tmtm⋅πMS(x_M) = \frac{4}{\pi}\sum_{m=1}^M \sin(t_m)\frac{\pi}{2Mt_m} = \frac{2}{\pi}\sum_{m=1}^M\frac{\sin t_m}{t_m}\cdot\frac{\pi}{M}.

Step 6. Recognise a Riemann sum. The points tmt_m are the midpoints of MM equal intervals of width π/M\pi/M covering [0,π][0, \pi], so the sum tends to ∫0πsin⁡ttdt=Si⁡(π)≈1.85194\int_0^\pi\frac{\sin t}{t}dt = \operatorname{Si}(\pi) \approx 1.85194. Multiplying by 2/π2/\pi gives 1.178981.17898.

Measured values agree: with M=5,10,50,200M = 5, 10, 50, 200 odd terms the maximum is 1.182331.18233, 1.179811.17981, 1.179011.17901, 1.178981.17898, each at x=1/(4M)x = 1/(4M). The peak moves toward the jump and gets narrower, so its energy vanishes, but its height does not. Where does it come from? Step 1 of the Parseval proof says SNf=f∗DNS_N f = f * D_N, and the Dirichlet kernel has negative side lobes. Averaging a jump against a kernel with negative lobes produces ripples. The Fejér kernel has no negative lobes, which is why Fejér means of a square wave never overshoot.

Note (Gibbs in practice)

The same ripples appear whenever a spectrum is cut off sharply: around edges in an image low-passed with a brick-wall filter (Section 9), in MRI scans reconstructed from a truncated set of frequencies (“truncation artefacts”), and in spectral solvers of PDEs with shocks. The cure is always the same: taper the cut instead of chopping it.

Smoothness is decay

The second observation from the series figure, that the triangle’s coefficients fall faster, is a theorem worth knowing by heart.

Proposition 6 (Smooth functions have rapidly decaying coefficients)

Let ff be periodic with f,f′,…,f(p−1)f, f', \ldots, f^{(p-1)} continuous and f(p)f^{(p)} piecewise continuous. Then for k≠0k \ne 0

ck(f)=ck(f(p))(2πik)p,so∣ck(f)∣≤∫01∣f(p)∣(2π∣k∣)p.c_k(f) = \frac{c_k\big(f^{(p)}\big)}{(2\pi i k)^p}, \qquad \text{so} \qquad \lvert c_k(f)\rvert \le \frac{\int_0^1\lvert f^{(p)}\rvert}{(2\pi\lvert k\rvert)^p}.
Proof

Step 1. One integration by parts. ck(f′)=∫01f′(x)e−2πikxdx=[f(x)e−2πikx]01+2πik∫01f(x)e−2πikxdxc_k(f') = \int_0^1 f'(x)e^{-2\pi i k x}dx = \big[f(x)e^{-2\pi i k x}\big]_0^1 + 2\pi i k\int_0^1 f(x)e^{-2\pi i k x}dx.

Step 2. The boundary term vanishes, because ff and e−2πikxe^{-2\pi i k x} take the same values at 00 and 11. So ck(f′)=2πik ck(f)c_k(f') = 2\pi i k\, c_k(f).

Step 3. Repeat pp times (allowed because f,…,f(p−1)f, \ldots, f^{(p-1)} are continuous and periodic): ck(f(p))=(2πik)pck(f)c_k(f^{(p)}) = (2\pi i k)^p c_k(f).

Step 4. Bound. ∣ck(g)∣≤∫01∣g(x)∣ ∣e−2πikx∣ dx=∫01∣g∣\lvert c_k(g)\rvert \le \int_0^1\lvert g(x)\rvert\,\lvert e^{-2\pi i k x}\rvert\,dx = \int_0^1\lvert g\rvert, since ∣eiα∣=1\lvert e^{i\alpha}\rvert = 1.

A jump gives 1/k1/k decay (the square wave: ∣ck∣=2/(πk)\lvert c_k\rvert = 2/(\pi k)). A kink gives 1/k21/k^2: the triangle wave 1−4∣x−12∣1 - 4\lvert x - \tfrac12\rvert has derivative 44 times the square wave, so its coefficients are 4⋅2πik⋅12πik=−4π2k24\cdot\frac{2}{\pi i k}\cdot\frac{1}{2\pi i k} = -\frac{4}{\pi^2 k^2} for odd kk, which is what the log-scale stems in the figure show. A function with pp continuous derivatives decays faster than 1/kp1/k^p, and an infinitely smooth one faster than any power. Read backwards, this is a detector: slowly decaying coefficients mean a singularity somewhere, but the coefficients do not say where. Wavelets, in Part 3, will say where.

5. Why sinusoids? The real reason

Why this basis? There are many orthonormal bases of L2[0,1)L^2[0,1): Legendre polynomials, Haar functions, wavelets. The usual answer, “because signals are made of waves”, is not the reason. The reason is that sinusoids are the only functions that every shift-invariant operation leaves alone.

Write TsT_s for the shift, (Tsf)(x)=f(x−s)(T_s f)(x) = f(x - s). An operator LL on periodic functions is shift-invariant if it commutes with every shift: LTs=TsLL T_s = T_s L. Blurring is shift-invariant (it treats every place alike), so is differentiation, so is any convolution, and so is the Laplacian.

Proposition 7 (Every shift-invariant linear operator has the eₖ as eigenfunctions)

If LL is linear and shift-invariant, then Lek=λkekL e_k = \lambda_k e_k for every kk, with λk=(Lek)(0)\lambda_k = (L e_k)(0).

Proof

Step 1. eke_k is an eigenfunction of each shift. (Tsek)(x)=e2πik(x−s)=e−2πiks ek(x)(T_s e_k)(x) = e^{2\pi i k(x - s)} = e^{-2\pi i k s}\,e_k(x).

Step 2. Push the shift through LL. Let g=Lekg = L e_k. Then Tsg=TsLek=LTsek=L(e−2πiksek)=e−2πiks gT_s g = T_s L e_k = L T_s e_k = L\big(e^{-2\pi i k s}e_k\big) = e^{-2\pi i k s}\,g, using shift-invariance and then linearity.

Step 3. Read it pointwise. g(x−s)=e−2πiksg(x)g(x - s) = e^{-2\pi i k s}g(x) for all xx and ss. Put x=sx = s: g(0)=e−2πiksg(s)g(0) = e^{-2\pi i k s}g(s), so g(s)=g(0) e2πiks=g(0) ek(s)g(s) = g(0)\,e^{2\pi i k s} = g(0)\,e_k(s).

So in the Fourier basis, every shift-invariant operator is diagonal: it multiplies the kk-th coordinate by λk\lambda_k and does nothing else. For a convolution Lf=h∗fL f = h * f (with (h∗f)(x)=∫01h(y)f(x−y) dy(h * f)(x) = \int_0^1 h(y)f(x - y)\,dy), λk=ck(h)\lambda_k = c_k(h), so

ck(h∗f)=ck(h) ck(f).c_k(h * f) = c_k(h)\, c_k(f).

For the derivative, λk=2πik\lambda_k = 2\pi i k; for the second derivative, −(2πk)2-(2\pi k)^2, the eigenvalues of the Laplacian (more in the post on the Laplacian).

why Fourier: it makes every blur diagonalblur as a matrix H:every row the same kernel, shiftedchange basisto the eₖin the Fourier basis: diagonalentry k is ĥ(k): blur only rescales each wave
Proof: the convolution rule cₖ(h ∗ f) = cₖ(h) cₖ(f), directly

Step 1. Write it out. ck(h∗f)=∫01(∫01h(y)f(x−y) dy)e−2πikx dxc_k(h * f) = \int_0^1\Big(\int_0^1 h(y)f(x - y)\,dy\Big)e^{-2\pi i k x}\,dx.

Step 2. Split the exponential. e−2πikx=e−2πiky e−2πik(x−y)e^{-2\pi i k x} = e^{-2\pi i k y}\,e^{-2\pi i k(x - y)}, and swap the order of integration (Fubini; h,fh, f integrable): ∫01h(y)e−2πiky(∫01f(x−y)e−2πik(x−y)dx)dy\int_0^1 h(y)e^{-2\pi i k y}\Big(\int_0^1 f(x - y)e^{-2\pi i k(x-y)}dx\Big)dy.

Step 3. The inner integral is ck(f)c_k(f): substitute u=x−yu = x - y; by periodicity, the integral over any interval of length 11 is the same.

Step 4. What is left is ck(f)∫01h(y)e−2πikydy=ck(h) ck(f)c_k(f)\int_0^1 h(y)e^{-2\pi i k y}dy = c_k(h)\,c_k(f).

The converse is what makes the exponentials special, and not just convenient.

Proposition 8 (The eₖ are the only common eigenfunctions of all shifts)

Let φ≠0\varphi \neq 0 be continuous and periodic with Tsφ=λ(s)φT_s\varphi = \lambda(s)\varphi for every ss. Then φ=φ(0) ek\varphi = \varphi(0)\, e_k for some integer kk.

Proof

Step 1. φ(0)≠0\varphi(0) \ne 0. Otherwise putting x=sx = s in φ(x−s)=λ(s)φ(x)\varphi(x - s) = \lambda(s)\varphi(x) gives 0=λ(s)φ(s)0 = \lambda(s)\varphi(s); at a point s0s_0 where φ(s0)≠0\varphi(s_0)\ne0 this forces λ(s0)=0\lambda(s_0) = 0, and then φ(x−s0)=0\varphi(x - s_0) = 0 for all xx, so φ≡0\varphi \equiv 0.

Step 2. λ\lambda is multiplicative. Ts+t=TsTtT_{s+t} = T_sT_t gives λ(s+t)φ=λ(s)λ(t)φ\lambda(s+t)\varphi = \lambda(s)\lambda(t)\varphi, so λ(s+t)=λ(s)λ(t)\lambda(s + t) = \lambda(s)\lambda(t); also λ(s)=φ(0)/φ(s)\lambda(s) = \varphi(0)/\varphi(s) (put x=sx = s), so λ\lambda is continuous with λ(0)=1\lambda(0) = 1.

Step 3. λ\lambda is differentiable. Pick δ>0\delta > 0 small enough that a=∫0δλ(t) dt≠0a = \int_0^\delta\lambda(t)\,dt \ne 0 (possible since λ≈1\lambda \approx 1 near 00). Then aλ(s)=∫0δλ(s+t) dt=∫ss+δλ(u) dua\lambda(s) = \int_0^\delta\lambda(s + t)\,dt = \int_s^{s+\delta}\lambda(u)\,du, and the right side is differentiable in ss.

Step 4. Solve. Differentiating Step 3, aλ′(s)=λ(s+δ)−λ(s)=λ(s)(λ(δ)−1)a\lambda'(s) = \lambda(s + \delta) - \lambda(s) = \lambda(s)\big(\lambda(\delta) - 1\big). So λ′=cλ\lambda' = c\lambda with a constant cc, and λ(s)=ecs\lambda(s) = e^{cs}.

Step 5. Periodicity. T1φ=φT_1\varphi = \varphi forces λ(1)=1\lambda(1) = 1, so ec=1e^{c} = 1 and c=2πimc = 2\pi i m for an integer mm. Then φ(s)=φ(0)/λ(s)=φ(0)e−2πims=φ(0) e−m(s)\varphi(s) = \varphi(0)/\lambda(s) = \varphi(0)e^{-2\pi i m s} = \varphi(0)\,e_{-m}(s).

Remark (The general principle)

Shifts form a group (the circle here, the line in Section 6, the sphere in the sphere post). The functions that every element of the group merely rescales are the group’s characters, and expanding in them is harmonic analysis on that group. On the circle the characters are eke_k; on the line, e2πiξxe^{2\pi i\xi x}; on the sphere, rotations no longer commute and the role is taken by the spherical harmonics. Wherever there is symmetry, there is a Fourier transform adapted to it.

6. From series to transform

A signal on the whole line is not periodic. The trick is to pretend it is, with a period LL so large that the copies never meet, and to see what happens to the series as L→∞L \to \infty.

A unit box repeated every L. Its Fourier lines sit at ξ = k/L with heights L·c_k = sinc(k/L); as L grows they crowd together under one curve, the Fourier transform of a single box.

The heuristic, step by step. Let ff vanish outside [−L2,L2][-\tfrac L2, \tfrac L2] and repeat it with period LL. Rescaling the formulas of Section 3 to period LL (substitute x→x/Lx \to x/L), the basis is e2πi(k/L)xe^{2\pi i (k/L) x} and

ck=1L∫−L/2L/2f(x) e−2πi(k/L)x dx=1L F ⁣(kL),where F(ξ)=∫−∞∞f(x) e−2πiξx dx.c_k = \frac1L\int_{-L/2}^{L/2} f(x)\,e^{-2\pi i (k/L) x}\,dx = \frac1L\,F\!\left(\frac kL\right), \quad \text{where } F(\xi) = \int_{-\infty}^{\infty} f(x)\,e^{-2\pi i \xi x}\,dx .

The series becomes f(x)=∑kF(k/L) e2πi(k/L)x⋅1Lf(x) = \sum_k F(k/L)\,e^{2\pi i (k/L)x}\cdot\frac1L: a Riemann sum with spacing Δξ=1/L\Delta\xi = 1/L. As L→∞L \to \infty it tends to ∫F(ξ) e2πiξx dξ\int F(\xi)\,e^{2\pi i\xi x}\,d\xi. The frequencies stop being whole numbers and fill the line.

Definition 4 (Fourier transform)

For ff integrable on R\mathbb{R},

f^(ξ)=∫−∞∞f(x) e−2πiξx dx,f(x)=∫−∞∞f^(ξ) e2πiξx dξ.\hat f(\xi) = \int_{-\infty}^{\infty} f(x)\, e^{-2\pi i \xi x}\, dx, \qquad f(x) = \int_{-\infty}^{\infty} \hat f(\xi)\, e^{2\pi i \xi x}\, d\xi .

The second formula, the inversion theorem, holds whenever ff is continuous and f^\hat f is integrable; Section 7 proves it.

f^(ξ)\hat f(\xi) is the same coordinate as before: the inner product of ff with the wave e2πiξxe^{2\pi i\xi x}, now for every real frequency ξ\xi.

Example 3 (Three transforms by hand)

A box. rect⁡(x)=1\operatorname{rect}(x) = 1 for ∣x∣<12\lvert x\rvert < \tfrac12: f^(ξ)=∫−1/21/2e−2πiξxdx=e−πiξ−eπiξ−2πiξ=−2isin⁡πξ−2πiξ=sin⁡πξπξ=sinc⁡ξ\hat f(\xi) = \int_{-1/2}^{1/2}e^{-2\pi i\xi x}dx = \frac{e^{-\pi i\xi} - e^{\pi i\xi}}{-2\pi i\xi} = \frac{-2i\sin\pi\xi}{-2\pi i\xi} = \frac{\sin\pi\xi}{\pi\xi} = \operatorname{sinc}\xi, with value 11 at ξ=0\xi = 0 (the area of the box).

A two-sided exponential. f(x)=e−∣x∣f(x) = e^{-\lvert x\rvert}. Split at zero: ∫0∞e−x(1+2πiξ)dx=11+2πiξ\int_0^\infty e^{-x(1 + 2\pi i\xi)}dx = \frac{1}{1 + 2\pi i\xi} and ∫−∞0ex(1−2πiξ)dx=11−2πiξ\int_{-\infty}^0 e^{x(1 - 2\pi i\xi)}dx = \frac{1}{1 - 2\pi i\xi}. Add over the common denominator 1+4π2ξ21 + 4\pi^2\xi^2: f^(ξ)=21+4π2ξ2\hat f(\xi) = \frac{2}{1 + 4\pi^2\xi^2}, a Lorentzian. (A kink at 00, so decay like 1/ξ21/\xi^2, as in Section 4.)

A spike. The box of width ε\varepsilon and height 1/ε1/\varepsilon has area 11 and, by the scaling rule of Section 7, transform sinc⁡(εξ)\operatorname{sinc}(\varepsilon\xi). As ε→0\varepsilon \to 0 the box becomes the Dirac delta and its transform becomes the constant 11. A perfect spike contains every frequency equally. (Distribution theory makes this precise; Osgood’s notes do it well.)

Each of these was checked numerically by quadrature at ξ=0.3\xi = 0.3 and 1.71.7.

ConventionForwardInverse
ξ\xi, this series∫fe−2πiξx\int f e^{-2\pi i\xi x}∫f^e2πiξx\int \hat f e^{2\pi i\xi x}
ω\omega, physics∫fe−iωx\int f e^{-i\omega x}12π∫f^eiωx\frac{1}{2\pi}\int \hat f e^{i\omega x}
ω\omega, unitary12π∫fe−iωx\frac{1}{\sqrt{2\pi}}\int f e^{-i\omega x}12π∫f^eiωx\frac{1}{\sqrt{2\pi}}\int\hat f e^{i\omega x}

Question 2

Which convention is right?

Answer

All three are; they differ by where 2π2\pi goes. With ω=2πξ\omega = 2\pi\xi, the physics transform at ω\omega equals ours at ξ=ω/2π\xi = \omega/2\pi, and the unitary one is that divided by 2π\sqrt{2\pi}. The cost of mixing them is a missing factor of 2π2\pi somewhere, usually in a Gaussian’s width or in Plancherel’s identity. Pick one and convert at the boundary of your code.

7. Properties, each with a proof

Most Fourier calculations are a few of these rules applied in sequence. Assume ff and gg are integrable, and smooth and decaying wherever a derivative appears.

Proposition 9 (Shift, modulation, scaling)

  1. Shift: f(x−a)  ⟷  e−2πiaξ f^(ξ)f(x - a) \;\longleftrightarrow\; e^{-2\pi i a\xi}\,\hat f(\xi).
  2. Modulation: e2πibxf(x)  ⟷  f^(ξ−b)e^{2\pi i b x}f(x) \;\longleftrightarrow\; \hat f(\xi - b).
  3. Scaling: f(ax)  ⟷  1∣a∣f^ ⁣(ξa)f(ax) \;\longleftrightarrow\; \frac{1}{\lvert a\rvert}\hat f\!\left(\frac{\xi}{a}\right) for a≠0a \ne 0.
Proof

Shift. Substitute u=x−au = x - a: ∫f(x−a)e−2πiξxdx=∫f(u)e−2πiξ(u+a)du=e−2πiaξf^(ξ)\int f(x - a)e^{-2\pi i\xi x}dx = \int f(u)e^{-2\pi i\xi(u + a)}du = e^{-2\pi i a\xi}\hat f(\xi).

Modulation. ∫e2πibxf(x)e−2πiξxdx=∫f(x)e−2πi(ξ−b)xdx=f^(ξ−b)\int e^{2\pi i bx}f(x)e^{-2\pi i\xi x}dx = \int f(x)e^{-2\pi i(\xi - b)x}dx = \hat f(\xi - b).

Scaling, a>0a > 0. Substitute u=axu = ax, dx=du/adx = du/a: ∫f(ax)e−2πiξxdx=1a∫f(u)e−2πi(ξ/a)udu=1af^(ξ/a)\int f(ax)e^{-2\pi i\xi x}dx = \frac1a\int f(u)e^{-2\pi i(\xi/a)u}du = \frac1a\hat f(\xi/a).

Scaling, a<0a < 0. The same substitution reverses the limits of integration, which contributes a minus sign: −1af^(ξ/a)=1∣a∣f^(ξ/a)-\frac1a\hat f(\xi/a) = \frac{1}{\lvert a\rvert}\hat f(\xi/a).

The shift rule says that moving a signal changes only the phase of its transform, never the magnitude. That is why the magnitude spectrum of an image does not care where things are, and why positions are written in the phase (Section 10). The scaling rule says that squeezing a signal stretches its spectrum:

The scaling rule applied to a Gaussian: narrow in space means wide in frequency, and the product of the two widths stays fixed. Part 2 proves that no function does better than the Gaussian.

Proposition 10 (Derivatives and multiplication by x)

  1. f′(x)  ⟷  2πiξ f^(ξ)f'(x) \;\longleftrightarrow\; 2\pi i\xi\,\hat f(\xi).
  2. xf(x)  ⟷  i2π f^ ′(ξ)x f(x) \;\longleftrightarrow\; \frac{i}{2\pi}\,\hat f\,'(\xi).
Proof

Derivative. Integrate by parts: ∫f′(x)e−2πiξxdx=[f(x)e−2πiξx]−∞∞+2πiξ∫f(x)e−2πiξxdx\int f'(x)e^{-2\pi i\xi x}dx = \big[f(x)e^{-2\pi i\xi x}\big]_{-\infty}^{\infty} + 2\pi i\xi\int f(x)e^{-2\pi i\xi x}dx. The boundary term vanishes because f(x)→0f(x) \to 0 as x→±∞x \to \pm\infty.

Multiplication by xx. Differentiate under the integral sign (allowed when xf(x)xf(x) is integrable): f^ ′(ξ)=∫f(x) (−2πix) e−2πiξxdx=−2πi xf^(ξ)\hat f\,'(\xi) = \int f(x)\,(-2\pi i x)\,e^{-2\pi i\xi x}dx = -2\pi i\,\widehat{xf}(\xi). Divide by −2πi-2\pi i, and 1−2πi=i2π\frac{1}{-2\pi i} = \frac{i}{2\pi}.

These two rules turn calculus into algebra, and they give the most important pair of all in four lines.

Proposition 11 (The Gaussian is its own transform)

e−πx2  ⟷  e−πξ2e^{-\pi x^2} \;\longleftrightarrow\; e^{-\pi\xi^2}.

Proof

Step 1. The Gaussian solves an ODE. g(x)=e−πx2g(x) = e^{-\pi x^2} satisfies g′(x)=−2πx g(x)g'(x) = -2\pi x\,g(x).

Step 2. Transform both sides. The left becomes 2πiξ g^(ξ)2\pi i\xi\,\hat g(\xi). The right becomes −2π⋅i2πg^ ′(ξ)=−i g^ ′(ξ)-2\pi\cdot\frac{i}{2\pi}\hat g\,'(\xi) = -i\,\hat g\,'(\xi). So g^ ′(ξ)=−2πξ g^(ξ)\hat g\,'(\xi) = -2\pi\xi\,\hat g(\xi): the same ODE.

Step 3. Solve it. ddξ(g^(ξ)eπξ2)=(g^ ′+2πξg^)eπξ2=0\frac{d}{d\xi}\big(\hat g(\xi)e^{\pi\xi^2}\big) = \big(\hat g\,' + 2\pi\xi\hat g\big)e^{\pi\xi^2} = 0, so g^(ξ)=g^(0) e−πξ2\hat g(\xi) = \hat g(0)\,e^{-\pi\xi^2}.

Step 4. The constant. g^(0)=∫e−πx2dx=I\hat g(0) = \int e^{-\pi x^2}dx = I. Square it and use polar coordinates: I2=∬e−π(x2+y2)dx dy=∫02π ⁣ ⁣∫0∞e−πr2r dr dθ=2π⋅12π=1I^2 = \iint e^{-\pi(x^2 + y^2)}dx\,dy = \int_0^{2\pi}\!\!\int_0^\infty e^{-\pi r^2}r\,dr\,d\theta = 2\pi\cdot\frac{1}{2\pi} = 1. Since I>0I > 0, I=1I = 1.

With scaling: e−πx2/s2↔s e−πs2ξ2e^{-\pi x^2/s^2} \leftrightarrow s\,e^{-\pi s^2\xi^2}, the pair in the clip above. Now the inversion theorem, which so far we only made plausible.

Theorem 2 (Fourier inversion)

If ff is integrable and continuous and f^\hat f is integrable, then f(x)=∫f^(ξ) e2πiξx dξf(x) = \int\hat f(\xi)\,e^{2\pi i\xi x}\,d\xi for every xx.

Proof

The idea: insert a Gaussian damping factor to make every integral absolutely convergent, compute, and let the damping go.

Step 1. Damp. For ε>0\varepsilon > 0 let Iε(x)=∫f^(ξ) e2πiξx e−πε2ξ2dξI_\varepsilon(x) = \int\hat f(\xi)\,e^{2\pi i\xi x}\,e^{-\pi\varepsilon^2\xi^2}d\xi. Since ∣f^∣\lvert\hat f\rvert is integrable and the damping is at most 11 and tends to 11, dominated convergence gives Iε(x)→∫f^(ξ)e2πiξxdξI_\varepsilon(x) \to \int\hat f(\xi)e^{2\pi i\xi x}d\xi.

Step 2. Expand f^\hat f and swap integrals. Iε(x)=∫f(y)(∫e−2πiξ(y−x)e−πε2ξ2dξ)dyI_\varepsilon(x) = \int f(y)\Big(\int e^{-2\pi i\xi(y - x)}e^{-\pi\varepsilon^2\xi^2}d\xi\Big)dy. The swap is allowed (Fubini) because ∬∣f(y)∣e−πε2ξ2 dy dξ=∥f∥1/ε<∞\iint\lvert f(y)\rvert e^{-\pi\varepsilon^2\xi^2}\,dy\,d\xi = \lVert f\rVert_1/\varepsilon < \infty.

Step 3. The inner integral is a Gaussian’s transform. It is the transform of ξ↦e−π(εξ)2\xi \mapsto e^{-\pi(\varepsilon\xi)^2} evaluated at y−xy - x. By the Gaussian pair and the scaling rule with a=εa = \varepsilon, it equals Gε(y−x)G_\varepsilon(y - x) with Gε(u)=1εe−πu2/ε2G_\varepsilon(u) = \frac1\varepsilon e^{-\pi u^2/\varepsilon^2}.

Step 4. So Iε=f∗GεI_\varepsilon = f * G_\varepsilon (GεG_\varepsilon is even).

Step 5. GεG_\varepsilon is an approximate identity. It is positive; it integrates to 11 (substitute u=εvu = \varepsilon v and use Step 4 of the Gaussian proof); and for any δ>0\delta > 0, sup⁡∣u∣>δGε(u)=1εe−πδ2/ε2→0\sup_{\lvert u\rvert>\delta}G_\varepsilon(u) = \frac1\varepsilon e^{-\pi\delta^2/\varepsilon^2} \to 0, as does ∫∣u∣>δGε\int_{\lvert u\rvert > \delta}G_\varepsilon.

Step 6. Convergence. ∣(f∗Gε)(x)−f(x)∣≤∫Gε(u)∣f(x−u)−f(x)∣du\lvert(f*G_\varepsilon)(x) - f(x)\rvert \le \int G_\varepsilon(u)\lvert f(x - u) - f(x)\rvert du. Choose δ\delta so that ∣f(x−u)−f(x)∣<η\lvert f(x-u) - f(x)\rvert < \eta for ∣u∣<δ\lvert u\rvert < \delta (continuity at xx). The near part is below η\eta. The far part is at most sup⁡∣u∣>δGε⋅∥f∥1+∣f(x)∣∫∣u∣>δGε\sup_{\lvert u\rvert > \delta}G_\varepsilon\cdot\lVert f\rVert_1 + \lvert f(x)\rvert\int_{\lvert u\rvert>\delta}G_\varepsilon, which tends to 00 by Step 5.

Step 7. Compare the limits. Step 1 and Step 6 compute the limit of the same Iε(x)I_\varepsilon(x), so they agree.

Proposition 12 (Plancherel and the convolution theorem)

  1. Plancherel: ∫∣f(x)∣2dx=∫∣f^(ξ)∣2dξ\int\lvert f(x)\rvert^2dx = \int\lvert\hat f(\xi)\rvert^2d\xi. Energy is the same in both domains.
  2. Convolution: f∗g^(ξ)=f^(ξ) g^(ξ)\widehat{f * g}(\xi) = \hat f(\xi)\,\hat g(\xi).
  3. Duality: f^^(x)=f(−x)\hat{\hat f}(x) = f(-x).
Proof

Plancherel. Step 1, the multiplication formula. For integrable f,gf, g: ∫f(x)g^(x) dx=∬f(x)g(y)e−2πixydy dx=∫f^(y)g(y) dy\int f(x)\hat g(x)\,dx = \iint f(x)g(y)e^{-2\pi i xy}dy\,dx = \int\hat f(y)g(y)\,dy, by Fubini, reading the double integral both ways. Step 2, choose g=f^‾g = \overline{\hat f}. Then g^(x)=∫f^(y)‾e−2πixydy=∫f^(y)e2πixydy‾=f(x)‾\hat g(x) = \int\overline{\hat f(y)}e^{-2\pi i xy}dy = \overline{\int\hat f(y)e^{2\pi ixy}dy} = \overline{f(x)} by inversion. Step 3, substitute: ∫ff‾=∫f^ f^‾\int f\overline{f} = \int\hat f\,\overline{\hat f}. (By density this extends to all of L2L^2, the content of Plancherel’s theorem.)

Convolution. f∗g^(ξ)=∫ ⁣ ⁣∫f(y)g(x−y) dy e−2πiξxdx\widehat{f*g}(\xi) = \int\!\!\int f(y)g(x - y)\,dy\,e^{-2\pi i\xi x}dx. Write e−2πiξx=e−2πiξye−2πiξ(x−y)e^{-2\pi i\xi x} = e^{-2\pi i\xi y}e^{-2\pi i\xi(x-y)}, swap integrals (Fubini), and substitute u=x−yu = x - y in the inner one: ∫f(y)e−2πiξy(∫g(u)e−2πiξudu)dy=f^(ξ)g^(ξ)\int f(y)e^{-2\pi i\xi y}\Big(\int g(u)e^{-2\pi i\xi u}du\Big)dy = \hat f(\xi)\hat g(\xi).

Duality. Inversion at −x-x: f(−x)=∫f^(ξ)e−2πiξxdξf(-x) = \int\hat f(\xi)e^{-2\pi i\xi x}d\xi, which is the transform of f^\hat f evaluated at xx.

Operation on ffEffect on f^\hat f
shift by aamultiply by e−2πiaξe^{-2\pi i a\xi} (phase only)
multiply by e2πibxe^{2\pi i bx}shift by bb
squeeze by aastretch by aa, scale by 1/∣a∣1/\lvert a\rvert
differentiatemultiply by 2πiξ2\pi i\xi
multiply by xxi2πddξ\frac{i}{2\pi}\frac{d}{d\xi}
convolve with ggmultiply by g^\hat g
real-valuedf^(−ξ)=f^(ξ)‾\hat f(-\xi) = \overline{\hat f(\xi)}

The last row is the negative-frequency proposition of Section 3 on the line, with the same proof.

8. Filters and what “frequency response” means

A linear shift-invariant system (in engineering, an LTI system) takes a signal xx and returns y=Lxy = Lx, linearly and treating every time alike. Section 5 already told us everything about it: it is a convolution, y=h∗xy = h * x, with h=Lδh = L\delta the impulse response, and in frequency it multiplies, y^(ξ)=h^(ξ) x^(ξ)\hat y(\xi) = \hat h(\xi)\,\hat x(\xi). The function h^\hat h is the frequency response: by how much, and with what phase shift, the system passes each frequency.

To see filters act, the series uses one shared signal, the song: 2048 samples over one second, containing a chord (two close tones, 40 and 56 Hz), then a chirp sweeping from 60 to 240 Hz, then a single click. It is synthetic, so every number about it is exact.

Question 3

“A filter removes frequencies.” Why is that not quite true, and what does the ringing in the figure have to do with Section 4?

Answer

An ideal low-pass filter has h^=rect⁡(ξ/2B)\hat h = \operatorname{rect}(\xi/2B): one inside [−B,B][-B, B], zero outside. By the box pair and duality its impulse response is h(x)=2Bsinc⁡(2Bx)h(x) = 2B\operatorname{sinc}(2Bx), which has negative side lobes. Convolving a click with it reproduces those lobes: ripples on both sides. This is the Gibbs phenomenon again, now in time: chopping a spectrum sharply is convolving with a kernel that rings. A Gaussian response has a Gaussian, positive impulse response, so it smooths without ringing; the price is a gentle roll-off instead of a clean cut. Every real filter trades sharpness in frequency against compactness and positivity in time, a first glimpse of the uncertainty principle of Part 2.

Two more facts worth keeping. Since a shift is multiplication by e−2πiaξe^{-2\pi i a\xi}, a filter whose phase is linear in ξ\xi just delays the signal; any other phase distorts it, which is why image filters are usually designed to be symmetric (zero phase). And a derivative is the filter 2πiξ2\pi i\xi: a high-pass that grows without bound, which is why differentiating noisy data amplifies the noise.

9. Images: the 2-D Fourier transform

Everything carries over to two dimensions, with one new ingredient: direction.

Definition 5 (2-D Fourier transform)

For an image f(x)f(\boldsymbol{x}), x=(x,y)\boldsymbol{x} = (x, y),

f^(ξ)=∬f(x) e−2πi x⋅ξ dx,f(x)=∬f^(ξ) e2πi x⋅ξ dξ,\hat f(\boldsymbol{\xi}) = \iint f(\boldsymbol{x})\, e^{-2\pi i\,\boldsymbol{x}\cdot\boldsymbol{\xi}}\, d\boldsymbol{x}, \qquad f(\boldsymbol{x}) = \iint\hat f(\boldsymbol{\xi})\,e^{2\pi i\,\boldsymbol{x}\cdot\boldsymbol{\xi}}\,d\boldsymbol{\xi},

with ξ=(ξ,η)\boldsymbol{\xi} = (\xi, \eta) and x⋅ξ=xξ+yη\boldsymbol{x}\cdot\boldsymbol{\xi} = x\xi + y\eta.

The basis functions are plane waves, e2πi x⋅ξe^{2\pi i\,\boldsymbol{x}\cdot\boldsymbol{\xi}}. Their phase is constant wherever x⋅ξ\boldsymbol{x}\cdot\boldsymbol{\xi} is, which is along lines perpendicular to ξ\boldsymbol{\xi}; moving a distance dd along ξ\boldsymbol{\xi} changes x⋅ξ\boldsymbol{x}\cdot\boldsymbol{\xi} by d ∣ξ∣d\,\lvert\boldsymbol{\xi}\rvert, so the wavelength is 1/∣ξ∣1/\lvert\boldsymbol{\xi}\rvert. A single point ξ\boldsymbol{\xi} of the spectrum, together with its mirror −ξ-\boldsymbol{\xi} (the image is real), is one grating: stripes perpendicular to ξ\boldsymbol{\xi}, spaced 1/∣ξ∣1/\lvert\boldsymbol{\xi}\rvert apart, with an amplitude and a phase.

Proposition 13 (Separability and rotation)

  1. Separability: if f(x,y)=g(x) h(y)f(x, y) = g(x)\,h(y), then f^(ξ,η)=g^(ξ) h^(η)\hat f(\xi, \eta) = \hat g(\xi)\,\hat h(\eta).
  2. Rotation: for a rotation matrix R\mathbf{R}, f(Rx)  ⟷  f^(Rξ)f(\mathbf{R}\boldsymbol{x}) \;\longleftrightarrow\; \hat f(\mathbf{R}\boldsymbol{\xi}). Rotate an image and its spectrum rotates with it.
Proof

Separability. e−2πi(xξ+yη)=e−2πixξe−2πiyηe^{-2\pi i(x\xi + y\eta)} = e^{-2\pi i x\xi}e^{-2\pi i y\eta}, so the double integral splits into ∫g(x)e−2πixξdx⋅∫h(y)e−2πiyηdy\int g(x)e^{-2\pi ix\xi}dx\cdot\int h(y)e^{-2\pi iy\eta}dy (Fubini).

Rotation. Substitute u=Rx\boldsymbol{u} = \mathbf{R}\boldsymbol{x}. A rotation has ∣det⁡R∣=1\lvert\det\mathbf{R}\rvert = 1, so dx=dud\boldsymbol{x} = d\boldsymbol{u}, and R⊤R=I\mathbf{R}^{\top}\mathbf{R} = \mathbf{I}, so x⋅ξ=(R⊤u)⋅ξ=u⋅(Rξ)\boldsymbol{x}\cdot\boldsymbol{\xi} = (\mathbf{R}^{\top}\boldsymbol{u})\cdot\boldsymbol{\xi} = \boldsymbol{u}\cdot(\mathbf{R}\boldsymbol{\xi}). Hence ∬f(Rx)e−2πix⋅ξdx=∬f(u)e−2πiu⋅Rξdu=f^(Rξ)\iint f(\mathbf{R}\boldsymbol{x})e^{-2\pi i\boldsymbol{x}\cdot\boldsymbol{\xi}}d\boldsymbol{x} = \iint f(\boldsymbol{u})e^{-2\pi i\boldsymbol{u}\cdot\mathbf{R}\boldsymbol{\xi}}d\boldsymbol{u} = \hat f(\mathbf{R}\boldsymbol{\xi}).

A consequence you can see in every image spectrum: a pattern that varies in one direction puts its energy on a line through the origin in that direction, perpendicular to its stripes. If f(x,y)=g(x)f(x, y) = g(x) does not depend on yy, separability with h=1h = 1 (whose transform is a spike at η=0\eta = 0) puts all of f^\hat f on the horizontal axis. In the explorer below, choose Sunset: the horizon and the waves are horizontal, they vary vertically, and the spectrum has a bright vertical streak. Its strongest off-centre wave, found by the figure, is four horizontal stripes across the image.

The figure works on 256×256256 \times 256 versions of my sketches, using the discrete transform of Part 2. The bright centre is zero frequency, and brightness is log⁡∣f^∣\log\lvert\hat f\rvert. Things to try: low-pass with a sharp edge, then tick smooth edge and watch the ringing (Gibbs, in 2-D) disappear; one wave to see what a single dot is; erase to delete a direction of texture.

How fast does the spectrum of a picture fall off? For photographs of natural scenes, power falls roughly like 1/∣ξ∣21/\lvert\boldsymbol{\xi}\rvert^2, so amplitude like 1/∣ξ∣1/\lvert\boldsymbol{\xi}\rvert (Field, 1987). My sketches are a little smoother: fitting the radially averaged power between 4 and 100 cycles per image gives exponents from −2.2-2.2 (Portrait, with its fine hatching) to −2.7-2.7 (Tree). By Section 4, this slow, power-law decay is the signature of edges: images are full of jumps.

The projection–slice theorem

One 2-D result deserves a place here because a machine in every hospital depends on it.

Theorem 3 (Projection–slice)

Let p(x)=∫f(x,y) dyp(x) = \int f(x, y)\,dy be the projection of an image onto the xx-axis. Then p^(ξ)=f^(ξ,0)\hat p(\xi) = \hat f(\xi, 0): the 1-D transform of a projection is a slice of the 2-D transform through the origin. By the rotation theorem, the same holds at every angle.

Proof

Step 1. p^(ξ)=∫(∫f(x,y) dy)e−2πixξdx\hat p(\xi) = \int\Big(\int f(x, y)\,dy\Big)e^{-2\pi ix\xi}dx.

Step 2. Insert e−2πiy⋅0=1e^{-2\pi iy\cdot 0} = 1: p^(ξ)=∬f(x,y) e−2πi(xξ+y⋅0) dx dy=f^(ξ,0)\hat p(\xi) = \iint f(x, y)\,e^{-2\pi i(x\xi + y\cdot 0)}\,dx\,dy = \hat f(\xi, 0).

Step 3. Other angles. Projecting along direction θ\theta is projecting the rotated image f(Rθx)f(\mathbf{R}_\theta\boldsymbol{x}) onto the xx-axis; by the rotation theorem its 2-D transform is f^(Rθξ)\hat f(\mathbf{R}_\theta\boldsymbol{\xi}), whose slice at η=0\eta = 0 is f^\hat f along the rotated axis.

projection–slice: how a CT scanner sees inside youf(x, y)projection p(x) = ∫ f(x, y) dyf̂(ξ, η)η = 0the slice f̂(ξ, 0)2-D Fourier transform1-D Fourier transformthey agree: p̂(ξ) = f̂(ξ, 0)rotate the rays and you read another slice; enough angles fill the whole spectrum

A CT scanner measures X-ray projections of a body at many angles. Each projection, transformed, fills one line of the 2-D spectrum; enough angles fill it all, and an inverse 2-D transform (in practice, its rearrangement as filtered back-projection) gives the image. MRI goes further: it measures the spectrum f^\hat f directly, one line of “k-space” at a time.

10. Amplitude versus phase

Every Fourier coefficient is a magnitude and a phase. Which one carries the picture? Rebuild an image from the amplitudes of one sketch and the phases of another.

A: B:

(On a phone the panel titles abbreviate phase as ∠.) The image with the Portrait’s amplitudes and the Tree’s phases looks like the tree: its correlation with the tree is 0.810.81, with the portrait 0.160.16. Keep the portrait’s amplitudes and draw the phases at random, and the correlation with the portrait falls to 0.050.05: a texture with the right mixture of scales and nothing in place. Oppenheim and Lim made this observation famous in 1981, and it is easy to underrate.

Why phase? By the shift rule, position lives in the phase. And edges are places where many frequencies agree. Look at the square wave’s series, 4π∑sin⁡2πkxk\frac4\pi\sum\frac{\sin 2\pi kx}{k}: at the jump x=0x = 0, every term crosses zero going upward at the same moment. An edge is a phase alignment across frequencies (Morrone and Owens call it phase congruency), and the amplitudes, which are much alike from one natural image to the next, only say how strong each scale is.

Note (What this means in practice)

Discarding phase is a common way to lose information without noticing: a magnitude spectrogram, a power spectrum used as a feature, a loss computed on ∣f^∣\lvert\hat f\rvert only. Recovering a signal from magnitudes alone, phase retrieval, is a field of its own, central to X-ray crystallography and coherent diffraction imaging.

11. What Fourier cannot tell you

Go back to the song. Its spectrum has two sharp peaks for the chord, a broad plateau for the chirp, and a faint floor that covers every frequency. That floor is the click: a spike contains every frequency equally (Section 6). The spectrum is a perfect inventory, and it is silent about when. Nothing in ∣x^(ξ)∣\lvert\hat x(\xi)\rvert says that the chirp rises rather than falls, or that the click comes last. The same is true of the edge of an eyelid in a sketch: it is everywhere in the spectrum and nowhere in particular.

what Fourier keeps, and what it throws awaya clicktime →a score: which notes, and whenthe click: a thin floorunder every frequencyfrequency →a spectrum: which notes, how much; not when

This is not a defect of the computation. Every e2πiξxe^{2\pi i\xi x} stretches over the whole line, so every coefficient is a global average. To say where and when, we need building blocks that are local in both position and frequency. How local they can be is limited by a theorem, the uncertainty principle, which Part 2 proves along with everything that changes when signals are sampled and finite. Part 3 then builds the best compromise, wavelets.

12. Implementation and caveats

In practice the integrals of this post are computed with the FFT, an algorithm for the discrete Fourier transform X[k]=∑n=0N−1x[n]e−2πikn/NX[k] = \sum_{n=0}^{N-1}x[n]e^{-2\pi ikn/N} (Part 2 derives it). Two recipes cover most needs.

Fourier series coefficients. Sample one period at xn=n/Nx_n = n/N. The rectangle rule turns ck=∫01f(x)e−2πikxdxc_k = \int_0^1 f(x)e^{-2\pi ikx}dx into 1N∑nf(xn)e−2πikn/N=X[k]/N\frac1N\sum_n f(x_n)e^{-2\pi ikn/N} = X[k]/N.

import numpy as np

N = 4096
x = np.arange(N) / N                     # one period, [0, 1)
f = np.where(x < 0.5, 1.0, -1.0)         # the square wave of Section 3
c = np.fft.fft(f) / N                    # c[k] ~ c_k for 0 <= k < N/2, and c[N - k] ~ c_{-k}
print(c[1], 2 / (np.pi * 1j))            # both about -0.6366j

The Fourier transform on a grid. Sample ff at xn=x0+nΔxx_n = x_0 + n\Delta x. At the frequencies ξk=k/(NΔx)\xi_k = k/(N\Delta x), a Riemann sum gives f^(ξk)≈Δx∑nf(xn)e−2πiξk(x0+nΔx)=Δx e−2πiξkx0 X[k]\hat f(\xi_k) \approx \Delta x\sum_n f(x_n)e^{-2\pi i\xi_k(x_0 + n\Delta x)} = \Delta x\,e^{-2\pi i\xi_k x_0}\,X[k], because ξknΔx=kn/N\xi_k n\Delta x = kn/N.

n, L = 512, 16.0
dx = L / n
xg = -L / 2 + dx * np.arange(n)                             # the grid starts at x0 = -8, not at 0
f = np.exp(-np.pi * (xg - 1.0) ** 2)                        # a Gaussian centred at x = 1
xi = np.fft.fftfreq(n, d=dx)                                # frequencies in cycles per unit
F = dx * np.exp(-2j * np.pi * xi * xg[0]) * np.fft.fft(f)   # note the phase factor for x0
exact = np.exp(-np.pi * xi**2) * np.exp(-2j * np.pi * xi)   # Gaussian pair + shift rule
print(np.abs(F - exact).max())                              # about 1e-15

Both snippets were run as written. The traps, each with its symptom:

  1. The origin phase. Drop the factor e−2πiξkx0e^{-2\pi i\xi_kx_0} and the magnitude is still exactly right but the phase is wrong by up to π\pi (measured: magnitude error 2×10−162\times10^{-16}, phase error 3.143.14 rad). A plot of ∣f^∣\lvert\hat f\rvert will never reveal this bug.
  2. Conventions. NumPy uses the DFT above, with 1/N1/N on the inverse; norm="ortho" puts 1/N1/\sqrt N on both. Mixing ξ\xi and ω\omega costs a factor of 2π2\pi (Section 6).
  3. Frequency order. The FFT returns k=0,1,…,N/2−1k = 0, 1, \ldots, N/2 - 1, then the negative frequencies. Use fftfreq for the values and fftshift to centre zero for display.
  4. Real input. A real signal has f^(−ξ)=f^(ξ)‾\hat f(-\xi) = \overline{\hat f(\xi)}: half the output is redundant. rfft returns only the non-negative half and is about twice as fast.
  5. Truncation rings. Cutting a spectrum sharply, to compress or to denoise, rings near edges (Gibbs). Taper the cut.
  6. Differentiation by FFT multiplies by 2πiξ2\pi i\xi: superb for smooth periodic data, disastrous for noisy data or data with jumps, where it amplifies noise and Gibbs ripples.
  7. Display. Show log⁡(1+∣f^∣)\log(1 + \lvert\hat f\rvert); raw magnitudes are a single bright dot. Phase is meaningless where the magnitude is near zero, so mask it there.

Two issues are deliberately left for Part 2: why the FFT of a function that is not periodic on its window shows a bright cross (“leakage”), and why sampling too coarsely silently changes frequencies (“aliasing”).

13. Where it is used, and what is open

Use Fourier analysis whenBe careful when
the operation is linear and shift-invariant (blur, convolution, differentiation, constant-coefficient PDEs)the signal changes character over time or space (speech, a chirp, an image with distinct regions)
the domain is periodic, or can be made sothere are boundaries the method does not know about
you need global structure: dominant orientations, textures, periodicityyou need to locate a localised event
speed matters: convolution with large kernels, solving Poisson’s equationthe data has jumps and you need pointwise accuracy

Where it shows up in current work. Spectral methods for PDEs on periodic domains; CT and MRI reconstruction, including from undersampled k-space; phase correlation for image registration; Fourier features and positional encodings in neural fields (Tancik et al., 2020), together with the observation that networks learn low frequencies first, spectral bias (Rahaman et al., 2019); global filtering layers in vision networks (GFNet); Fourier neural operators for learning PDE solution maps (Li et al., 2021); FFT-based long convolutions in sequence models.

Open questions worth a PhD’s attention:

  1. Spectral bias, made predictive. Networks fit low frequencies first. Can we predict, from an architecture and its initialisation, which frequencies it will learn and how fast, and choose encodings accordingly instead of by trial?
  2. Phase retrieval with learned priors. Recovering an image from Fourier magnitudes is ill-posed in general; learned priors make it work in practice. When is the answer unique and stable, and can the prior’s errors be detected?
  3. Fourier methods off the grid. FFT speed needs regular grids and periodic boundaries. What is the right fast spectral layer on irregular meshes, point clouds or bounded domains, without losing the diagonalisation of Section 5?
  4. When does global spectral mixing beat attention or convolution in vision models, and why? Current evidence is empirical and task-specific.
  5. Trusting individual frequencies. A learned surrogate may be accurate at low frequencies and wrong at high ones. How should uncertainty be reported per frequency band, so that a user knows which scales of a prediction to believe?
Note (Shoulders to stand on)

Self-check

Question 4

You shift an image by 10 pixels. What happens to ∣f^∣\lvert\hat f\rvert, and what happens to the phase?

Answer

By the shift rule, f^\hat f is multiplied by e−2πia⋅ξe^{-2\pi i\boldsymbol{a}\cdot\boldsymbol{\xi}} with a\boldsymbol{a} the shift. The magnitude is unchanged; the phase gains a linear ramp −2πa⋅ξ-2\pi\boldsymbol{a}\cdot\boldsymbol{\xi}. (On a finite image the shift must be circular for this to be exact; Part 2.)

Question 5

Show that a real, even function has a real, even Fourier transform.

Answer

Step 1. f^(ξ)=∫f(x)cos⁡(2πξx)dx−i∫f(x)sin⁡(2πξx)dx\hat f(\xi) = \int f(x)\cos(2\pi\xi x)dx - i\int f(x)\sin(2\pi\xi x)dx. Step 2. f(x)sin⁡(2πξx)f(x)\sin(2\pi\xi x) is odd in xx when ff is even, so its integral over the line is 00: f^\hat f is real. Step 3. cos⁡(2πξx)\cos(2\pi\xi x) is even in ξ\xi, so f^(−ξ)=f^(ξ)\hat f(-\xi) = \hat f(\xi).

Question 6

Why does the square wave have no even harmonics?

Answer

It satisfies f(x+12)=−f(x)f(x + \tfrac12) = -f(x). Then ck=∫01f(x)e−2πikxdxc_k = \int_0^1 f(x)e^{-2\pi ikx}dx, and substituting x→x+12x \to x + \tfrac12 gives ck=∫01f(x+12)e−2πik(x+1/2)dx=−(−1)kckc_k = \int_0^1 f(x + \tfrac12)e^{-2\pi ik(x + 1/2)}dx = -(-1)^k c_k. For even kk this says ck=−ckc_k = -c_k, so ck=0c_k = 0.

Question 7

Which decays faster: the Fourier coefficients of the 1-periodic extension of xx on [−12,12)[-\tfrac12, \tfrac12), or of ∣x∣\lvert x\rvert?

Answer

∣x∣\lvert x\rvert: its periodic extension is continuous, with kinks, so its coefficients fall like 1/k21/k^2. The extension of xx jumps at ±12\pm\tfrac12, so its coefficients fall only like 1/k1/k (Section 4).

Question 8

You blur an image with a Gaussian of standard deviation σ\sigma pixels. By what factor is the amplitude of a grating of frequency ∣ξ∣\lvert\boldsymbol{\xi}\rvert (cycles per pixel) reduced?

Answer

The kernel 12πσ2e−∣x∣2/2σ2\frac{1}{2\pi\sigma^2}e^{-\lvert\boldsymbol{x}\rvert^2/2\sigma^2} is separable; in each direction, by the Gaussian pair and scaling (e−x2/2σ2=e−π(x/s)2e^{-x^2/2\sigma^2} = e^{-\pi(x/s)^2} with s=σ2πs = \sigma\sqrt{2\pi}), its normalised transform is e−πs2ξ2=e−2π2σ2ξ2e^{-\pi s^2\xi^2} = e^{-2\pi^2\sigma^2\xi^2}. In 2-D the factor is e−2π2σ2∣ξ∣2e^{-2\pi^2\sigma^2\lvert\boldsymbol{\xi}\rvert^2}. Energy, the square, falls by e−4π2σ2∣ξ∣2e^{-4\pi^2\sigma^2\lvert\boldsymbol{\xi}\rvert^2}.

Question 9

A real cosine of amplitude 11 is sampled at NN points and passed to an FFT. Why are there two peaks of height N/2N/2 instead of one of height NN?

Answer

By Section 3, cos⁡θ=12eiθ+12e−iθ\cos\theta = \tfrac12e^{i\theta} + \tfrac12e^{-i\theta}: half the amplitude sits at +k0+k_0 and half at −k0-k_0, and the DFT stores −k0-k_0 at index N−k0N - k_0. Each phasor contributes N⋅12N\cdot\tfrac12 through a geometric sum; Part 2 carries out the sum.

References

  • A. V. Oppenheim, J. S. Lim. The importance of phase in signals. Proceedings of the IEEE 69(5), 1981.
  • M. C. Morrone, R. A. Owens. Feature detection from local energy. Pattern Recognition Letters 6(5), 1987.
  • D. J. Field. Relations between the statistics of natural images and the response properties of cortical cells. JOSA A 4(12), 1987.
  • E. M. Stein, R. Shakarchi. Fourier Analysis: An Introduction. Princeton, 2003. (Fejér’s theorem, inversion, Plancherel.)
  • B. Osgood. Lecture Notes for EE 261: The Fourier Transform and its Applications. Stanford University.
  • A. Torralba, P. Isola, W. T. Freeman. Foundations of Computer Vision. MIT Press, 2024.
  • G. Sanderson. But what is the Fourier Transform? A visual introduction. 3Blue1Brown, 2018.
  • M. Tancik et al. Fourier features let networks learn high frequency functions in low dimensional domains. NeurIPS, 2020.
  • N. Rahaman et al. On the spectral bias of neural networks. ICML, 2019.
  • Y. Rao et al. Global filter networks for image classification. NeurIPS, 2021.
  • Z. Li et al. Fourier neural operator for parametric partial differential equations. ICLR, 2021.