QR Factorization
Chapter 8 • Section 8-4
"Every matrix has a hidden orthogonal heart. 💎"
🧩 The Decomposition
Any matrix $A$ with linearly independent columns can be factored as:
Q: Orthogonal
Columns are orthonormal basis vectors (from Gram-Schmidt).
R: Upper Triangular
Contains the coefficients from the Gram-Schmidt process.
Existence Theorem
Let $A$ be an $m \times n$ matrix with linearly independent columns. Then $A$ can be factored as $A=QR$, where:
- $Q$ is an $m \times n$ matrix with orthonormal columns.
- $R$ is an $n \times n$ upper triangular matrix with positive diagonal entries.
Note: If $A$ is square ($m=n$), then $Q$ is orthogonal.
⚙️ The QR Algorithm
We use the Gram-Schmidt process on the columns of $A = [\vec{c}_1, \dots, \vec{c}_n]$.
Step 1: Find Q
Apply Gram-Schmidt to $\{\vec{c}_1, \dots, \vec{c}_n\}$ to get orthogonal vectors $\{\vec{f}_1, \dots, \vec{f}_n\}$.
Normalize them to get orthonormal vectors $\{\vec{q}_1, \dots, \vec{q}_n\}$.
Step 2: Find R
Since $A = QR$, we have $R = Q^T A$. The entries $r_{ij}$ are given by:
Entries below the diagonal ($i > j$) are 0.
📝 Worked Example
Find the QR factorization of $A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \\ 0 & 1 \end{bmatrix}$.
1. Gram-Schmidt on Columns
$\vec{c}_1 = (4, 2, 0)$. Let $\vec{f}_1 = \vec{c}_1$. $\|\vec{f}_1\| = \sqrt{20}$.
$\vec{q}_1 = \frac{1}{\sqrt{20}}(4, 2, 0)$.
$\vec{c}_2 = (1, 3, 1)$.
$\vec{f}_2 = \vec{c}_2 - \text{proj}_{\vec{f}_1}(\vec{c}_2) = (1, 3, 1) - \frac{10}{20}(4, 2, 0) = (-1, 2, 1)$.
$\|\vec{f}_2\| = \sqrt{6}$. $\vec{q}_2 = \frac{1}{\sqrt{6}}(-1, 2, 1)$.
2. Construct Q and R
QR Explorer
See the QR decomposition for a simple $2 \times 2$ matrix.
$A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$ (Shear)
Matrix A
[0, 1]]
Matrix Q (Orthogonal)
[0, 1]]
Identity (since columns of A were already independent? No, wait...)
Matrix R (Upper Triangular)
[0, 1]]
Note: For $A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$, the first column is $\vec{e}_1$. The second column projects onto $\vec{e}_1$ as 1. So Gram-Schmidt gives $\vec{q}_1=\vec{e}_1, \vec{q}_2=\vec{e}_2$. Thus $Q=I, R=A$.
🧠 Knowledge Check Win $15
Why is $R$ always upper triangular?