LINEAR-ALGEBRA Β· Unit 16 Β· Video 4 Β· Interactive Practice

Why Gram-Schmidt Secretly Builds an Upper Triangular Matrix

IKey Formulas

Formula Name Description
A=QRA = QR QR Factorization QQ has orthonormal columns, RR is upper triangular
rij=qi⊀ajr_{ij} = \mathbf{q}_i^\top \mathbf{a}_j Entry of RR Inner product of ii-th Q-column with jj-th A-column
R=Q⊀AR = Q^\top A Direct formula Follows from Q⊀Q=IQ^\top Q = I
Qβˆ’1=Q⊀Q^{-1} = Q^\top Orthonormal inverse The power of orthonormality

IIVisualization 1 β€” Filling R Column by Column

With A=[110101011]A = \begin{bmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{bmatrix}, each Gram-Schmidt step rewrites one column of AA in the orthonormal q\mathbf{q}-basis, filling exactly one column of RR.

IIIVisualization 2 β€” Why the Sub-Diagonal Zeros Appear

Gram-Schmidt forces q2βŠ₯span⁑{a1}\mathbf{q}_2 \perp \operatorname{span}\{\mathbf{a}_1\}, so r21=q2⊀a1=0r_{21} = \mathbf{q}_2^\top \mathbf{a}_1 = 0 for every pair of vectors.

πŸ’‘ If a1\mathbf{a}_1 and a2\mathbf{a}_2 line up, r22=0r_{22} = 0 and Gram-Schmidt breaks down β€” the columns must be linearly independent.

IVVisualization 3 β€” R Is Always Upper Triangular

For any matrix with independent columns, A=QRA = QR yields an upper-triangular RR β€” the sub-diagonal zeros are guaranteed by orthogonality.

πŸ’‘ Equivalently R=Q⊀AR = Q^\top A, since Q⊀Q=IQ^\top Q = I β€” once you have QQ, no Gram-Schmidt is needed.

VQuiz Questions

Question 1

In the QR factorization A=QRA = QR, what does the entry rijr_{ij} (row ii, column jj of RR) equal?

βœ… Correct! Each R entry is the inner product of a Q-column with an A-column.

❌ Not quite. Think about what R=Q⊀AR = Q^\top A tells us about individual entries: row ii, column jj of RR is qi⊀aj\mathbf{q}_i^\top \mathbf{a}_j.

Show solution

Solution:

Each entry of RR is computed as: rij=qi⊀ajr_{ij} = \mathbf{q}_i^\top \mathbf{a}_j

This is the dot product of the ii-th column of QQ with the jj-th column of AA.

This follows directly from R=Q⊀AR = Q^\top A: the (i,j)(i,j) entry of Q⊀AQ^\top A is qi⊀aj\mathbf{q}_i^\top \mathbf{a}_j.

Question 2

Why is r21=q2⊀a1=0r_{21} = \mathbf{q}_2^\top \mathbf{a}_1 = 0 in the QR factorization?

βœ… Correct! The zeros are forced by Gram-Schmidt's orthogonalization β€” by construction, not coincidence.

❌ Not quite. The zeros aren't a convention or coincidence β€” they're a consequence of how Gram-Schmidt builds each q vector perpendicular to the span of earlier columns.

Show solution

Solution:

Gram-Schmidt builds q2\mathbf{q}_2 by subtracting from a2\mathbf{a}_2 its projection onto q1\mathbf{q}_1: v2=a2βˆ’(q1⊀a2) q1\mathbf{v}_2 = \mathbf{a}_2 - (\mathbf{q}_1^\top \mathbf{a}_2)\,\mathbf{q}_1

This makes v2\mathbf{v}_2 (and hence q2=v2/βˆ₯v2βˆ₯\mathbf{q}_2 = \mathbf{v}_2/\|\mathbf{v}_2\|) perpendicular to span{a1}\text{span}\{\mathbf{a}_1\}.

Since a1∈span{a1}\mathbf{a}_1 \in \text{span}\{\mathbf{a}_1\}, we get q2⊀a1=0\mathbf{q}_2^\top \mathbf{a}_1 = 0.

In general: for i>ji > j, qiβŠ₯span{a1,…,aiβˆ’1}\mathbf{q}_i \perp \text{span}\{\mathbf{a}_1, \ldots, \mathbf{a}_{i-1}\} and aj\mathbf{a}_j lives in that span (since j<ij < i), so rij=qi⊀aj=0r_{ij} = \mathbf{q}_i^\top \mathbf{a}_j = 0.

The zeros are forced by construction, not by convention.

Question 3

True or False: If QQ is the matrix with orthonormal columns from A=QRA = QR, then Qβˆ’1=Q⊀Q^{-1} = Q^\top.

βœ… Correct! Orthonormal columns give Q⊀Q=IQ^\top Q = I, so Qβˆ’1=Q⊀Q^{-1} = Q^\top. That's the power of orthonormality!

❌ Incorrect. Since QQ has orthonormal columns, Q⊀Q=IQ^\top Q = I, which means Qβˆ’1=Q⊀Q^{-1} = Q^\top.

Show solution

Solution: True

Since QQ has orthonormal columns: Q⊀Q=IQ^\top Q = I.

For a square matrix, this means Qβˆ’1=Q⊀Q^{-1} = Q^\top.

This is what makes QR especially powerful:

  • Inverting QQ is trivial β€” just transpose it!
  • This gives us R=Q⊀AR = Q^\top A directly from A=QRA = QR: A=QRβ€…β€ŠβŸΉβ€…β€ŠQ⊀A=Q⊀QR=IR=RA = QR \;\Longrightarrow\; Q^\top A = Q^\top QR = IR = R

Compare with LU, where computing Lβˆ’1L^{-1} requires actual work.

Question 4

When using QR factorization to solve the least-squares problem Axβ‰ˆbA\mathbf{x} \approx \mathbf{b}, what system do you actually solve?

βœ… Correct! QR turns least squares into simple back-substitution, avoiding the numerically dangerous A⊀AA^\top A.

❌ Close, but not the QR approach. The normal equations work but are numerically unstable. The whole point of QR is to avoid forming A⊀AA^\top A! Instead: Rx=Q⊀bR\mathbf{x} = Q^\top \mathbf{b}.

❌ Not quite. Start from A=QRA = QR, multiply both sides by Q⊀Q^\top, and use Q⊀Q=IQ^\top Q = I to get Rx=Q⊀bR\mathbf{x} = Q^\top \mathbf{b}.

Show solution

Solution:

Starting from Axβ‰ˆbA\mathbf{x} \approx \mathbf{b} with A=QRA = QR:

  1. Substitute: QRxβ‰ˆbQR\mathbf{x} \approx \mathbf{b}
  2. Multiply left by Q⊀Q^\top: Q⊀QRx=Q⊀bQ^\top QR\mathbf{x} = Q^\top \mathbf{b}
  3. Since Q⊀Q=IQ^\top Q = I: Rx=Q⊀bR\mathbf{x} = Q^\top \mathbf{b}

Since RR is upper triangular, we solve by back-substitution β€” fast and numerically stable.

The normal equations A⊀Ax=A⊀bA^\top A\mathbf{x} = A^\top \mathbf{b} also work, but forming A⊀AA^\top A amplifies numerical errors. QR avoids this entirely, which is why it's preferred in practice.

Solved: 0 / 4