11 Orthogonal Transformations and the QR Factorization
Changing to an orthonormal basis preserves Euclidean distances. This lets us simplify a matrix without magnifying the errors already present in a vector. We construct such changes of basis by reflections and by subtracting projections.
The resulting QR factorization records each original column in an orthonormal basis. Its triangular factor records the coefficients of those columns. The same construction will turn least squares into a triangular solve.
11.1 Orthogonality, Isometry, and Invariance
A square matrix \(\bQ \in \fR^{n \times n}\) is termed orthogonal if its columns form an orthonormal basis for \(\fR^n\). Equivalently, \[ \begin{align} \bQ^T\bQ = \bQ\bQ^T = \bI_n \iff \bQ^{-1} = \bQ^T. \end{align} \] For rectangular matrices \(\bQ \in \fR^{m \times n}\) with \(m \geq n\), we say that \(\bQ\) has orthonormal columns if \(\bQ^T\bQ = \bI_n\).
Let \(\bQ \in \fR^{n \times n}\) be an orthogonal matrix. For all vectors \(\bx, \by \in \fR^n\), the transformation \(\bx \mapsto \bQ\bx\) satisfies the following properties:
Inner Product Preservation: \(\langle \bQ\bx, \bQ\by \rangle = (\bQ\bx)^T(\bQ\by) = \bx^T\by = \langle \bx, \by \rangle\).
Isometry (Length Preservation): \(\|\bQ\bx\|_2 = \|\bx\|_2\).
Matrix 2-Norm and Conditioning: \(\|\bQ\|_2 = 1\) and \(\kappa_2(\bQ) = \|\bQ\|_2 \|\bQ^{-1}\|_2 = 1\).
Determinant: \(\det(\bQ) = \pm 1\), where the sign records whether orientation is preserved or reversed. In higher dimensions an orientation-reversing orthogonal map need not be a single hyperplane reflection.
We establish the claims in the order in which they depend on one another.
The transpose of \(\bQ\bx\) is \(\bx^T\bQ^T\). Hence \[ \begin{align} (\bQ\bx)^T(\bQ\by) =\bx^T(\bQ^T\bQ)\by =\bx^T\bI\by=\bx^T\by. \end{align} \] The middle equality is exactly where orthogonality is used.
Set \(\by=\bx\). Then \(\|\bQ\bx\|_2^2=\|\bx\|_2^2\). Norms are nonnegative, so taking square roots gives equality of lengths.
Every Euclidean unit input has a Euclidean unit output. The maximum output length is therefore one. Since \(\bQ^{-1}=\bQ^T\) and \(\bQ^T\) is also orthogonal, both factors in \(\kappa_2(\bQ)=\|\bQ\|_2\|\bQ^{-1}\|_2\) equal one.
Take determinants in \(\bQ^T\bQ=\bI\). Multiplicativity and invariance under transpose give \[ \begin{align} 1=\det(\bI)=\det(\bQ^T)\det(\bQ)=(\det\bQ)^2. \end{align} \] The determinant is real, so it is \(1\) or \(-1\). These signs distinguish preservation and reversal of orientation.
11.2 The QR Factorization
For two independent columns, begin with \(\bq_1=\ba_1/\|\ba_1\|_2\). Subtract the projection of \(\ba_2\) onto \(\bq_1\) and normalize what remains to obtain \(\bq_2\). Thus \[ \begin{align} \ba_1=r_{11}\bq_1,\qquad \ba_2=r_{12}\bq_1+r_{22}\bq_2. \end{align} \] Writing these two relations side by side gives a matrix product with an upper triangular factor. Each additional independent column adds one new basis vector in the same way.
Let \(\bA \in \fR^{m \times n}\) with \(m \geq n\).
The Full QR Factorization is given by \[ \begin{align} \bA = \bQ\bR = \begin{pmatrix} \bQ_1 & \bQ_2 \end{pmatrix} \begin{pmatrix} \bR_1 \\ \bzero \end{pmatrix}, \end{align} \] where \(\bQ \in \fR^{m \times m}\) is orthogonal, \(\bQ_1 \in \fR^{m \times n}\), \(\bQ_2 \in \fR^{m \times (m-n)}\), and \(\bR_1 \in \fR^{n \times n}\) is upper triangular.
The Thin (Economy) QR Factorization retains only the first \(n\) columns: \[ \begin{align} \bA = \bQ_1 \bR_1, \end{align} \] where \(\bQ_1 \in \fR^{m \times n}\) satisfies \(\bQ_1^T\bQ_1 = \bI_n\) and \(\bR_1 \in \fR^{n \times n}\) is upper triangular.
If \(\bA\) has full column rank, the thin QR factorization is unique when the diagonal entries of \(\bR_1\) are chosen to be strictly positive.
Suppose \(\bA=\bQ_1\bR_1=\widehat{\bQ}_1\widehat{\bR}_1\) has full column rank and both triangular factors have positive diagonal. Show that \(\bQ_1^T\widehat{\bQ}_1=\bR_1\widehat{\bR}_1^{-1}\) is orthogonal and upper triangular. Prove that such a matrix with positive diagonal must be the identity, and deduce uniqueness.
(Subspace identification via QR) When \(\bA\) has full column rank, the columns of \(\bQ_1\) form an orthonormal basis for the column space (range) \(\mathcal{R}(\bA)\), while the columns of \(\bQ_2\) form an orthonormal basis for the orthogonal complement \(\mathcal{R}(\bA)^\perp = \mathcal{N}(\bA^T)\). For overdetermined least-squares problems where \(m \gg n\), the thin factorization requires less storage (\(O(mn)\) vs \(O(m^2)\)) and is used in practical implementations.
11.3 Householder Triangularization
The standard method for computing the QR factorization of a dense matrix is the Householder reflection technique. At each step, a Householder reflector is constructed to zero out all subdiagonal entries of a column simultaneously (Householder 1958).
A reflection leaves the component parallel to a mirror unchanged and reverses the perpendicular component. If \(\bv\) is normal to the mirror, that perpendicular component of \(\by\) is \(\bv(\bv^T\by)/(\bv^T\bv)\). Subtracting twice this component gives the formula below.
Let \(\bv \in \fR^m\) be a nonzero vector. The Householder reflector associated with \(\bv\) is the matrix \[ \begin{align} \bH = \bI - 2 \frac{\bv\bv^T}{\bv^T\bv}. \end{align} \] Geometrically, \(\bH\) reflects any vector across the hyperplane orthogonal to \(\bv\). Every Householder reflector is symmetric (\(\bH^T = \bH\)) and orthogonal (\(\bH^T\bH = \bH^2 = \bI\)).
Let \(\bP=\bv\bv^T/(\bv^T\bv)\). Show that \(\bP^T=\bP\) and \(\bP^2=\bP\), and deduce that \((\bI-2\bP)^2=\bI\). Determine the action of the reflector on \(\operatorname{span}\{\bv\}\) and its orthogonal complement. If the column to be reduced is zero, explain why no reflector is needed.
Given a nonzero vector \(\bx \in \fR^m\), we wish to find a reflector \(\bH\) that aligns \(\bx\) with the first canonical coordinate axis: \(\bH\bx = \pm \|\bx\|_2 \be_1\). The vector \(\bv\) is chosen as \[ \begin{align} \bv = \bx + \operatorname{sign}(x_1) \|\bx\|_2 \be_1, \end{align} \] where \(\operatorname{sign}(x_1) = 1\) if \(x_1 \geq 0\) and \(-1\) if \(x_1 < 0\). Choosing the sign of the first component ensures that the two added terms have identical signs and avoids cancellation when the first component of \(\bv\) is formed.
We want \(\bH\bx=\alpha\be_1\) with \(\bH\) orthogonal. Orthogonality preserves the norm, so any possible \(\alpha\) must satisfy \(|\alpha|=\|\bx\|_2\). Choose \(\alpha=-\operatorname{sign}(x_1)\|\bx\|_2\) with the convention in the statement, and set \(\bv=\bx-\alpha\be_1\).
This vector is nonzero. Its first entry is \(x_1+\operatorname{sign}(x_1)\|\bx\|_2\), whose magnitude is \(|x_1|+\|\bx\|_2>0\). The reflector defined from \(\bv\) is therefore well defined.
Calculate its denominator before applying it: \[ \begin{align} \bv^T\bv &=(\bx-\alpha\be_1)^T(\bx-\alpha\be_1)\\ &=\|\bx\|_2^2-2\alpha x_1+\alpha^2\\ &=2\|\bx\|_2^2-2\alpha x_1 =2(\bx-\alpha\be_1)^T\bx=2\bv^T\bx. \end{align} \] The third line uses \(\alpha^2=\|\bx\|_2^2\). Since \(\bv\neq0\), the denominator is positive. Substitute the identity into the reflector action: \[ \begin{align} \bH\bx &=\bx-2\bv\frac{\bv^T\bx}{\bv^T\bv} =\bx-\bv=\alpha\be_1. \end{align} \] Thus all entries except the first are zero.
The chosen sign also makes the two terms forming \(v_1\) have the same sign. It avoids subtracting two nearly equal magnitudes, which could lose relative accuracy in the vector defining the reflector. The opposite choice of \(\alpha\) can work algebraically when its vector is nonzero, but lacks this numerical protection (Higham 2002; Golub and Van Loan 2013).
Construct the Householder reflector \(\bH\) that transforms the vector \(\bx = (3, 4)^T\) into \(\alpha \be_1 = (-5, 0)^T\). Explicitly write out the \(2 \times 2\) matrix \(\bH\) and verify that \(\bH = \bH^T\) and \(\bH^2 = \bI\).
(Matrix-free application and complexity) In numerical algorithms, a Householder matrix \(\bH\) is usually stored through its defining vector rather than as an explicit \(m \times m\) array. To apply \(\bH\) to a vector \(\by\), we compute \[ \begin{align} \bH\by = \by - \left( \frac{2\bv^T\by}{\bv^T\bv} \right) \bv, \end{align} \] which requires only an inner product and a vector update costing \(O(m)\) flops. For a matrix \(\bA \in \fR^{m \times n}\), Householder QR requires \(2mn^2 - \frac{2}{3}n^3\) flops.
11.4 Gram–Schmidt Orthogonalization
The Gram–Schmidt process constructs the thin QR factorization column by column by projecting each column of \(\bA\) onto the orthogonal complement of the previously computed basis vectors.
Let \(\ba_1,...,\ba_n\in\fR^m\) be linearly independent columns of \(\bA\). This assumption ensures that every vector to be normalized below is nonzero in exact arithmetic.
Classical Gram–Schmidt (CGS): For each column \(k = 1, ..., n\), compute all projections against the original vector simultaneously: \[ \begin{align} r_{ik} = \bq_i^T \ba_k \quad (i = 1, ..., k-1), \qquad \bv_k = \ba_k - \sum_{i=1}^{k-1} r_{ik} \bq_i, \qquad r_{kk} = \|\bv_k\|_2, \qquad \bq_k = \frac{\bv_k}{r_{kk}}. \end{align} \]
Modified Gram–Schmidt (MGS): For each column \(k\), subtract projections sequentially from the partially updated vector: \[ \begin{align} \bv_k^{(1)} = \ba_k, \qquad \bv_k^{(i+1)} = \bv_k^{(i)} - (\bq_i^T \bv_k^{(i)}) \bq_i \quad (i = 1, ..., k-1), \qquad \bq_k = \frac{\bv_k^{(k)}}{\|\bv_k^{(k)}\|_2}. \end{align} \]
Rearrange the classical Gram–Schmidt update to express \(\ba_k\) in terms of \(\bq_1,...,\bq_k\). Assemble these relations to prove \(\bA=\bQ_1\bR_1\). Explain what a zero diagonal entry would tell you about the original columns. In modified Gram–Schmidt, which inner products must be saved to construct \(\bR_1\)?
Compute the thin QR factorization of \(\bA = \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix}\) using Modified Gram-Schmidt.
(Stability hierarchy among orthogonalization methods) In exact arithmetic, CGS and MGS produce the same orthonormal basis, up to signs. In floating-point arithmetic their organization matters:
Classical Gram–Schmidt can lose orthogonality when the columns are nearly dependent.
Modified Gram–Schmidt retains more orthogonality because each projection is taken from the current residual rather than from the original column.
Householder QR is backward stable and normally produces a computed \(\bQ\) that is orthogonal to working precision.
Precise bounds depend on dimension, scaling, and the condition of the column space. Reorthogonalization can make Gram–Schmidt reliable when an explicit basis is required.
11.5 Orthogonal Projectors
Let \(S \subset \fR^m\) be a subspace with orthonormal basis columns stored in \(\bQ_1 \in \fR^{m \times n}\). The orthogonal projector onto \(S\) is the matrix \[ \begin{align} \bP = \bQ_1 \bQ_1^T. \end{align} \] Every orthogonal projector is symmetric (\(\bP^T = \bP\)) and idempotent (\(\bP^2 = \bP\)). The complementary projector \(\bP^\perp = \bI - \bP\) projects onto the orthogonal complement \(S^\perp\).
A square matrix \(\bP\) is the orthogonal projector onto its range if and only if \[ \begin{align} \bP^T=\bP, \qquad \bP^2=\bP. \end{align} \] For such a matrix, every vector has the orthogonal decomposition \[ \begin{align} \bx=\bP\bx+(\bI-\bP)\bx, \end{align} \] with the first term in \(\mathcal{R}(\bP)\) and the second in \(\mathcal{N}(\bP)\).
We prove both directions.
Assume \(\bP^T=\bP\) and \(\bP^2=\bP\). For any \(\bx\), \[ \begin{align} \bx=\bP\bx+(\bI-\bP)\bx. \end{align} \] The first term belongs to the range by definition. The second belongs to the null space because \[ \begin{align} \bP(\bI-\bP)\bx=(\bP-\bP^2)\bx=\bzero. \end{align} \] If \(\by=\bP\bu\) is any range vector and \(\bz\) is any null-space vector, then \[ \begin{align} \by^T\bz=\bu^T\bP^T\bz=\bu^T\bP\bz=0. \end{align} \] Symmetry was needed to replace \(\bP^T\) by \(\bP\). Thus the two components are perpendicular.
For any \(\bs\) in the range, \(\bP\bx-\bs\) also lies in the range. Consequently \[ \begin{align} \|\bx-\bs\|_2^2 =\|(\bI-\bP)\bx\|_2^2+\|\bP\bx-\bs\|_2^2. \end{align} \] The unique minimum occurs at \(\bs=\bP\bx\).
If \(\bP\) is the orthogonal projector onto a subspace with orthonormal basis \(\bQ_1\), then \(\bP=\bQ_1\bQ_1^T\). Direct multiplication gives \[ \begin{align} \bP^T&=(\bQ_1\bQ_1^T)^T=\bQ_1\bQ_1^T=\bP,\\ \bP^2&=\bQ_1(\bQ_1^T\bQ_1)\bQ_1^T=\bQ_1\bQ_1^T=\bP. \end{align} \]
Let \(\bQ\) and \(\widehat{\bQ}\) have orthonormal columns spanning the same subspace. Prove that \(\bQ\bQ^T=\widehat{\bQ}\widehat{\bQ}^T\). Thus projection depends on the subspace, not on the chosen orthonormal basis.
11.6 Further Exercises
An idempotent matrix need not be an orthogonal projector. For \(\bP=\begin{pmatrix}1&1\\0&0\end{pmatrix}\), identify the range and null space, sketch its action, and explain the role of symmetry in the referenced result.
Explain why the condition number of any orthogonal matrix is equal to \(1\). What does this imply about the propagation of errors when applying orthogonal transformations?