
# Fourier Series & Transforms

> Any reasonable signal is a sum of pure rotations $e^{i\omega t}$ — 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:

1. **Prove** the orthogonality of complex exponentials on an interval and use it to extract Fourier coefficients.
2. **Compute** the complex Fourier series of a periodic function and state the convergence guarantees you can rely on.
3. **Define** the continuous Fourier transform and its inverse, and **apply** linearity, time/frequency shift, and the convolution theorem.
4. **Derive** Parseval/Plancherel and interpret it as conservation of energy between time and frequency domains.
5. **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 $e^{i\omega t}$ spinning at
its own frequency $\omega$, 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, $e^{i m t}$ and $e^{i n t}$ have zero overlap unless $m=n$. This is the continuous
sibling of the roots-of-unity vanishing sum from [lesson 1](01-complex-numbers-functions.md) —
distinct frequencies average to nothing. Orthogonality is what makes "project onto frequency $\omega$"
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](03-discrete-fourier-transform.md) turns it into an algorithm, and the quantum version
turns that algorithm into a circuit.

---

## Theory

### Orthogonality of complex exponentials

Work on the interval $[0,T]$ and define, for integer $n$, the functions $e_n(t) = e^{i 2\pi n t/T}$.
These are exactly the *tones whose period divides $T$*. Equip the space of (square-integrable)
functions on $[0,T]$ with the Hermitian inner product (conjugate the left factor, matching
[Appendix C §1](../../appendix/C-notation-glossary.md)):

$$
\langle f, g\rangle := \int_0^T f(t)^{*}\,g(t)\,dt.
$$

**Lemma (orthogonality).**

$$
\langle e_m, e_n\rangle = \int_0^T e^{-i2\pi m t/T}\,e^{i2\pi n t/T}\,dt = T\,\delta_{mn}.
$$

*Proof.* The integrand is $e^{i2\pi(n-m)t/T}$. If $m=n$ it equals $1$ and integrates to $T$.
Otherwise let $k = n-m\neq 0$ and integrate the exponential:

$$
\int_0^T e^{i2\pi k t/T}\,dt
= \left[\frac{T}{i2\pi k}\,e^{i2\pi k t/T}\right]_0^T
= \frac{T}{i2\pi k}\big(e^{i2\pi k} - 1\big) = \frac{T}{i2\pi k}\big(1 - 1\big) = 0,
$$

since $e^{i2\pi k} = 1$ for integer $k$. $\blacksquare$

This is the continuous analog of the roots-of-unity orthogonality $\tfrac1N\sum_x \omega^{x(j-k)} =
\delta_{jk}$ ([Appendix E §6](../../appendix/E-math-identities.md)): replace the sum over $N$ sample
points by an integral over the period. The $\{e_n/\sqrt T\}$ form an *orthonormal* family.

### Fourier series of a periodic function

Let $f$ be $T$-periodic and square-integrable on a period. Because $\{e_n\}$ is a complete
orthogonal system (a theorem of analysis we use, not reprove), $f$ has the **complex Fourier series**

$$
f(t) = \sum_{n=-\infty}^{\infty} c_n\, e^{i2\pi n t/T}.
$$

The coefficients fall out of orthogonality: take the inner product of both sides with $e_m$ and use
the lemma. Only the $n=m$ term survives,

$$
\langle e_m, f\rangle = \sum_n c_n\langle e_m, e_n\rangle = \sum_n c_n\,T\delta_{mn} = c_m\,T,
$$

so the **analysis formula** is

$$
\boxed{\,c_n = \frac{1}{T}\int_0^T f(t)\,e^{-i2\pi n t/T}\,dt\,}.
$$

Each $c_n$ is the (normalized) overlap of $f$ with the pure tone of frequency $n/T$ — the amount of
that tone in the blend. Note $c_0 = \tfrac1T\int_0^T f\,dt$ is the average (DC) value.

**Reality and symmetry.** If $f$ is real then $c_{-n} = c_n^{*}$ (conjugate-symmetric spectrum),
because conjugating the integrand flips the sign of the exponent. Pairing $\pm n$ then recovers the
familiar real sine/cosine series:

$$
f(t) = c_0 + \sum_{n=1}^{\infty}\Big[a_n\cos\tfrac{2\pi n t}{T} + b_n\sin\tfrac{2\pi n t}{T}\Big],
\quad a_n = 2\operatorname{Re}c_n,\ \ b_n = -2\operatorname{Im}c_n.
$$

**Convergence (what you can rely on).** For $f\in L^2[0,T]$ the partial sums converge to $f$ *in the
$L^2$ (mean-square) sense*: $\|f - \sum_{|n|\le M} c_n e_n\|_2 \to 0$. If $f$ is piecewise-$C^1$, the
series converges *pointwise* to $f(t)$ where $f$ is continuous and to the midpoint
$\tfrac12\big(f(t^+)+f(t^-)\big)$ at jumps; near a jump the partial sums overshoot by a fixed
$\approx 9\%$ (the **Gibbs phenomenon**), which never disappears but moves toward the jump as $M$
grows. We will *see* Gibbs in the code.

### The continuous Fourier transform

Let the period $T\to\infty$: the discrete frequencies $n/T$ crowd into a continuum $\xi$, the sum
becomes an integral, and the Fourier *series* becomes the Fourier *transform*. For an integrable (or
$L^2$) function $f:\mathbb R\to\mathbb C$ we use the convention

$$
\boxed{\;\hat f(\xi) = \mathcal F[f](\xi) = \int_{-\infty}^{\infty} f(t)\,e^{-i2\pi\xi t}\,dt\;}
$$

with frequency $\xi$ in cycles per unit time, and the **inversion formula**

$$
\boxed{\;f(t) = \mathcal F^{-1}[\hat f](t) = \int_{-\infty}^{\infty} \hat f(\xi)\,e^{+i2\pi\xi t}\,d\xi\;}.
$$

The $e^{\mp 2\pi i\xi t}$ kernel and the $\pm$ sign convention match the DFT forward/inverse pair in
[lesson 3](03-discrete-fourier-transform.md) and the program-wide choice in
[Appendix C §4](../../appendix/C-notation-glossary.md) (no stray $1/2\pi$ factors with this "ordinary
frequency" convention — a convenience we exploit below).

### Key properties

Let $\hat f = \mathcal F[f]$, $\hat g = \mathcal F[g]$, and $a,b\in\mathbb C$. The following are
direct consequences of the integral definition.

**Linearity.** $\mathcal F[a f + b g] = a\hat f + b\hat g$ (the integral is linear).

**Time shift.** $\mathcal F[f(t - t_0)](\xi) = e^{-i2\pi\xi t_0}\,\hat f(\xi)$.

*Proof.* Substitute $u = t - t_0$, $du = dt$:
$\int f(t-t_0)e^{-i2\pi\xi t}\,dt = \int f(u)e^{-i2\pi\xi(u+t_0)}\,du = e^{-i2\pi\xi t_0}\hat f(\xi)$.
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).** $\mathcal F[e^{i2\pi\xi_0 t}f(t)](\xi) = \hat f(\xi - \xi_0)$ —
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

$$
\boxed{\;\mathcal F[f * g] = \hat f \cdot \hat g\;}\qquad\text{and dually}\qquad
\mathcal F[f\cdot g] = \hat f * \hat g.
$$

*Proof.* Write out and swap the order of integration (justified for $L^1$ functions by Fubini):

$$
\mathcal F[f*g](\xi) = \int_t\!\!\int_\tau f(\tau)g(t-\tau)\,d\tau\;e^{-i2\pi\xi t}\,dt
= \int_\tau f(\tau)\Big[\int_t g(t-\tau)e^{-i2\pi\xi t}\,dt\Big]d\tau.
$$

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

$$
\mathcal F[f*g](\xi) = \hat g(\xi)\int_\tau f(\tau)e^{-i2\pi\xi\tau}\,d\tau = \hat f(\xi)\hat g(\xi).
\qquad\blacksquare
$$

This is the property that makes the FFT a workhorse of computation: convolution costs $O(N^2)$
directly but $O(N\log N)$ via "transform, multiply, inverse-transform." We use it in the code.

**Parseval / Plancherel — derivation.** With the ordinary-frequency convention above, the transform
*preserves energy*:

$$
\boxed{\;\int_{-\infty}^{\infty}|f(t)|^2\,dt = \int_{-\infty}^{\infty}|\hat f(\xi)|^2\,d\xi\;}.
$$

*Proof.* Start from the left and write $|f|^2 = f\,f^{*}$, expressing $f$ by inversion and $f^{*}$ by
the conjugate of inversion:

$$
\int_t |f(t)|^2\,dt
= \int_t f(t)\Big(\int_\xi \hat f(\xi) e^{i2\pi\xi t}\,d\xi\Big)^{\!*}\,dt
= \int_t f(t)\int_\xi \hat f(\xi)^{*} e^{-i2\pi\xi t}\,d\xi\,dt.
$$

Swap the order of integration (Fubini) and group the $t$-integral:

$$
= \int_\xi \hat f(\xi)^{*}\Big[\int_t f(t)e^{-i2\pi\xi t}\,dt\Big]d\xi
= \int_\xi \hat f(\xi)^{*}\,\hat f(\xi)\,d\xi
= \int_\xi |\hat f(\xi)|^2\,d\xi. \qquad\blacksquare
$$

The bracket is just the forward transform $\hat f(\xi)$. The polarized version
$\int f^{*}g = \int \hat f^{*}\hat g$ (Plancherel) follows identically with $g$ in place of the
second $f$ — i.e. **the Fourier transform is unitary on $L^2$**, an inner-product-preserving map.
This is the continuous shadow of the fact, proved in [lesson 3](03-discrete-fourier-transform.md),
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 $\hat f$ is itself complex: $|\hat f(\xi)|$ is the **magnitude spectrum** (how much
energy at frequency $\xi$) and $\arg\hat f(\xi)$ 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 $f$ be the odd square wave of period $T = 2\pi$ with $f(t) = +1$ on $(0,\pi)$ and $-1$ on
$(-\pi,0)$ (so $T$-periodic). Compute its complex coefficients $c_n = \tfrac1T\int_{-\pi}^{\pi}
f(t)e^{-int}\,dt$ (here $2\pi n/T = n$).

For $n=0$: $c_0 = \tfrac1{2\pi}\int_{-\pi}^{\pi} f = 0$ (equal $+$ and $-$ areas; zero average).

For $n\neq 0$, split the integral and use $\int e^{-int}dt = e^{-int}/(-in)$:

$$
c_n = \frac{1}{2\pi}\Big[\int_0^{\pi}(+1)e^{-int}\,dt + \int_{-\pi}^{0}(-1)e^{-int}\,dt\Big].
$$

The first integral is $\frac{1}{-in}(e^{-in\pi}-1)$; the second is $-\frac{1}{-in}(1 - e^{in\pi})$.
Using $e^{\pm in\pi} = (-1)^n$ and simplifying,

$$
c_n = \frac{1}{2\pi}\cdot\frac{1}{-in}\Big[\big((-1)^n - 1\big) - \big(1 - (-1)^n\big)\Big]
= \frac{1}{2\pi}\cdot\frac{2\big((-1)^n - 1\big)}{-in}
= \frac{1 - (-1)^n}{i\pi n}.
$$

So $c_n = 0$ for even $n$ and $c_n = \dfrac{2}{i\pi n}$ for odd $n$. Reassembling the real series
(pairing $\pm n$, only odd $n$ survive) gives the classic

$$
f(t) = \frac{4}{\pi}\sum_{k=0}^{\infty}\frac{\sin\big((2k+1)t\big)}{2k+1}
= \frac{4}{\pi}\Big(\sin t + \tfrac13\sin 3t + \tfrac15\sin 5t + \cdots\Big).
$$

Only odd harmonics appear (by the symmetry $f(t+\pi) = -f(t)$), and their amplitudes decay like
$1/n$ — slow decay characteristic of a jump discontinuity, which is why truncating the series
produces Gibbs overshoot near $t=0,\pi$.

Truncate it yourself below. Beside the jump the partial sum peaks near
$\tfrac{2}{\pi}\operatorname{Si}(\pi) \approx 1.179$, about 9% of the jump of 2, however many
terms you keep; the overshoot only narrows. The triangle and the plucked string, which have no
jumps, show the contrast: their coefficients fall like $1/n^2$ and the error goes to zero.

```qm-demo fourier-synthesis

```

### Example 2 — Transform of a Gaussian (a fixed point)

Let $f(t) = e^{-\pi t^2}$. Its transform is itself:

$$
\hat f(\xi) = \int_{-\infty}^{\infty} e^{-\pi t^2}e^{-i2\pi\xi t}\,dt = e^{-\pi\xi^2}.
$$

*Sketch.* Complete the square in the exponent: $-\pi t^2 - i2\pi\xi t = -\pi(t + i\xi)^2 - \pi\xi^2$.
Pulling out $e^{-\pi\xi^2}$ leaves $\int e^{-\pi(t+i\xi)^2}dt$, which equals $\int e^{-\pi u^2}du = 1$
(the Gaussian integral, with a contour-shift justification). Hence $\hat f(\xi) = e^{-\pi\xi^2}$. The
Gaussian is the eigenfunction with eigenvalue $1$: 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 $\mathcal F[f(at)] = \tfrac1{|a|}\hat f(\xi/a)$ shows.)

### Example 3 — Convolution as filtering

Let $g$ be a normalized box of width $w$: $g(t) = \tfrac1w$ for $|t|\le w/2$, else $0$. Then $(f *
g)(t) = \tfrac1w\int_{t-w/2}^{t+w/2} f(\tau)\,d\tau$ is the *moving average* of $f$ — a smoother. Its
transform is, by the convolution theorem, $\widehat{f*g} = \hat f\cdot\hat g$ where $\hat g(\xi) =
\operatorname{sinc}(w\xi) = \sin(\pi w\xi)/(\pi w\xi)$. Because $\hat g$ decays away from $\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)

```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 $M$ grows; the numerically computed $c_n$ match $2/(i\pi n)$
for odd $n$ and vanish for even $n$; `np.allclose(direct, via_fft)` prints `True`, confirming
$\mathcal F[f*g] = \hat f\hat g$; and the filtered spectrum is visibly attenuated at high
frequencies — convolution in time is multiplication in frequency.

> **Note on circular vs. linear convolution.** `np.fft` computes *circular* convolution (the DFT
> treats data as one period of a periodic signal — see [lesson 3](03-discrete-fourier-transform.md)).
> For *linear* convolution, zero-pad both inputs to length $\ge \text{len}(f)+\text{len}(g)-1$ before
> transforming. This periodicity is the bridge from the continuous theory here to the discrete
> machinery next.

---

## Exercises

**1. (Easy) Linearity and shift.** Given $\hat f(\xi)$, write the transform of $h(t) = 3f(t) -
f(t-5)$ in terms of $\hat f$.

<details><summary>Solution</summary>

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
$e^{-i10\pi\xi}$; the magnitude spectrum is reshaped by $|3 - e^{-i10\pi\xi}|$.

</details>

**2. (Easy) DC coefficient.** Show that the $n=0$ Fourier coefficient $c_0$ equals the average of
$f$ over a period, and compute it for $f(t) = 2 + 3\cos(2\pi t/T)$.

<details><summary>Solution</summary>

$c_0 = \tfrac1T\int_0^T f(t)e^{0}\,dt = \tfrac1T\int_0^T f$, which is the mean by definition. For
$f = 2 + 3\cos(2\pi t/T)$ the cosine integrates to $0$ over a full period, leaving $c_0 = 2$. (The
$\cos$ contributes $c_{\pm 1} = 3/2$ each, since $\cos\theta = \tfrac12(e^{i\theta}+e^{-i\theta})$.)

</details>

**3. (Medium) Parseval for a finite series.** For a real $T$-periodic $f$ with coefficients $c_n$,
prove the series form of Parseval: $\tfrac1T\int_0^T|f(t)|^2\,dt = \sum_{n}|c_n|^2$.

<details><summary>Solution</summary>

Write $f = \sum_n c_n e_n$ and $f^{*} = \sum_m c_m^{*} e_m^{*}$ with $e_n(t)=e^{i2\pi nt/T}$. Then
$$
\tfrac1T\int_0^T |f|^2\,dt = \tfrac1T\int_0^T \sum_{n,m} c_n c_m^{*}\, e_n e_m^{*}\,dt
= \sum_{n,m} c_n c_m^{*}\,\tfrac1T\langle e_m, e_n\rangle = \sum_{n,m} c_n c_m^{*}\,\delta_{mn}
= \sum_n |c_n|^2,
$$
using the orthogonality lemma $\tfrac1T\langle e_m, e_n\rangle = \delta_{mn}$. Energy in time =
energy in the coefficients. $\blacksquare$

</details>

**4. (Medium) Convolution by hand.** Let $f = g = \mathbf 1_{[0,1]}$ (indicator of $[0,1]$). Compute
$(f * g)(t)$ directly and confirm via the convolution theorem that its transform is $\hat f(\xi)^2$.

<details><summary>Solution</summary>

$(f*g)(t) = \int \mathbf 1_{[0,1]}(\tau)\mathbf 1_{[0,1]}(t-\tau)\,d\tau$ = length of the overlap of
$[0,1]$ and $[t-1,t]$. This is the **triangle** function: $0$ for $t\le 0$, rising as $t$ for
$0\le t\le 1$, falling as $2-t$ for $1\le t\le 2$, and $0$ for $t\ge 2$. 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)$ (with $\operatorname{sinc}(\xi)=\sin\pi\xi/\pi\xi$). By the convolution
theorem $\widehat{f*g} = \hat f^2 = e^{-i2\pi\xi}\operatorname{sinc}^2(\xi)$, the well-known
transform of a triangle (a squared sinc) — consistent with the direct computation.

</details>

**5. (Hard) Plancherel ⇒ unitarity intuition.** Using the convention in this lesson, show that the
operator $\mathcal F$ preserves the $L^2$ inner product $\langle f,g\rangle = \int f^{*}g$, i.e.
$\langle \mathcal F f, \mathcal F g\rangle = \langle f, g\rangle$, and explain in one sentence why
this is the continuous analog of "the DFT matrix is unitary."

<details><summary>Solution</summary>

Repeat the Parseval derivation with $g$ in the second slot: expand $\langle f,g\rangle = \int_t
f(t)^{*}g(t)\,dt$, substitute $g(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)^{*}$. This leaves $\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
($U^\dagger U = I$); in finite dimensions the same statement is "the normalized DFT matrix $U$
satisfies $U^\dagger U = I$," proved in [lesson 3](03-discrete-fourier-transform.md).

</details>

**6. (Hard) Smoothness ⇒ decay.** Argue that if $f$ is $T$-periodic and $C^k$ (k continuous
derivatives), then its Fourier coefficients satisfy $c_n = O(|n|^{-k})$ as $|n|\to\infty$. Connect
this to the slow $1/n$ decay seen for the (discontinuous) square wave.

<details><summary>Solution</summary>

Integrate the coefficient formula by parts. Each integration by parts moves a derivative off the
exponential and onto $f$: $\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}dt$ (boundary terms vanish by periodicity). Hence $c_n = \frac{T}{i2\pi n}\cdot
c_n^{(f')}$, i.e. differentiating multiplies the coefficient by $i2\pi n/T$; equivalently a smooth
$f'$ has bounded coefficients, so $c_n = O(1/|n|)$ for $C^1$. Repeating $k$ times gives $c_n =
O(|n|^{-k})$ provided $f^{(k)}\in L^2$. The square wave is *not* continuous ($k=0$ effectively, with
a jump), so its coefficients decay only like $1/n$ — 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.

</details>

---

## Checkpoint

<details><summary>1. State the orthogonality relation for $e_n(t)=e^{i2\pi nt/T}$ on $[0,T]$ and why it matters.</summary>

$\int_0^T e_m^{*}e_n\,dt = T\delta_{mn}$. It lets you read off each Fourier coefficient
independently by an inner product: $c_n = \tfrac1T\langle e_n, f\rangle$ — projecting $f$ onto one
pure frequency without interference from the others.

</details>

<details><summary>2. Write the analysis and synthesis formulas for the continuous Fourier transform (this lesson's convention).</summary>

Analysis: $\hat f(\xi) = \int f(t)e^{-i2\pi\xi t}dt$. Synthesis (inverse): $f(t) = \int \hat
f(\xi)e^{+i2\pi\xi t}d\xi$. The $\mp$ signs and the absence of $1/2\pi$ factors match the program's
DFT/QFT conventions.

</details>

<details><summary>3. What does the convolution theorem say, and why is it computationally important?</summary>

$\mathcal F[f*g] = \hat f\cdot\hat g$: convolution in time is pointwise multiplication in frequency.
It turns an $O(N^2)$ convolution into "FFT, multiply, inverse-FFT," which is $O(N\log N)$.

</details>

<details><summary>4. State Parseval/Plancherel and interpret it physically.</summary>

$\int|f|^2\,dt = \int|\hat f|^2\,d\xi$ (and $\langle f,g\rangle = \langle\hat f,\hat g\rangle$).
Total energy is conserved between time and frequency domains; equivalently, $\mathcal F$ is unitary
on $L^2$.

</details>

<details><summary>5. Why does a time delay leave the magnitude spectrum unchanged?</summary>

Because $\mathcal F[f(t-t_0)] = e^{-i2\pi\xi t_0}\hat f(\xi)$: the delay multiplies by a
unit-modulus phase factor, so $|\hat f|$ is unchanged and only the phase spectrum tilts.

</details>

<details><summary>6. How does this continuous theory foreshadow the quantum Fourier transform?</summary>

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](../../term-2-qc-core/c04-qft-qpe/01-quantum-fourier-transform.md).

</details>

---

## 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](../../appendix/E-math-identities.md)** — geometric sums, orthogonality, the QFT
  kernel.
- **[Appendix B §1–2](../../appendix/B-python-numpy-refresher.md)** — complex arrays and inner
  products used in the code.

---

← Prev: [Complex Numbers & Functions](01-complex-numbers-functions.md) · Up: [Term 0](../README.md) · Next: [The Discrete Fourier Transform](03-discrete-fourier-transform.md) →
