4.5 Inner products and orthogonality

The vector-space axioms — addition and scalar multiplication — let you add and stretch arrows but say nothing about length or angle. Pythagoras’ theorem, the cosine rule, the very idea of “perpendicular” — none of these are part of the bare vector-space structure. To recover them, you need one extra piece of equipment: an inner product.

This lesson defines the inner product, develops the geometric notions it makes possible (length, angle, projection, orthogonality), and walks through the Gram–Schmidt procedure that turns any linearly-independent set of vectors into an orthonormal basis. The same machinery, lifted to function spaces, is what makes Fourier expansion and modal projection work — it is the algebraic structure underlying Foundations 6.5.

The dot product

In Rn\mathbb{R}^n the inner product is the familiar dot product:

uv  =  u1v1+u2v2++unvn  =  k=1nukvk.\mathbf{u} \cdot \mathbf{v} \;=\; u_1 v_1 + u_2 v_2 + \cdots + u_n v_n \;=\; \sum_{k=1}^n u_k v_k.

This is just a single number — the inner product of two vectors is a scalar, not another vector. Three properties pin it down and generalise to other inner-product spaces:

Any operation on a vector space with these three properties is called an inner product, often written u,v\langle \mathbf{u}, \mathbf{v} \rangle in more abstract settings. The integral 0Lf(x)g(x)dx\int_0^L f(x) g(x)\, dx, for instance, satisfies all three properties (with functions f,gf, g as the “vectors”), and so it is an inner product on the space of integrable functions on [0,L][0, L]. That fact is what makes the Fourier-projection formula in Foundations 6.5 work mechanically the same way as the projection of a 2-D vector onto an axis.

Length and angle

The inner product gives you a norm (length):

v  =  vv.\|\mathbf{v}\| \;=\; \sqrt{\mathbf{v} \cdot \mathbf{v}}.

In R2\mathbb{R}^2 this is just Pythagoras: (x,y)=x2+y2\|(x, y)\| = \sqrt{x^2 + y^2}. The norm satisfies the triangle inequality u+vu+v\|\mathbf{u} + \mathbf{v}\| \leq \|\mathbf{u}\| + \|\mathbf{v}\| — a consequence of the Cauchy–Schwarz inequality uvuv|\mathbf{u} \cdot \mathbf{v}| \leq \|\mathbf{u}\|\, \|\mathbf{v}\|, which is one of the most-used inequalities in mathematics.

The inner product also encodes the angle between two vectors:

cosθ  =  uvuv.\cos \theta \;=\; \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\|\, \|\mathbf{v}\|}.

Two vectors are orthogonal (perpendicular) if their inner product is zero. In Rn\mathbb{R}^n orthogonality is the algebraic condition kukvk=0\sum_k u_k v_k = 0; in function-space settings it becomes f(x)g(x)dx=0\int f(x) g(x)\, dx = 0. The integral version is what makes the Fourier sine series of Foundations 6.3 work:

0Lsin(mπx/L)sin(nπx/L)dx  =  L2δmn,\int_0^L \sin(m \pi x / L)\, \sin(n \pi x / L)\, dx \;=\; \tfrac{L}{2}\, \delta_{mn},

— different-mode sines are orthogonal as elements of the function space L2[0,L]L^2[0, L].

Projection

If u\mathbf{u} is a unit vector (i.e. u=1\|\mathbf{u}\| = 1), the projection of any vector v\mathbf{v} onto u\mathbf{u} is

proju(v)  =  (vu)u.\text{proj}_\mathbf{u}(\mathbf{v}) \;=\; (\mathbf{v} \cdot \mathbf{u})\, \mathbf{u}.

The scalar vu\mathbf{v} \cdot \mathbf{u} is the length of the projection — how much of v\mathbf{v} points along u\mathbf{u}. The vector (vu)u(\mathbf{v} \cdot \mathbf{u})\, \mathbf{u} is the projection itself, a vector parallel to u\mathbf{u}.

The residual w=vproju(v)\mathbf{w} = \mathbf{v} - \text{proj}_\mathbf{u}(\mathbf{v}) is the component of v\mathbf{v} perpendicular to u\mathbf{u}. Two checks: uw=uv(vu)1=0\mathbf{u} \cdot \mathbf{w} = \mathbf{u} \cdot \mathbf{v} - (\mathbf{v} \cdot \mathbf{u}) \cdot 1 = 0 (so wu\mathbf{w} \perp \mathbf{u} ✓), and v=proju(v)+w\mathbf{v} = \text{proj}_\mathbf{u}(\mathbf{v}) + \mathbf{w} (so the decomposition is exact ✓).

Projection is the bread-and-butter geometric operation of linear algebra. If {e1,,en}\{\mathbf{e}_1, \ldots, \mathbf{e}_n\} is an orthonormal basis, then any vector decomposes as

v  =  k=1n(vek)ek.\mathbf{v} \;=\; \sum_{k=1}^n (\mathbf{v} \cdot \mathbf{e}_k)\, \mathbf{e}_k.

That formula is the Fourier expansion of v\mathbf{v} in the basis {ek}\{\mathbf{e}_k\}. When the basis is the modes of a PDE rather than Rn\mathbb{R}^n basis vectors, the same formula extracts modal coefficients from initial data; that is the Fourier-projection step in Foundations 6.5.

Gram–Schmidt orthogonalisation

Given a set of linearly-independent vectors {a1,a2,,ak}\{\mathbf{a}_1, \mathbf{a}_2, \ldots, \mathbf{a}_k\}, we want to produce an orthonormal set {e1,e2,,ek}\{\mathbf{e}_1, \mathbf{e}_2, \ldots, \mathbf{e}_k\} spanning the same space — orthogonal to each other and each of unit length. The Gram–Schmidt procedure does this iteratively, by subtracting projections.

The recipe for two input vectors a\mathbf{a} and b\mathbf{b}:

  1. e1=a/a\mathbf{e}_1 = \mathbf{a} / \|\mathbf{a}\|. (Normalise the first vector.)
  2. w=b(be1)e1\mathbf{w} = \mathbf{b} - (\mathbf{b} \cdot \mathbf{e}_1)\, \mathbf{e}_1. (Subtract from b\mathbf{b} its component along e1\mathbf{e}_1.)
  3. e2=w/w\mathbf{e}_2 = \mathbf{w} / \|\mathbf{w}\|. (Normalise.)

For three or more inputs the procedure continues: subtract from each subsequent vector its components along all previously orthonormalised vectors, then normalise.

abstep1 of 4a(1.60, 0.50), ‖a‖ = 1.676b(0.40, 1.40)
Initial input: two linearly-independent vectors a and b.

Drag the blue and red circles to set the input vectors a and b. Step through the procedure: normalise a, subtract its component from b to get a perpendicular remainder w, then normalise w. The small right-angle marker confirms that the green w is perpendicular to e₁. The output {e₁, e₂} is an orthonormal basis for the same plane that {a, b} spanned.

Drag the blue and red input vectors a\mathbf{a} and b\mathbf{b}. Step through the three operations. The little right-angle marker in step 2 confirms that the green residual w\mathbf{w} is perpendicular to e1\mathbf{e}_1; in step 3 it gets normalised to e2\mathbf{e}_2. The output basis {e1,e2}\{\mathbf{e}_1, \mathbf{e}_2\} spans the same plane as the input but with orthogonal axes.

Worked example

Worked example: Gram–Schmidt on three vectors in R³

The problem. Find an orthonormal basis for the span of

a1=(1,1,0),a2=(1,0,1),a3=(0,1,1).\mathbf{a}_1 = (1, 1, 0), \quad \mathbf{a}_2 = (1, 0, 1), \quad \mathbf{a}_3 = (0, 1, 1).

These three vectors are linearly independent (verify by computing det=20\det = 2 \neq 0) and so span all of R3\mathbb{R}^3; the output will be an orthonormal basis of R3\mathbb{R}^3.

Step 1 — Normalise a1\mathbf{a}_1.

a1=12+12+02=2,e1=12(1,1,0).\|\mathbf{a}_1\| = \sqrt{1^2 + 1^2 + 0^2} = \sqrt{2}, \qquad \mathbf{e}_1 = \frac{1}{\sqrt{2}} (1, 1, 0).

Step 2 — Subtract the e1\mathbf{e}_1-component from a2\mathbf{a}_2 to get w2\mathbf{w}_2.

a2e1=12(11+01+10)=12.\mathbf{a}_2 \cdot \mathbf{e}_1 = \frac{1}{\sqrt{2}} (1 \cdot 1 + 0 \cdot 1 + 1 \cdot 0) = \frac{1}{\sqrt{2}}.w2=a2(a2e1)e1=(1,0,1)1212(1,1,0)=(1,0,1)12(1,1,0)=(12,12,1).\mathbf{w}_2 = \mathbf{a}_2 - (\mathbf{a}_2 \cdot \mathbf{e}_1)\, \mathbf{e}_1 = (1, 0, 1) - \frac{1}{\sqrt{2}} \cdot \frac{1}{\sqrt{2}} (1, 1, 0) = (1, 0, 1) - \tfrac12 (1, 1, 0) = (\tfrac12, -\tfrac12, 1).

Check that w2\mathbf{w}_2 is orthogonal to e1\mathbf{e}_1: w2e1=12(1212+0)=0\mathbf{w}_2 \cdot \mathbf{e}_1 = \tfrac{1}{\sqrt{2}} (\tfrac12 - \tfrac12 + 0) = 0. ✓

Step 3 — Normalise w2\mathbf{w}_2.

w2=(12)2+(12)2+12=32=62.\|\mathbf{w}_2\| = \sqrt{(\tfrac12)^2 + (\tfrac12)^2 + 1^2} = \sqrt{\tfrac{3}{2}} = \frac{\sqrt{6}}{2}.e2=26(12,12,1)=16(1,1,2).\mathbf{e}_2 = \frac{2}{\sqrt{6}} (\tfrac12, -\tfrac12, 1) = \frac{1}{\sqrt{6}} (1, -1, 2).

Step 4 — Subtract e1\mathbf{e}_1- and e2\mathbf{e}_2-components from a3\mathbf{a}_3.

a3e1=12(0+1+0)=12.\mathbf{a}_3 \cdot \mathbf{e}_1 = \frac{1}{\sqrt{2}} (0 + 1 + 0) = \frac{1}{\sqrt{2}}.a3e2=16(01+1(1)+12)=16.\mathbf{a}_3 \cdot \mathbf{e}_2 = \frac{1}{\sqrt{6}} (0 \cdot 1 + 1 \cdot (-1) + 1 \cdot 2) = \frac{1}{\sqrt{6}}.w3=a3(a3e1)e1(a3e2)e2=(0,1,1)1212(1,1,0)1616(1,1,2)=(0,1,1)(12,12,0)(16,16,13)=(23,23,23).\begin{aligned} \mathbf{w}_3 &= \mathbf{a}_3 - (\mathbf{a}_3 \cdot \mathbf{e}_1)\, \mathbf{e}_1 - (\mathbf{a}_3 \cdot \mathbf{e}_2)\, \mathbf{e}_2 \\ &= (0, 1, 1) - \frac{1}{\sqrt{2}} \cdot \frac{1}{\sqrt{2}} (1, 1, 0) - \frac{1}{\sqrt{6}} \cdot \frac{1}{\sqrt{6}} (1, -1, 2) \\ &= (0, 1, 1) - (\tfrac12, \tfrac12, 0) - (\tfrac16, -\tfrac16, \tfrac13) \\ &= (-\tfrac23, \tfrac23, \tfrac23). \end{aligned}

Check orthogonality: w3e1=12(23+23+0)=0\mathbf{w}_3 \cdot \mathbf{e}_1 = \tfrac{1}{\sqrt{2}} (-\tfrac23 + \tfrac23 + 0) = 0 ✓, and w3e2=16(2323+43)=0\mathbf{w}_3 \cdot \mathbf{e}_2 = \tfrac{1}{\sqrt{6}} (-\tfrac23 - \tfrac23 + \tfrac43) = 0 ✓.

Step 5 — Normalise w3\mathbf{w}_3.

w3=(23)23=23.\|\mathbf{w}_3\| = \sqrt{(\tfrac23)^2 \cdot 3} = \tfrac{2}{\sqrt{3}}.e3=32(23,23,23)=13(1,1,1).\mathbf{e}_3 = \frac{\sqrt{3}}{2} \cdot (-\tfrac23, \tfrac23, \tfrac23) = \frac{1}{\sqrt{3}} (-1, 1, 1).

Step 6 — Final answer. The orthonormal basis is

  e1=12(1,1,0),e2=16(1,1,2),e3=13(1,1,1).  \boxed{\;\mathbf{e}_1 = \tfrac{1}{\sqrt{2}}(1, 1, 0), \quad \mathbf{e}_2 = \tfrac{1}{\sqrt{6}}(1, -1, 2), \quad \mathbf{e}_3 = \tfrac{1}{\sqrt{3}}(-1, 1, 1).\;}

Each has length 1; each pair is orthogonal; together they span R3\mathbb{R}^3.

Inner products on function spaces

The bridge to PDEs: the same recipe — projection, orthogonality, Gram–Schmidt — works on infinite-dimensional spaces of functions, provided the inner product is the integral

f,g  =  abf(x)g(x)dx\langle f, g \rangle \;=\; \int_a^b f(x)\, g(x)\, dx

(possibly weighted; the Sturm–Liouville theorem describes which weight functions are appropriate for which differential operators). The functions sin(nπx/L)\sin(n \pi x / L) on [0,L][0, L] are pairwise orthogonal under this inner product, with sin(nπx/L)2=L/2\|sin(n \pi x / L)\|^2 = L/2. Therefore the Fourier sine series

f(x)=ncnsin(nπx/L),cn=2L0Lf(x)sin(nπx/L)dx,f(x) = \sum_n c_n \sin(n \pi x / L), \qquad c_n = \frac{2}{L} \int_0^L f(x)\, \sin(n \pi x / L)\, dx,

is exactly the orthonormal-basis expansion v=k(vek)ek\mathbf{v} = \sum_k (\mathbf{v} \cdot \mathbf{e}_k)\, \mathbf{e}_k from the finite-dimensional case, lifted to the function space. The arithmetic is identical; the only difference is that “sum” becomes “integral” in the inner product, and "sin(nπx/L)\sin(n\pi x/L)" plays the role of en\mathbf{e}_n. This is the deep reason separation of variables and Fourier expansion work: the natural eigenfunctions of self-adjoint differential operators are orthogonal under an appropriate inner product, and the spectral theorem in 4.6 guarantees their completeness as a basis.

What we use this for

Inner products are everywhere across the bookshelf:

The next lesson, 4.6, ties together everything in the chapter: the eigenvalues of 4.4, the orthogonality of this lesson, and the spectral theorem that guarantees a self-adjoint operator’s eigenvectors form a complete orthonormal basis. That theorem is what makes mode expansions for PDEs not just convenient but mathematically complete.