Linear Algebra, Live
Strang §4.4 · Orthonormal bases

Orthonormal vectors and orthogonal matrices Q

Slide 5 saw the equations split apart when the two columns were perpendicular. Now we make that happen on purpose. Think of a city laid out as a perfect square grid of streets, one block apart. To say where you are, you just count blocks east and blocks north, with no calculation. A city with slanted streets makes you work it out. Vectors that are all perpendicular to each other and each have length 1 are called orthonormal: they are the perfect grid. Put them as the columns of a matrix Q and QᵀQ = I. Then coordinates are plain dot products, a square Q is inverted just by transposing it, and least squares needs no inverse at all.

Lesson 5 · slide 6Orthonormal bases
QᵀQ = I    square Q: Q⁻¹ = Qᵀ    ‖Qx‖ = ‖x‖
Key ideas
  1. q₁, ..., qₙ are orthonormal when qᵢᵀqⱼ = 0 for i ≠ j and qᵢᵀqᵢ = 1.
  2. With those vectors as columns, QᵀQ = I.
  3. A square Q with QᵀQ = I is an orthogonal matrix. Its inverse is its transpose.
  4. Q keeps lengths and angles (lesson 6 shows that in the plane these Q are turns and mirror flips).
  5. Coordinates in an orthonormal basis are dot products: x = (q₁ᵀx)q₁ + ... + (qₙᵀx)qₙ.

A perfect grid

The word orthonormal packs two conditions together: ortho, perpendicular to each other, and normal, each of length 1. The usual axes 10 and 01 are orthonormal, and so are other perpendicular pairs of length 1, like q₁ = 0.60.8 and q₂ = −0.80.6:

‖q₁‖² = 0.36 + 0.64 = 1,   ‖q₂‖² = 0.64 + 0.36 = 1,   q₁ · q₂ = −0.48 + 0.48 = 0

Any perpendicular pair can be made orthonormal: divide each vector by its length. 34 and −43 are perpendicular with length 5; dividing by 5 gives exactly q₁ and q₂.

QᵀQ = I

Put q₁ and q₂ in the columns of Q. Entry (i, j) of QᵀQ is row i of Qᵀ times column j of Q, which is qᵢ · qⱼ. Perpendicular columns give zeros off the diagonal. Length 1 gives ones on it:

Q = 0.6−0.80.80.6,   QᵀQ = q₁·q₁q₁·q₂q₂·q₁q₂·q₂ = 1001
Qᵀ times Q, one entry at a time. Each entry is a dot product of two columns of Q: 1 for a column with itself, 0 for two different columns.

A square Q with QᵀQ = I is called an orthogonal matrix. For it, QᵀQ = I says Q⁻¹ = Qᵀ: inverting is just transposing. (The name is odd: the columns are orthonormal, not just orthogonal.)

Lengths stay the same

‖Qx‖² = (Qx)ᵀ(Qx) = xᵀQᵀQx = xᵀx = ‖x‖². Multiplying by Q never stretches a vector:

x = 55:   Qx = 0.6·5 − 0.8·50.8·5 + 0.6·5 = −17
‖Qx‖² = 1 + 49 = 50 = 25 + 25 = ‖x‖² ✓

Angles stay the same too, since dot products do: (Qx) · (Qy) = xᵀQᵀQy = xᵀy, worked out in the exercises below. Lesson 6 shows what such a Q looks like in the plane: a turn or a mirror flip.

Coordinates are dot products

To write x = c₁q₁ + c₂q₂, dot both sides with q₁. The other term drops out, because q₁ · q₂ = 0, and q₁ · q₁ = 1. So c₁ = q₁ᵀx. No elimination needed.

x = 55:   c₁ = q₁ᵀx = 3 + 4 = 7,   c₂ = q₂ᵀx = −4 + 3 = −1
7·0.60.8 − 1·−0.80.6 = 4.2 + 0.85.6 − 0.6 = 55 ✓
The line is the q₁ direction (drawn with a = 34 = 5q₁). x = 55 casts the shadow p = 4.25.6, of length 7 = q₁ · x. The leftover e = 0.8−0.6 has length 1: one step along q₂, backwards.

Projections get simple

With orthonormal columns, AᵀA becomes QᵀQ = I. The normal equations turn into x̂ = Qᵀb, and the projection matrix becomes P = QQᵀ. With one column q₁ = 0.60.8:

P = q₁q₁ᵀ = 0.360.480.480.64,   P55 = 1.8 + 2.42.4 + 3.2 = 4.25.6 ✓

That is the shadow in the picture above. Careful: if Q has fewer columns than rows, QQᵀ is not I. It is the projection onto the column space of Q.

Keep reading with the full course

Finish lesson 5 and you will be able to: fit the best line to noisy sensor data.

Still locked here:

  • The rest of this explanation
  • 4 more examples with step-by-step solutions
  • Five extra members-only problems with worked solutions

$20 once, lifetime access. Lessons 1 to 3 stay free.

Examples

Example 1 · The matrix Q(θ) is orthogonal

Q(θ) = cos θ−sin θsin θcos θ. Q(θ) turns the plane by the angle θ; lesson 6 builds it. Is it orthogonal?

Show solutionHide solution
q₁ · q₁ = cos²θ + sin²θ = 1,   q₂ · q₂ = 1
q₁ · q₂ = −cos θ sin θ + sin θ cos θ = 0
So QᵀQ = I, and Q⁻¹ = Qᵀ = cos θsin θ−sin θcos θ
cos(−θ) = cos θ and sin(−θ) = −sin θ, so this is Q(−θ)

So its inverse turns back by θ.

Exercise The columns (3, 4) and (−4, 3) are perpendicular. Scale them to length 1 so that Q is orthogonal. Edit the code and press Run.
slide_6.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Questions and comments

Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.

The full course

From Ax = b to PCA, by running it

Lessons 1 to 3 are free. Finish all eight and you will be able to:

You get: all 8 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · answers to your questions · every future update.

$20 once · lifetime access
Continue to checkout →

Already a member? Log in to the course