Calculation Results
1. What is QR decomposition?
The QR decomposition factors a matrix \(A\) into \(A=QR\) where
- \(Q\) has orthonormal columns (for real matrices \(Q^{T}Q = I\)) — an orthogonal matrix when square;
- \(R\) is upper triangular.
QR is widely used for solving least-squares problems, numerical algorithms and computing orthonormal bases.
2. Formula / Gram–Schmidt procedure (brief)
Given column vectors \(a_1,a_2,\dots,a_n\) of \(A\), classical Gram–Schmidt constructs orthonormal vectors \(q_1,\dots,q_n\):
- \(u_1 = a_1,\quad q_1 = u_1 / \|u_1\|\).
- For \(k\ge2\): \(u_k = a_k - \sum_{j=1}^{k-1} \operatorname{proj}_{q_j}(a_k)\), where \(\operatorname{proj}_{q_j}(a_k) = (q_j^{T}a_k)q_j.\)
- \(q_k = u_k / \|u_k\|\).
Finally \(Q=[q_1\ \cdots\ q_n]\) and \(R = Q^{T}A\). For numerical stability prefer Modified Gram–Schmidt or Householder reflections for production code.
3. Worked examples
Example 1
Find QR for
Step 1. \(u_1 = [1,1]^T,\ \|u_1\|=\sqrt{2},\ q_1=\frac{1}{\sqrt2}[1,1]^T.\)
Step 2. \(q_1^{T}a_2 = \frac{1}{\sqrt2}[1,1]\cdot[1,-1] = 0\Rightarrow u_2=a_2.\)
\(q_2=\frac{1}{\sqrt2}[1,-1]^T.\)
Result:
Example 2
Find QR for
\(u_1=[2,0]^T,\ \|u_1\|=2,\ q_1=[1,0]^T.\)
\(q_1^{T}a_2 = [1,0]\cdot[1,2]=1,\ u_2=a_2 - (q_1^{T}a_2)q_1 = [0,2]^T,\ q_2=[0,1]^T.\)
Result:
4. Common mistakes
- Not normalizing the orthogonal vectors — forgetting the \(\|u_k\|\) step.
- Using classical Gram–Schmidt for ill-conditioned matrices — it can be numerically unstable.
- Mixing up order: \(R = Q^{T}A\), not \(AQ^{T}\).
- Assuming \(Q\) must be square — for tall matrices \(Q\) has orthonormal columns (m×n) and \(R\) is n×n.
- Forgetting to handle linear dependence among columns (zero or near-zero \(u_k\)).
5. Practice problems (answers hidden)
Try these by hand or with your QR calculator. Click Show Answer to reveal one valid QR (answers may differ by signs or ordering of orthonormal vectors).
Exercise 1
Show Answer
(Here first column already unit; second column orthogonalized gives [0,1].)
Exercise 2
Show Answer
(Signs or exact fractions may vary; \(R=Q^{T}A\) should hold.)
Exercise 3
Show Answer
(One valid orthonormal basis; equivalent alternatives differ by column signs.)
Exercise 4
Show Answer
(Columns scaled and orthogonalized; verify \(Q^{T}Q=I\) and \(R=Q^{T}A\).)
QR decomposition also relates to matrix multiplication, determinants, and eigenvectors.