linearly

Lecture 13

Orthonormal Bases, Gram-Schmidt & QR

Perpendicular unit columns make every formula in this course cheaper. How to build them from any basis, and the factorization that records the work.

71 slides / MIT 18.06, Lecture 17 / Strang §4.4

Slide 1 of 71
1 / 71

The idea in one sentence

When the columns of a matrix are perpendicular and have length 1, the expensive part of every formula in this course disappears: the inverse becomes the transpose.

The wish

Lecture 12 ended at a formula that works and costs too much. To fit a model to data that no model fits exactly, you solve

ATAx^=ATb.A\T A \,\hat{x} = A\T b .

Everything about that line is fine except one thing. The matrix ATAA\T A has to be built and then undone. Its entry in row ii, column jj is the dot product of column ii of AA with column jj. So ATAA\T A is a table of how much each column of AA overlaps every other column. A good name for it is the coupling matrix: the columns are tangled together, and solving means untangling them.

Now make a wish. What if ATAA\T A were the identity? Then x^=ATb\hat{x} = A\T b, and there is nothing left to solve. One matrix multiplication and you are done.

The wish is really a request about the columns of AA. Written out, ATA=IA\T A = I says two things at once: every column has length 1, and every pair of different columns has dot product 0. Perpendicular unit vectors. Nothing more.

So the rest of this lecture builds columns like that, and then spends them.

Q, and the one identity that matters

Vectors q1,,qnq_1, \ldots, q_n are orthonormal when

qiTqj={0ij1i=jq_i\T q_j = \begin{cases} 0 & i \neq j \\ 1 & i = j \end{cases}

Put them in the columns of a matrix and the matrix gets the letter QQ. Here is one, and every entry is a third:

Q=13[122221212].Q = \frac{1}{3}\begin{bmatrix} 1 & 2 & 2 \\ 2 & -2 & 1 \\ 2 & 1 & -2 \end{bmatrix}.

Check the first column against itself: (1+4+4)/9=1(1 + 4 + 4)/9 = 1. Check it against the second: (24+2)/9=0(2 - 4 + 2)/9 = 0. All nine checks work, and all nine checks are the entries of QTQQ\T Q. Row ii of QTQ\T is column ii of QQ, so

QTQ=I.Q\T Q = I .
a₁a₂q₁q₂not a right anglea₁a₂a₁a₂10555AᵀAthe columns overlapq₁q₂1001QᵀQ = Ino overlap at all
Fig. 1 

The whole difference between the two halves of this lecture, in one picture. On the left the two columns lean on each other, so the table of their dot products has a 5 off the diagonal, and solving means undoing that 5. On the right the columns are perpendicular and have length 1, the table is the identity, and there is nothing to undo.

That single identity is the whole lecture, and it asks for less than you might expect. QQ can be tall and thin. If QQ is 5×25 \times 2 with two orthonormal columns, QTQQ\T Q is the 2×22 \times 2 identity, and it still holds. What fails for a tall QQ is the other order: QQTQQ\T is 5×55 \times 5 with rank 2, so it cannot be I5I_5. You will meet that matrix again in a few paragraphs, doing useful work.

When QQ is square, QTQ=IQ\T Q = I makes QTQ\T a genuine inverse, so QQT=IQQ\T = I too and

Q1=QT.Q^{-1} = Q\T .

The expensive step in every formula so far becomes a transpose.

The orthogonal family

You have already dragged some of these. In Lecture 2 you moved four numbers around and watched the plane move with them. Three of those machines were orthogonal, and now you can say why.

A rotation turns the plane by an angle θ\theta:

Q=[cosθsinθsinθcosθ].Q = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}.

Its columns are the landing spots of e1e_1 and e2e_2, both of length 1, and perpendicular because they started perpendicular. At θ=30°\theta = 30° the columns are (0.866,0.5)(0.866, 0.5) and (0.5,0.866)(-0.5, 0.866).

A reflection flips the plane across a line. Across the line through the origin with direction (0.8,0.6)(0.8, 0.6), the matrix is

H=[0.280.960.960.28],H = \begin{bmatrix} 0.28 & 0.96 \\ 0.96 & -0.28 \end{bmatrix},

and HTH=IH\T H = I holds because 0.282+0.962=10.28^2 + 0.96^2 = 1 and 0.28(0.96)+0.96(0.28)=00.28 (0.96) + 0.96(-0.28) = 0. The next section builds this matrix instead of quoting it.

rotate 30°, det = +1reflect, det = −1mirror
Fig. 2 

Both machines move every point without changing a single length. The dot marks one corner. The rotation carries it around; the mirror sends it to the other side, and the shape comes back inside out.

A permutation matrix shuffles the entries of a vector. It has exactly one 1 in every row and exactly one 1 in every column, and nothing else:

P=[001100010],P[579]=[957].P = \begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix}, \qquad P\begin{bmatrix} 5 \\ 7 \\ 9 \end{bmatrix} = \begin{bmatrix} 9 \\ 5 \\ 7 \end{bmatrix}.

Its columns are the standard basis vectors in a new order, so they are already orthonormal, and every permutation matrix is orthogonal. Reordering a list cannot change its length, which is the same fact said in words.

A mirror built from a shadow

Lecture 11 derived the shadow of one vector on another. For a unit vector uu the shadow of vv is short:

p=(uTv)u.p = (u\T v)\, u .

Now walk from vv to pp, and keep walking the same distance again. You arrive on the far side of the line through the origin perpendicular to uu, at the same distance from it. That is a reflection, and it is one subtraction:

v=v2(uTv)u=(I2uuT)v.v' = v - 2(u\T v)\,u = \left(I - 2uu\T\right) v .

The matrix H=I2uuTH = I - 2uu\T is the Householder reflection. It is symmetric, and applying it twice returns you home, so HTH=H2=IH\T H = H^2 = I: orthogonal, with no work.

vu(uᵀv) uHvmirror line− 2 (uᵀv) u
Fig. 3 

With u=(0.6,0.8)u = (-0.6, 0.8) and v=(1,3)v = (1, 3), the shadow is 1.8u=(1.08,1.44)1.8\,u = (-1.08, 1.44). Subtract it twice and you land on (3.16,0.12)(3.16, 0.12). Both vectors have length 10\sqrt{10}, and the mirror line cuts the dashed segment at a right angle, in half.

Nothing stretches

Here is the property that makes numerical people reach for QQ before anything else. Take any vector xx and hit it with QQ. Its length is unchanged:

Qx2=(Qx)T(Qx)=xTQTQx=xTx=x2.\norm{Qx}^2 = (Qx)\T(Qx) = x\T Q\T Q x = x\T x = \norm{x}^2 .

Two steps, and the middle one is the only fact in play. Angles survive too, because dot products do:

(Qx)T(Qy)=xTQTQy=xTy.(Qx)\T(Qy) = x\T Q\T Q y = x\T y .

Try it with the QQ from earlier. The vector (1,2,3)(1, -2, 3) has length 14=3.7416573\sqrt{14} = 3.7416573\ldots, and so does Q(1,2,3)Q(1, -2, 3), to the last digit your computer keeps.

Projection, with the inverse deleted

Lecture 11 built the projection onto the column space of AA:

P=A(ATA)1AT.P = A(A\T A)^{-1} A\T .

Set A=QA = Q and watch the middle collapse. Since QTQ=IQ\T Q = I, its inverse is II, and

P=Q(QTQ)1QT=QQT.P = Q(Q\T Q)^{-1} Q\T = QQ\T .

There is nothing to invert. Take the first two columns of the QQ above, call that tall matrix Q2Q_2, and project b=(1,1,1)b = (1,1,1) onto the plane they span:

Q2Q2Tb=19[524282425][111]=19[7811].Q_2 Q_2\T\, b = \tfrac{1}{9}\begin{bmatrix} 5 & -2 & 4 \\ -2 & 8 & 2 \\ 4 & 2 & 5 \end{bmatrix} \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix} = \tfrac{1}{9}\begin{bmatrix} 7 \\ 8 \\ 11 \end{bmatrix} .

Build A(ATA)1ATA(A\T A)^{-1}A\T from the same two columns before they were orthonormalized and you get the identical matrix, after inverting a 2×22 \times 2. Same answer, more work.

There is a second way to read QQTbQQ\T b. Multiply the other way round and it is a sum:

QQTb=q1(q1Tb)+q2(q2Tb)++qn(qnTb).QQ\T b = q_1 (q_1\T b) + q_2 (q_2\T b) + \cdots + q_n(q_n\T b).

Each term is one shadow. So the projection is the sum of the shadows of bb on each qq separately, with no correction between them. That is what “no coupling” means, and it is exactly what fails for columns that are not perpendicular: their shadows overlap, and the overlap is ATAA\T A.

Wishful thinking: suppose A=QRA = QR

Real data does not arrive with orthonormal columns. So make a wish and follow it. Suppose the matrix AA could be written as

A=QR,A = QR ,

with QQ carrying orthonormal columns and RR carrying whatever is left over. Put that into the normal equations and turn the handle:

(QR)T(QR)x^=(QR)Tb(QR)\T (QR)\,\hat{x} = (QR)\T b RTQTQRx^=RTQTb.R\T Q\T Q R\,\hat{x} = R\T Q\T b .

The middle of the left side is QTQQ\T Q, which is II, so it goes:

RTRx^=RTQTb.R\T R\,\hat{x} = R\T Q\T b .

Now RTR\T sits in front of both sides. If AA has independent columns then RR is invertible, so RTR\T is too, and it cancels:

Rx^=QTb.R\,\hat{x} = Q\T b .

Read what happened. The coupling matrix ATAA\T A is gone. In its place is one matrix multiplication QTbQ\T b and a system with a triangular RR, which back substitution solves top down in n2/2n^2/2 steps. No inverse is ever formed.

A x̂ ≈ b, with no exact answerform AᵀA and Aᵀbsolve AᵀA x̂ = Aᵀbfactor A = QRsolve R x̂ = Qᵀbthe condition number is squaredhalf the digits are goneone multiply, then back substitutenothing gets squaredthe same x̂
Fig. 4 

Two roads to the same answer. In exact arithmetic they agree to the last digit. The road on the left builds the coupling matrix and pays for it; the road on the right never builds it. The last section of this lecture prices the difference.

Everything now rests on one question. Does A=QRA = QR exist, and can you compute it?

Gram-Schmidt, on real numbers

Yes, and the recipe is one idea repeated: take the next column, subtract its shadows on everything you have built so far, and divide by what is left.

Take three columns and run the whole thing. Nothing here is symbolic:

a=[122],b=[202],c=[111].a = \begin{bmatrix} 1 \\ 2 \\ 2 \end{bmatrix}, \qquad b = \begin{bmatrix} 2 \\ 0 \\ 2 \end{bmatrix}, \qquad c = \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}.

Step 1. There is nothing to subtract from the first vector, so only normalize it. a=1+4+4=3\norm{a} = \sqrt{1 + 4 + 4} = 3, and

q1=13(1,2,2).q_1 = \tfrac{1}{3}(1, 2, 2).

Record the length that came out: r11=3r_{11} = 3.

Step 2. Take bb and remove its shadow on q1q_1. The shadow coefficient is

r12=q1Tb=13(1)(2)+13(2)(0)+13(2)(2)=23+43=2.r_{12} = q_1\T b = \tfrac{1}{3}(1)(2) + \tfrac{1}{3}(2)(0) + \tfrac{1}{3}(2)(2) = \tfrac{2}{3} + \tfrac{4}{3} = 2 .

Subtract:

B=b2q1=(2,0,2)23(1,2,2)=(43,43,23).B = b - 2q_1 = (2, 0, 2) - \tfrac{2}{3}(1, 2, 2) = \left(\tfrac{4}{3}, -\tfrac{4}{3}, \tfrac{2}{3}\right).

Check that this is perpendicular to q1q_1: 13(4383+43)=0\tfrac{1}{3}\left(\tfrac{4}{3} - \tfrac{8}{3} + \tfrac{4}{3}\right) = 0. It is, by construction, because subtracting the shadow is exactly what kills the overlap. Its length is 234+4+1=2\tfrac{2}{3}\sqrt{4 + 4 + 1} = 2, so r22=2r_{22} = 2 and

q2=13(2,2,1).q_2 = \tfrac{1}{3}(2, -2, 1).
abq₁q₂Bshadow = 2q₁B moved to the originlength 3 becomes length 1
Fig. 5 

The first two steps happen entirely inside the plane that aa and bb span, so they can be drawn flat and exactly. Measured along q1q_1 and q2q_2, the vector aa sits at (3,0)(3, 0) and bb sits at (2,2)(2, 2). Those four numbers are the first two columns of RR.

Drag the two starting vectors and run the steps yourself. What happens when they are nearly parallel is the whole story of the last section of this lecture:

Try it. Drag the two vectors, then press Step
ab

Two independent vectors. Neither has length 1, and they are not at a right angle.

R so far

??
0?

Drag either head. Push the two vectors nearly parallel and watch the leftover almost vanish before it is stretched back to length 1.

Step 3. Now cc, with two shadows to remove:

r13=q1Tc=13(1+2+2)=53,r23=q2Tc=13(22+1)=13.r_{13} = q_1\T c = \tfrac{1}{3}(1 + 2 + 2) = \tfrac{5}{3}, \qquad r_{23} = q_2\T c = \tfrac{1}{3}(2 - 2 + 1) = \tfrac{1}{3}. C=c53q113q2=(1,1,1)59(1,2,2)19(2,2,1)=(29,19,29).C = c - \tfrac{5}{3}q_1 - \tfrac{1}{3}q_2 = (1,1,1) - \tfrac{5}{9}(1,2,2) - \tfrac{1}{9}(2,-2,1) = \left(\tfrac{2}{9}, \tfrac{1}{9}, -\tfrac{2}{9}\right).

Its length is 194+1+4=13\tfrac{1}{9}\sqrt{4 + 1 + 4} = \tfrac{1}{3}, so r33=13r_{33} = \tfrac{1}{3} and q3=13(2,1,2)q_3 = \tfrac{1}{3}(2, 1, -2).

q₁q₂q₃cCthe plane q₁ and q₂ span
Fig. 6 

The third vector leans hard into the plane the first two already span. Its shadow there has length (5/3)2+(1/3)21.70\sqrt{(5/3)^2 + (1/3)^2} \approx 1.70, while cc itself has length 31.73\sqrt{3} \approx 1.73. Only 1/31/3 of a unit sticks out, and after stretching, that scrap is q3q_3. Remember how short it is; the last section is about what short means.

Now collect the numbers you wrote down along the way. Each original vector is built from the qq‘s using exactly the coefficients Gram-Schmidt produced:

a=3q1,b=2q1+2q2,c=53q1+13q2+13q3.a = 3q_1, \qquad b = 2q_1 + 2q_2, \qquad c = \tfrac{5}{3}q_1 + \tfrac{1}{3}q_2 + \tfrac{1}{3}q_3 .

Stack those coefficient lists as columns and you have RR. Stack the qq‘s as columns and you have QQ:

[121201221]A=13[122221212]Q[325302130013]R.\underbrace{\begin{bmatrix} 1 & 2 & 1 \\ 2 & 0 & 1 \\ 2 & 2 & 1 \end{bmatrix}}_{A} = \underbrace{\tfrac{1}{3}\begin{bmatrix} 1 & 2 & 2 \\ 2 & -2 & 1 \\ 2 & 1 & -2 \end{bmatrix}}_{Q} \underbrace{\begin{bmatrix} 3 & 2 & \tfrac{5}{3} \\ 0 & 2 & \tfrac{1}{3} \\ 0 & 0 & \tfrac{1}{3} \end{bmatrix}}_{R}.

Multiply it out to check. Column 2 of the product is 2q1+2q2=23(1,2,2)+23(2,2,1)=(2,0,2)2q_1 + 2q_2 = \tfrac{2}{3}(1,2,2) + \tfrac{2}{3}(2,-2,1) = (2, 0, 2), which is bb. The wish came true, and it came true for the plain reason that every step of the process was a subtraction and a division.

Why is RR triangular? Because q2q_2 was born after aa was already finished. The vector aa is a multiple of q1q_1 alone, so its column of RR has one entry and two zeros. In general R=QTAR = Q\T A, and the entry below the diagonal is qiTajq_i\T a_j with i>ji > j: a later qq against an earlier aa, and those are perpendicular.

abcq₁q₂q₃325/3021/3001/3b = 2q₁ + 2q₂read straight down the columnthe shaded corner is forced to zero: q₂ and q₃ are built after a and bthe diagonal holds the lengths that were divided out
Fig. 7 

RR is a recipe card. Column jj says how much of each qq goes into the jj-th original vector. Everything below the diagonal is zero because Gram-Schmidt builds the qq‘s in order and never looks back.

python
import numpy as np

A = np.array([[1., 2., 1.],
              [2., 0., 1.],
              [2., 2., 1.]])         # columns a, b, c

qs, R = [], [[0.0] * 3 for _ in range(3)]
for j in range(3):
    v = A[:, j]
    for i in range(j):
        R[i][j] = float(qs[i] @ v)   # how much of q_i is still in v
        v = v - R[i][j] * qs[i]      # take the shadow away
    R[j][j] = float(np.linalg.norm(v))       # the length that is left
    qs.append(v / R[j][j])
Q = np.stack(qs, axis=1)

print(3 * Q)   # [[ 1.  2.  2.] [ 2. -2.  1.] [ 2.  1. -2.]]
print(R)       # [[3.0, 2.0, 1.6666666666666665],
               #  [0.0, 2.0, 0.33333333333333337],
               #  [0.0, 0.0, 0.3333333333333333]]
print(np.round(Q.T @ Q, 12))              # the identity
print(np.abs(Q @ np.array(R) - A).max())  # 0.0   exact here
x = np.array([1., -2., 3.])
print(np.linalg.norm(Q @ x))   # 3.741657386773942
print(np.linalg.norm(x))       # 3.7416573867739413

The same process, done stably

Written as an algorithm, Gram-Schmidt is six lines:

text
for j = 1 to n
    v = column j of A
    for i = 1 to j-1
        R[i,j] = q_i dot v
        v      = v - R[i,j] * q_i
    R[j,j] = length of v
    q_j    = v / R[j,j]

Look closely at line 4. The dot product is taken against v, the vector as it stands right now, with earlier shadows already removed. The classical version takes it against the original column instead: R[i,j] = q_i dot A[:,j]. In exact arithmetic the two agree, since the pieces already removed were perpendicular to qiq_i anyway. In floating point they do not, because the first version measures the small leftover directly while the second measures a big vector and hopes the large parts cancel.

The version above is called modified Gram-Schmidt, and the difference is not academic. Run both on a matrix whose columns nearly coincide and check how far QTQQ\T Q drifts from the identity:

python
import numpy as np

def gram_schmidt(A, classical):
    qs = []
    for j in range(A.shape[1]):
        v = A[:, j].copy()
        for i in range(j):
            r = qs[i] @ (A[:, j] if classical else v)   # the line that differs
            v = v - r * qs[i]
        qs.append(v / np.linalg.norm(v))
    return np.stack(qs, axis=1)

eps = 1e-8
A = np.array([[1., 1., 1.],
              [eps, 0., 0.],
              [0., eps, 0.],
              [0., 0., eps]])         # three columns that almost agree

for name, Q in [("classical", gram_schmidt(A, True)),
                ("modified ", gram_schmidt(A, False)),
                ("library  ", np.linalg.qr(A)[0])]:
    print(name, f"{np.abs(Q.T @ Q - np.eye(3)).max():.3e}")
# classical 5.000e-01     the columns are not perpendicular at all
# modified  7.071e-09     eight digits kept
# library   6.661e-16     Householder mirrors, full precision

Half. The classical version returns columns that are not remotely perpendicular, and it does so silently. Modified Gram-Schmidt keeps eight digits. Libraries do better still by never building QQ this way at all: they apply a chain of Householder mirrors, each one an exact orthogonal matrix, and lengths cannot drift when nothing stretches.

Two roads to least squares

Now the payoff, priced honestly. You have two ways to solve a least squares problem.

The first road builds ATAA\T A and solves. The second road factors A=QRA = QR and solves Rx^=QTbR\hat{x} = Q\T b by back substitution. On clean data they agree to the last digit. Take the measurements table from Lecture 12, put a column of ones beside the two feature columns, and both roads return x^=(14.855866,2.079330,0.541899)\hat{x} = (14.855866, -2.079330, -0.541899).

The roads part when the columns of AA nearly line up, which is what real features do. Here is a matrix built to lean that way, with a knob dd that squeezes two columns together:

A=[1111+d11d].A = \begin{bmatrix} 1 & 1 \\ 1 & 1+d \\ 1 & 1-d \end{bmatrix}.

The condition number of a matrix is the ratio of its largest stretch to its smallest, and it predicts how many digits a solve can lose. For this AA it grows like 1/d1/d. For ATAA\T A it grows like 1/d21/d^2, because forming ATAA\T A squares every stretch factor. Squaring a condition number means throwing away half your digits before you start.

10⁰10⁴10⁸10¹²10¹⁶10⁻²10⁻⁴10⁻⁶10⁻⁸how close the two columns are, dcond(A)cond(AᵀA)what float64 can resolve
Fig. 8 

Every point is computed. Squeeze the columns to d=108d = 10^{-8} and AA still has a condition number of 2.4×1082.4 \times 10^{8}, comfortably solvable. Its coupling matrix ATAA\T A is at 8.8×10168.8 \times 10^{16}, past the line, and past that line the computer cannot tell it from a singular matrix.

python
import numpy as np

def make(d):
    A = np.array([[1., 1.], [1., 1. + d], [1., 1. - d]])
    return A, A @ np.array([1., 1.])   # so the answer is exactly (1, 1)

for d in [1e-2, 1e-6, 1e-8]:
    A, b = make(d)
    s = np.linalg.svd(A, compute_uv=False)
    t = np.linalg.svd(A.T @ A, compute_uv=False)
    print(d, s[0] / s[-1], t[0] / t[-1])
# 0.01  2.45e+02  6.00e+04
# 1e-06 2.45e+06  6.00e+12
# 1e-08 2.45e+08  8.83e+16   squaring the condition costs half the digits

A, b = make(1e-6)
print(np.linalg.solve(A.T @ A, A.T @ b))   # [1.00022207 0.99977793]
Q, R = np.linalg.qr(A)
print(np.linalg.solve(R, Q.T @ b))         # [1. 1.]        exact

A, b = make(1e-8)
print(np.linalg.det(A.T @ A))       # 0.0   AtA is now singular
Q, R = np.linalg.qr(A)
print(np.linalg.solve(R, Q.T @ b))  # [1.00000001 0.99999999]   QR is fine

At d=106d = 10^{-6} the normal equations lose four digits and QR loses none. At d=108d = 10^{-8} the normal equations stop working: all four entries of ATAA\T A round to the same number 3, its determinant is exactly zero, and the solver refuses. The matrix AA itself is untouched. It still has two independent columns and an ordinary condition number. All the damage was done by the step that formed ATAA\T A, and QR never takes that step.

Why deep networks are initialised with Q

A deep network multiplies its input by one matrix per layer. Sixty layers is sixty multiplications, and whatever length the signal has at the end is whatever those sixty matrices left of it. The callout above claimed an orthogonal matrix can do neither harm. Here is that claim run for six steps and measured.

Start from x=(1,0)x = (1, 0) and multiply repeatedly by three different matrices. The first is the rotation QQ with columns (0.6,0.8)(0.6, 0.8) and (0.8,0.6)(-0.8, 0.6). The other two are ordinary matrices with no special structure.

01234561010.1multiplications applied‖x‖orthogonal Q: 1.000 at every stepa generic W: 1.000 → 10.182another generic V: 1.000 → 0.052
Fig. 9 

Six multiplications, three matrices, one starting vector. The scale is logarithmic, so equal steps up mean equal factors. QQ holds the length at exactly 11 forever, because Qx=x\norm{Qx} = \norm{x} is not an approximation. The other two are ordinary matrices, and they leave 10.18210.182 and 0.0520.052.

Six steps already spread the two ordinary matrices by a factor of nearly 200200. At sixty layers the same arithmetic gives numbers your machine cannot hold at one end and cannot distinguish from zero at the other. That is the exploding and vanishing signal problem, and it is a fact about Ax\norm{Ax} before it is a fact about training.

This is why orthogonal initialisation exists. Give every layer a QQ and the signal arrives at the last layer the same length it left the first, whatever the depth. The gradient runs the same gauntlet backwards through the transposes, and QTQ\T is orthogonal too, so it is protected by the identical two-line proof.

Where this is going

You now have a factorization that turns any independent columns into perpendicular unit ones, and a reason to want it. Two things follow.

The first is that QQ shows up again as the answer to a different question. Lecture 15 asks which directions a matrix leaves alone, and for symmetric matrices the answer is a full orthonormal set: S=QΛQTS = Q\Lambda Q\T, a rotation, a stretch along the axes, and the rotation undone. Every fact in this lecture is waiting there.

The second is that Gram-Schmidt needs independent columns, and dies when they are not. When two columns coincide exactly, r22r_{22} comes out zero and you divide by it. The tool that handles rank honestly, and handles nearly-dependent columns better than anything here, is the singular value decomposition, which Part VI reaches by combining this lecture with the next two.