Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Real and functional analysis

Hilbert Spaces and Orthonormal Bases

A Hilbert space is a complete space with an inner product, which gives lengths, angles and orthogonality, even for functions. Orthonormal bases turn approximation into simple formulas: coefficients are inner products, the best approximation is a projection, and the error follows from Pythagoras. This is the geometry behind least squares, Fourier series, PCA/POD, Gaussian processes and kernel methods.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Angles and shadows, even for curves

Shine a light straight down on a stick and it casts a shadow on the floor. The shadow is the closest point on the floor to the stick’s tip, and the line from tip to shadow is perpendicular to the floor. That simple picture of shadow, perpendicular and closest is all you need for the best approximation of anything.

The surprise is that it works for functions too. Two curves can be “perpendicular”, and the best way to approximate a messy curve with simple ones is to cast its shadow onto them. A space where lengths, angles and shadows all work is a Hilbert space.

Best approximation by orthogonal projection (Legendre basis)
coefficients cₖ = ⟨f, eₖ⟩, k = 0…24 (used ones coloured)
‖f‖² = 0.66667 · sum of cₖ² for k < N = 0.65625 · L² error ‖f − P_N f‖ = 1.02e-1 · sup error = 1.87e-1
Even, so every odd coefficient is 0. The kink makes coefficients decay slowly (like k⁻²). Grey: f. Orange: its projection onto the first N orthonormal Legendre polynomials. Adding a basis function never changes the earlier coefficients. That's the power of orthogonality.
Why engineers care

Fitting a model to sensor data (least squares), compressing a fluid simulation into a few modes, and filtering noise out of a signal are all “cast a shadow onto a simpler space”. The geometry guarantees the answer is the best possible, and tells you exactly how big the error is.

📝 Quick check (Level 0)
0/3 answered
  1. 1. The shadow is the ___ point on the floor.
  2. 2. The line from tip to shadow is ___ to the floor.
  3. 3. (2, 1) and (−1, 2): perpendicular?

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Inner products

An inner product ⟨x,y⟩\langle x,y\rangle is symmetric, linear in each slot, and positive (⟨x,x⟩>0\langle x,x\rangle > 0 for x≠0x\ne0). It gives a norm ∥x∥=⟨x,x⟩\|x\| = \sqrt{\langle x,x\rangle}, angles cos⁡θ=⟨x,y⟩∥x∥∥y∥\cos\theta = \frac{\langle x,y\rangle}{\|x\|\|y\|}, and orthogonality ⟨x,y⟩=0\langle x,y\rangle = 0.

Space Inner product
Rn\mathbb R^n x⊤yx^\top y (or x⊤Myx^\top My with MM SPD)
L2[a,b]L^2[a,b] ∫abf(x)g(x) dx\int_a^bf(x)g(x)\,dx
L2(p)L^2(p) (random variables) E[XY]\mathbb E[XY], which is the covariance for centred variables
matrices tr⁡(A⊤B)\operatorname{tr}(A^\top B) (Frobenius)

Function examples on [−1,1][-1,1]:

  • ⟨x,x2⟩=∫x3=0\langle x, x^2\rangle = \int x^3 = 0, so xx and x2x^2 are orthogonal: odd times even.
  • ∥1∥=2\|1\| = \sqrt2.
  • On [0,π][0,\pi], the functions sin⁡(kx)\sin(kx) are mutually orthogonal.

An orthonormal basis {ek}\{e_k\} has ⟨ej,ek⟩=δjk\langle e_j,e_k\rangle = \delta_{jk}. Then every f=∑k⟨f,ek⟩ekf = \sum_k\langle f,e_k\rangle e_k. The coefficients are just inner products, with no system of equations to solve.

📝 Quick check (Level 1)
0/3 answered
  1. 1. ⟨x, x²⟩ on [−1, 1] = ?
  2. 2. ‖1‖ in L²[−1, 1] = ?
  3. 3. In an orthonormal basis, the coefficient of eₖ is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

The projection theorem

Let VV be a closed subspace of a Hilbert space. For any ff there is a unique closest point Pf∈VPf\in V, and it’s characterized by the residual being orthogonal to VV: ⟨f−Pf,v⟩=0\langle f - Pf, v\rangle = 0 for all v∈Vv\in V. With an orthonormal basis e1,…,eNe_1,\dots,e_N of VV:

Pf=∑k=1N⟨f,ek⟩ek,∥f−Pf∥2=∥f∥2−∑k=1N∣⟨f,ek⟩∣2Pf = \sum_{k=1}^N\langle f,e_k\rangle e_k, \qquad \|f - Pf\|^2 = \|f\|^2 - \sum_{k=1}^N|\langle f,e_k\rangle|^2

The second formula is Pythagoras. Consequences:

  • Least squares is the projection of bb onto col⁡(A)\operatorname{col}(A), and the normal equations A⊤(b−Ax)=0A^\top(b - Ax) = 0 say “the residual is orthogonal” (A2.3-7).
  • Bessel’s inequality ∑k∣⟨f,ek⟩∣2≤∥f∥2\sum_k|\langle f,e_k\rangle|^2\le\|f\|^2 holds for any orthonormal set.
  • Parseval’s identity ∑k∣⟨f,ek⟩∣2=∥f∥2\sum_k|\langle f,e_k\rangle|^2 = \|f\|^2 holds exactly when the set is complete (a basis). Then the energy in the coefficients equals the energy of the function.

Building orthonormal bases

Apply Gram–Schmidt to 1,x,x2,…1, x, x^2, \dots in L2[−1,1]L^2[-1,1]. You get the Legendre polynomials, used by the demo. Different weights give other families:

  • Chebyshev (weight 1/1−x21/\sqrt{1-x^2});
  • Hermite (Gaussian weight; quantum oscillators, Gaussian chaos expansions);
  • Laguerre;
  • Fourier (A3.5-7).
🐍 Exercise 1: Gram–Schmidt in function space
Orthonormalize 1, x, …, x⁷ in L²[−1, 1] (you'll get Legendre polynomials). Project |x| onto growing subspaces, check that the residual is orthogonal and that Pythagoras holds, and confirm that the projection beats every other combination.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The best approximation in a subspace has a residual that is…
  2. 2. Gram–Schmidt on 1, x, x² in L²[−1, 1] gives…
  3. 3. Parseval's identity holds when the orthonormal set is…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proofs

Cauchy–Schwarz. If y=0y = 0 there’s nothing to prove. Otherwise, for every real tt, 0≤∥x−ty∥2=∥x∥2−2t⟨x,y⟩+t2∥y∥20\le\|x - ty\|^2 = \|x\|^2 - 2t\langle x,y\rangle + t^2\|y\|^2. This quadratic in tt is never negative, so its discriminant is ≤0\le0: ⟨x,y⟩2≤∥x∥2∥y∥2\langle x,y\rangle^2\le\|x\|^2\|y\|^2. ∎

Pythagoras. If ⟨u,v⟩=0\langle u,v\rangle = 0, then ∥u+v∥2=∥u∥2+2⟨u,v⟩+∥v∥2=∥u∥2+∥v∥2\|u + v\|^2 = \|u\|^2 + 2\langle u,v\rangle + \|v\|^2 = \|u\|^2 + \|v\|^2. ∎

Projection minimizes distance. For any v∈Vv\in V, f−v=(f−Pf)+(Pf−v)f - v = (f - Pf) + (Pf - v). The first piece is ⊥V\perp V and the second lies in VV. So ∥f−v∥2=∥f−Pf∥2+∥Pf−v∥2≥∥f−Pf∥2\|f - v\|^2 = \|f - Pf\|^2 + \|Pf - v\|^2\ge\|f - Pf\|^2, with equality only for v=Pfv = Pf. ∎

Which norms come from inner products?

A norm comes from an inner product if and only if it satisfies the parallelogram law ∥x+y∥2+∥x−y∥2=2∥x∥2+2∥y∥2\|x+y\|^2 + \|x-y\|^2 = 2\|x\|^2 + 2\|y\|^2 (Jordan–von Neumann). The inner product is then recovered by polarization, ⟨x,y⟩=14(∥x+y∥2−∥x−y∥2)\langle x,y\rangle = \tfrac14(\|x+y\|^2 - \|x-y\|^2). The ℓ1\ell^1 and ℓ∞\ell^\infty norms fail the law (Practice Code 5), so those Banach spaces have no notion of angle. Hilbert spaces are special.

Riesz representation

Every continuous linear functional ϕ\phi on a Hilbert space is an inner product with a unique vector: ϕ(f)=⟨f,gϕ⟩\phi(f) = \langle f,g_\phi\rangle, with ∥ϕ∥=∥gϕ∥\|\phi\| = \|g_\phi\|. This is why gradients exist in infinite dimensions. The derivative of a functional is a linear map, and Riesz turns it into a vector, the gradient (A3.5-10). It’s also why every reproducing-kernel Hilbert space has a kernel: point evaluation f↦f(x)f\mapsto f(x) is represented by k(x,⋅)k(x,\cdot).

Exercise 3.1: Show the parallelogram law fails for ℓ¹ with e₁, e₂

∥e1+e2∥12+∥e1−e2∥12=4+4=8\|e_1 + e_2\|_1^2 + \|e_1 - e_2\|_1^2 = 4 + 4 = 8, while 2∥e1∥2+2∥e2∥2=42\|e_1\|^2 + 2\|e_2\|^2 = 4.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Cauchy–Schwarz is proved by…
  2. 2. A norm comes from an inner product iff it satisfies…
  3. 3. The Riesz representation theorem turns a continuous linear functional into…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

POD: the optimal basis for your data

Given snapshots u(t1),…,u(tm)u(t_1),\dots,u(t_m) of a simulation or experiment, which rr-dimensional orthonormal basis minimizes the total projection error ∑j∥u(tj)−Pru(tj)∥2\sum_j\|u(t_j) - P_ru(t_j)\|^2? The answer is the top rr left singular vectors of the snapshot matrix. This is proper orthogonal decomposition (POD), mathematically PCA. The error is exactly the sum of the discarded squared singular values (Eckart–Young). Projecting the governing equations onto these modes gives a reduced-order model that’s thousands of times cheaper. These are used for:

  • aeroelastic flutter analysis and active flow control (Holmes, Lumley and Berkooz, 2012);
  • spacecraft thermal models;
  • digital twins (Benner, Gugercin and Willcox, 2015).
🐍 Exercise 2 (research): POD reduced basis for a heat simulation
Simulate a heated rod and collect 40 snapshots of a 200-point state. Compute POD modes by SVD and verify that error² equals the discarded σ². Show that 3 POD modes beat 3 Fourier sines and a random basis.

Hilbert spaces across AI and engineering

  • Kernel methods and Gaussian processes. A positive-definite kernel defines a reproducing-kernel Hilbert space (RKHS). Kernel ridge regression’s solution lies in the span of k(xi,⋅)k(x_i,\cdot) (the representer theorem; Schölkopf, Herbrich and Smola, 2001), which is an orthogonal-projection argument. GP posterior means are the same object (Rasmussen and Williams, 2006; I2).
  • Random variables as vectors. In L2(Ω)L^2(\Omega), the conditional expectation E[X∣Y]\mathbb E[X\mid Y] is the orthogonal projection of XX onto functions of YY. The Kalman filter is recursive orthogonal projection: the innovation is orthogonal to past data (Kalman, 1960). That’s why it’s the optimal linear estimator, as used in Apollo’s navigation.
  • Quantum mechanics lives in Hilbert space: states are unit vectors, observables are self-adjoint operators (A3.5-6), and probabilities are squared inner products.
  • Spectral methods and polynomial chaos. Orthogonal-polynomial expansions solve PDEs with exponential accuracy and propagate uncertainty through spacecraft models (Xiu and Karniadakis, 2002).
  • Neural tangent kernel. Wide networks behave like kernel regression in a particular RKHS (Jacot, Gabriel and Hongler, 2018).

References

  1. E. Kreyszig (1978). Introductory Functional Analysis with Applications. Wiley.
  2. D. Luenberger (1969). Optimization by Vector Space Methods. Wiley. (Projection theorem, applications.)
  3. P. Holmes, J. Lumley, G. Berkooz, C. Rowley (2012). Turbulence, Coherent Structures, Dynamical Systems and Symmetry, 2nd ed. Cambridge.
  4. P. Benner, S. Gugercin, K. Willcox (2015). “A survey of projection-based model reduction methods for parametric dynamical systems.” SIAM Review, 57(4).
  5. B. Schölkopf, R. Herbrich, A. Smola (2001). “A generalized representer theorem.” COLT.
  6. C. Rasmussen, C. Williams (2006). Gaussian Processes for Machine Learning. MIT Press.
  7. R. E. Kalman (1960). “A new approach to linear filtering and prediction problems.” Journal of Basic Engineering, 82.
  8. D. Xiu, G. E. Karniadakis (2002). “The Wiener–Askey polynomial chaos for stochastic differential equations.” SIAM Journal on Scientific Computing, 24(2).
  9. A. Jacot, F. Gabriel, C. Hongler (2018). “Neural tangent kernel: convergence and generalization in neural networks.” NeurIPS.