Math Core

Lesson 6.2 · Orthogonality and Least Squares

Orthogonal sets

Finding the coordinates of a vector in a basis usually means row reducing an augmented matrix. But if the basis vectors are mutually perpendicular, like the standard basis, each coordinate comes from a single inner product. That is why orthogonal bases are the preferred bases throughout applied math, from signal processing to statistics.

Orthogonal sets

Definition

Orthogonal set

A set of vectors {u1,…,up}\{\mathbf{u}_1, \ldots, \mathbf{u}_p\} in Rn\mathbb{R}^n is an orthogonal set if every pair of distinct vectors in it is orthogonal: ui⋅uj=0\mathbf{u}_i \cdot \mathbf{u}_j = 0 whenever i≠ji \neq j.

To check a set of pp vectors, you check all (p2)\binom{p}{2} pairs. For three vectors that is three inner products.

Worked example: Checking an orthogonal set

Is {u1,u2,u3}\{\mathbf{u}_1, \mathbf{u}_2, \mathbf{u}_3\} orthogonal, where u1=(1,1,1)\mathbf{u}_1 = (1, 1, 1), u2=(1,−2,1)\mathbf{u}_2 = (1, -2, 1) and u3=(1,0,−1)\mathbf{u}_3 = (1, 0, -1)?

u1⋅u2=1−2+1=0,u1⋅u3=1+0−1=0,u2⋅u3=1+0−1=0.\mathbf{u}_1 \cdot \mathbf{u}_2 = 1 - 2 + 1 = 0, \quad \mathbf{u}_1 \cdot \mathbf{u}_3 = 1 + 0 - 1 = 0, \quad \mathbf{u}_2 \cdot \mathbf{u}_3 = 1 + 0 - 1 = 0.

All three pairs are orthogonal, so yes.

Orthogonal sets are independent

Orthogonality implies independence

If S={u1,…,up}S = \{\mathbf{u}_1, \ldots, \mathbf{u}_p\} is an orthogonal set of nonzero vectors, then SS is linearly independent, so it is a basis for the subspace it spans.

Here is why. Suppose c1u1+⋯+cpup=0c_1\mathbf{u}_1 + \cdots + c_p\mathbf{u}_p = \mathbf{0}. Take the inner product of both sides with u1\mathbf{u}_1. Every term cj uj⋅u1c_j\,\mathbf{u}_j \cdot \mathbf{u}_1 with j≠1j \neq 1 vanishes, leaving

c1(u1⋅u1)=0.c_1(\mathbf{u}_1 \cdot \mathbf{u}_1) = 0.

Since u1≠0\mathbf{u}_1 \neq \mathbf{0}, u1⋅u1>0\mathbf{u}_1 \cdot \mathbf{u}_1 > 0, so c1=0c_1 = 0. The same argument with u2,…,up\mathbf{u}_2, \ldots, \mathbf{u}_p shows every weight is 00.

So the set in the example above is a basis for R3\mathbb{R}^3: three independent vectors in a 3-dimensional space. An orthogonal basis for a subspace WW is a basis of WW that is also an orthogonal set.

Coordinates in an orthogonal basis

The same trick of "dot with uj\mathbf{u}_j" also computes coordinates. If y=c1u1+⋯+cpup\mathbf{y} = c_1\mathbf{u}_1 + \cdots + c_p\mathbf{u}_p, dotting with uj\mathbf{u}_j kills every term but one: y⋅uj=cj(uj⋅uj)\mathbf{y} \cdot \mathbf{u}_j = c_j(\mathbf{u}_j \cdot \mathbf{u}_j).

Weights in an orthogonal basis

If {u1,…,up}\{\mathbf{u}_1, \ldots, \mathbf{u}_p\} is an orthogonal basis for WW and y\mathbf{y} is in WW, then

y=c1u1+⋯+cpup,where cj=y⋅ujuj⋅uj.\mathbf{y} = c_1\mathbf{u}_1 + \cdots + c_p\mathbf{u}_p, \qquad \text{where } c_j = \frac{\mathbf{y} \cdot \mathbf{u}_j}{\mathbf{u}_j \cdot \mathbf{u}_j}.

No row reduction, and each weight is computed independently of the others.

Worked example: Coordinates without row reduction

Write y=(5,−1,2)\mathbf{y} = (5, -1, 2) as a combination of the orthogonal basis u1=(1,1,1)\mathbf{u}_1 = (1, 1, 1), u2=(1,−2,1)\mathbf{u}_2 = (1, -2, 1), u3=(1,0,−1)\mathbf{u}_3 = (1, 0, -1).

c1=y⋅u1u1⋅u1=5−1+23=63=2,c2=y⋅u2u2⋅u2=5+2+26=96=32,c3=y⋅u3u3⋅u3=5+0−22=32.\begin{aligned} c_1 &= \frac{\mathbf{y} \cdot \mathbf{u}_1}{\mathbf{u}_1 \cdot \mathbf{u}_1} = \frac{5 - 1 + 2}{3} = \frac{6}{3} = 2, \\ c_2 &= \frac{\mathbf{y} \cdot \mathbf{u}_2}{\mathbf{u}_2 \cdot \mathbf{u}_2} = \frac{5 + 2 + 2}{6} = \frac{9}{6} = \frac{3}{2}, \\ c_3 &= \frac{\mathbf{y} \cdot \mathbf{u}_3}{\mathbf{u}_3 \cdot \mathbf{u}_3} = \frac{5 + 0 - 2}{2} = \frac{3}{2}. \end{aligned}

So y=2u1+32u2+32u3\mathbf{y} = 2\mathbf{u}_1 + \tfrac{3}{2}\mathbf{u}_2 + \tfrac{3}{2}\mathbf{u}_3. Check: 2(1,1,1)+32(1,−2,1)+32(1,0,−1)=(2+1.5+1.5, 2−3+0, 2+1.5−1.5)=(5,−1,2)2(1, 1, 1) + \tfrac{3}{2}(1, -2, 1) + \tfrac{3}{2}(1, 0, -1) = (2 + 1.5 + 1.5,\ 2 - 3 + 0,\ 2 + 1.5 - 1.5) = (5, -1, 2).

Common mistake

The denominator is uj⋅uj=∥uj∥2\mathbf{u}_j \cdot \mathbf{u}_j = \|\mathbf{u}_j\|^2, not ∥uj∥\|\mathbf{u}_j\|. Forgetting the square is the most common slip. And the formula only works when the basis is orthogonal; for any other basis you must solve a system.

Orthonormal sets

Definition

Orthonormal set

An orthogonal set of unit vectors is orthonormal. An orthonormal basis of WW is a basis that is an orthonormal set.

With an orthonormal basis every denominator is 11, so the weights are simply cj=y⋅ujc_j = \mathbf{y} \cdot \mathbf{u}_j. The standard basis {e1,…,en}\{\mathbf{e}_1, \ldots, \mathbf{e}_n\} is the most familiar example. To turn an orthogonal set of nonzero vectors into an orthonormal one, normalize each vector; scaling doesn't affect orthogonality.

Normalizing the basis from the examples gives the orthonormal basis

13(1,1,1),16(1,−2,1),12(1,0,−1).\tfrac{1}{\sqrt{3}}(1, 1, 1), \quad \tfrac{1}{\sqrt{6}}(1, -2, 1), \quad \tfrac{1}{\sqrt{2}}(1, 0, -1).

Matrices with orthonormal columns

Let U=[u1 ⋯ up]U = [\mathbf{u}_1 \ \cdots \ \mathbf{u}_p]. The (i,j)(i, j) entry of UTUU^TU is row ii of UTU^T times column jj of UU, which is ui⋅uj\mathbf{u}_i \cdot \mathbf{u}_j. So the columns are orthonormal exactly when those entries are 11 on the diagonal and 00 elsewhere.

Orthonormal columns

An m×nm \times n matrix UU has orthonormal columns if and only if UTU=IU^TU = I. Such a matrix preserves lengths and inner products: for all x,y\mathbf{x}, \mathbf{y} in Rn\mathbb{R}^n,

∥Ux∥=∥x∥and(Ux)⋅(Uy)=x⋅y.\|U\mathbf{x}\| = \|\mathbf{x}\| \quad \text{and} \quad (U\mathbf{x}) \cdot (U\mathbf{y}) = \mathbf{x} \cdot \mathbf{y}.

The proof is one line: (Ux)⋅(Uy)=(Ux)T(Uy)=xTUTUy=xTy(U\mathbf{x}) \cdot (U\mathbf{y}) = (U\mathbf{x})^T(U\mathbf{y}) = \mathbf{x}^TU^TU\mathbf{y} = \mathbf{x}^T\mathbf{y}. Taking y=x\mathbf{y} = \mathbf{x} gives the length statement. Since angles are computed from inner products and lengths, UU preserves angles too, and in particular it sends orthogonal vectors to orthogonal vectors.

A square matrix with orthonormal columns is called an orthogonal matrix. For such a matrix, UTU=IU^TU = I means U−1=UTU^{-1} = U^T: the inverse costs nothing to compute. Rotations and reflections of Rn\mathbb{R}^n are orthogonal matrices. (The name is traditional; "orthonormal matrix" would be more accurate.)

Worked example: An orthogonal matrix

Let Q=15[3−443]Q = \dfrac{1}{5}\begin{bmatrix} 3 & -4 \\ 4 & 3 \end{bmatrix}. Show that QQ is orthogonal, find Q−1Q^{-1}, and check that ∥Qx∥=∥x∥\|Q\mathbf{x}\| = \|\mathbf{x}\| for x=(2,1)\mathbf{x} = (2, 1).

The columns (35,45)\left(\tfrac{3}{5}, \tfrac{4}{5}\right) and (−45,35)\left(-\tfrac{4}{5}, \tfrac{3}{5}\right) each have length 9+1625=1\sqrt{\tfrac{9 + 16}{25}} = 1, and their inner product is −1225+1225=0-\tfrac{12}{25} + \tfrac{12}{25} = 0. So QQ is orthogonal and

Q−1=QT=15[34−43].Q^{-1} = Q^T = \frac{1}{5}\begin{bmatrix} 3 & 4 \\ -4 & 3 \end{bmatrix}.

Next, Qx=15(6−4, 8+3)=(25,115)Q\mathbf{x} = \tfrac{1}{5}(6 - 4,\ 8 + 3) = \left(\tfrac{2}{5}, \tfrac{11}{5}\right), with length 4+12125=5\sqrt{\tfrac{4 + 121}{25}} = \sqrt{5}. And ∥x∥=4+1=5\|\mathbf{x}\| = \sqrt{4 + 1} = \sqrt{5}. They match: QQ is a rotation.

Tip

A non-square matrix UU with orthonormal columns still has UTU=IU^TU = I, but UUT≠IUU^T \neq I. You will meet UUTUU^T in the next lesson: it is the matrix of an orthogonal projection.

Practice

Practice 1

Which set is orthogonal?

Practice 2

Find kk so that {(1,k,2),(3,−1,k)}\{(1, k, 2), (3, -1, k)\} is an orthogonal set.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

The vectors u1=(2,1)\mathbf{u}_1 = (2, 1) and u2=(−1,2)\mathbf{u}_2 = (-1, 2) form an orthogonal basis for R2\mathbb{R}^2. Find the weights (c1,c2)(c_1, c_2) with (4,7)=c1u1+c2u2(4, 7) = c_1\mathbf{u}_1 + c_2\mathbf{u}_2.

Enter a point like (2, -3)

Practice 4

The vectors u1=(1,2,2)\mathbf{u}_1 = (1, 2, 2), u2=(2,1,−2)\mathbf{u}_2 = (2, 1, -2) and u3=(2,−2,1)\mathbf{u}_3 = (2, -2, 1) form an orthogonal basis for R3\mathbb{R}^3. Find the weights (c1,c2,c3)(c_1, c_2, c_3) that express y=(2,1,7)\mathbf{y} = (2, 1, 7) in this basis.

Enter a point like (2, -3)

Practice 5

The vectors (1,1,1)(1, 1, 1) and (1,−1,0)(1, -1, 0) are orthogonal. Find aa and bb so that (a,b,1)(a, b, 1) is orthogonal to both, and enter the vector (a,b,1)(a, b, 1).

Enter a point like (2, -3)

Practice 6

UU is a 5×35 \times 3 matrix with orthonormal columns and x=(1,2,−2)\mathbf{x} = (1, 2, -2). Find ∥Ux∥\|U\mathbf{x}\|.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

Q=[3/5−4/54/53/5]Q = \begin{bmatrix} 3/5 & -4/5 \\ 4/5 & 3/5 \end{bmatrix} is an orthogonal matrix. Find the (1,2)(1, 2) entry of Q−1Q^{-1}.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

Which statement is always true?