✓ Official Syllabus VerifiedStandards & Rigor ↗
8

Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares

📌 Linear Algebra · Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares Core Mastery · 8  ·  Orthogonality & Least Squares

Orthogonality is the central organizing principle of modern computational linear algebra. By decomposing vector spaces into mutually perpendicular subspaces, orthogonality transforms complex matrix inversions into simple inner products, eliminates numerical instability, and powers the Gram–Schmidt process and QR decomposition. Furthermore, orthogonal projections resolve overdetermined, inconsistent linear systems via the method of least squares — the mathematical engine underpinning linear regression, statistical estimation, signal processing, and machine learning.

● Level 1 Foundation — Definition 8.1: Orthogonal & Orthonormal Systems

Let V be an inner product space (such as \( \mathbb{R}^n \) with standard Euclidean inner product \( \langle \mathbf{u}, \mathbf{v} \rangle = \mathbf{u} \cdot \mathbf{v} \)).

  1. Two vectors \( \mathbf{u}, \mathbf{v} \) are orthogonal (denoted \( \mathbf{u} \perp \mathbf{v} \)) if and only if \( \mathbf{u} \cdot \mathbf{v} = 0 \).
  2. A set of vectors \( \mathcal{S} = \{ \mathbf{u}_1, \mathbf{u}_2, \ldots, \mathbf{u}_k \} \) is an orthogonal set if \( \mathbf{u}_i \cdot \mathbf{u}_j = 0 \) whenever \( i \neq j \).
  3. An orthogonal set \( \mathcal{S} \) is orthonormal if every vector has unit length: \[ \mathbf{u}_i \cdot \mathbf{u}_j = \delta_{ij} = \begin{cases} 1 & \text{if } i = j \\ 0 & \text{if } i \neq j \end{cases} \] where \( \delta_{ij} \) is the Kronecker delta.
  4. An orthonormal basis (ONB) for a subspace \( W \) is a basis of \( W \) that is orthonormal.

Orthogonal Fourier Expansion: If \( \{ \mathbf{q}_1, \ldots, \mathbf{q}_n \} \) is an orthonormal basis for \( \mathbb{R}^n \), any vector \( \mathbf{x} \) expands effortlessly without solving a system of equations: \[ \mathbf{x} = (\mathbf{x} \cdot \mathbf{q}_1)\mathbf{q}_1 + (\mathbf{x} \cdot \mathbf{q}_2)\mathbf{q}_2 + \cdot s + (\mathbf{x} \cdot \mathbf{q}_n)\mathbf{q}_n. \]

Least-squares fit minimizing Euclidean residual norm \(\|A\hat{\mathbf{x}} - \mathbf{b}\|_2\).
▲ Level 1 Foundation — Theorem 8.1: Orthogonal Sets are Linearly Independent

If \( \mathcal{S} = \{ \mathbf{v}_1, \mathbf{v}_2, \ldots, \mathbf{v}_k \} \) is an orthogonal set of nonzero vectors in \( \mathbb{R}^n \), then \( \mathcal{S} \) is linearly independent and therefore forms an orthogonal basis for \( \operatorname{span}(\mathcal{S}) \).

Proof of Theorem 8.1

Suppose there exist scalars \( c_1, c_2, \ldots, c_k \) satisfying the linear dependence relation: \[ c_1 \mathbf{v}_1 + c_2 \mathbf{v}_2 + \cdot s + c_k \mathbf{v}_k = \mathbf{0}. \] Select any index \( i \in \{1, 2, \ldots, k\} \) and take the inner product of both sides with \( \mathbf{v}_i \): \[ \left( \sum_{j=1}^k c_j \mathbf{v}_j \right) \cdot \mathbf{v}_i = \mathbf{0} \cdot \mathbf{v}_i = 0. \] Expanding by the bilinearity of the inner product: \[ c_1(\mathbf{v}_1 \cdot \mathbf{v}_i) + \cdot s + c_i(\mathbf{v}_i \cdot \mathbf{v}_i) + \cdot s + c_k(\mathbf{v}_k \cdot \mathbf{v}_i) = 0. \] By mutual orthogonality, every term with \( j \neq i \) vanishes (\( \mathbf{v}_j \cdot \mathbf{v}_i = 0 \)), reducing the equation to: \[ c_i \|\mathbf{v}_i\|^2 = 0. \] Since \( \mathbf{v}_i \neq \mathbf{0} \), the squared Euclidean norm \( \|\mathbf{v}_i\|^2 > 0 \), forcing \( c_i = 0 \). Because this holds identically for every \( i \in \{1, \ldots, k\} \), the only linear combination yielding \( \mathbf{0} \) is the trivial one: \( c_1 = c_2 = \cdot s = c_k = 0 \). Hence, \( \mathcal{S} \) is linearly independent. \( \blacksquare \)

Worked Example 8.A (Level 1) — Coordinates Under Orthonormal Basis
Problem. Verify that the vectors \( \mathbf{q}_1 = \frac{1}{3}\begin{pmatrix} 2 \\ 2 \\ 1 \end{pmatrix} \), \( \mathbf{q}_2 = \frac{1}{3}\begin{pmatrix} -2 \\ 1 \\ 2 \end{pmatrix} \), and \( \mathbf{q}_3 = \frac{1}{3}\begin{pmatrix} 1 \\ -2 \\ 2 \end{pmatrix} \) form an orthonormal basis for \( \mathbb{R}^3 \), and express \( \mathbf{x} = \begin{pmatrix} 9 \\ 0 \\ 0 \end{pmatrix} \) as a linear combination of these basis vectors.
▸ Show step-by-step solution

Step 1: Check orthonormality:
\( \|\mathbf{q}_1\|^2 = \frac{4+4+1}{9} = 1 \), \( \|\mathbf{q}_2\|^2 = \frac{4+1+4}{9} = 1 \), \( \|\mathbf{q}_3\|^2 = \frac{1+4+4}{9} = 1 \).
\( \mathbf{q}_1 \cdot \mathbf{q}_2 = \frac{-4+2+2}{9} = 0 \), \( \mathbf{q}_1 \cdot \mathbf{q}_3 = \frac{2-4+2}{9} = 0 \), \( \mathbf{q}_2 \cdot \mathbf{q}_3 = \frac{-2-2+4}{9} = 0 \).
Since the 3 vectors are orthonormal in \( \mathbb{R}^3 \), they form an orthonormal basis.

Step 2: Coordinate expansion via dot products: \[ c_1 = \mathbf{x} \cdot \mathbf{q}_1 = \begin{pmatrix} 9 \\ 0 \\ 0 \end{pmatrix} \cdot \begin{pmatrix} 2/3 \\ 2/3 \\ 1/3 \end{pmatrix} = 6. \] \[ c_2 = \mathbf{x} \cdot \mathbf{q}_2 = \begin{pmatrix} 9 \\ 0 \\ 0 \end{pmatrix} \cdot \begin{pmatrix} -2/3 \\ 1/3 \\ 2/3 \end{pmatrix} = -6. \] \[ c_3 = \mathbf{x} \cdot \mathbf{q}_3 = \begin{pmatrix} 9 \\ 0 \\ 0 \end{pmatrix} \cdot \begin{pmatrix} 1/3 \\ -2/3 \\ 2/3 \end{pmatrix} = 3. \] Therefore, \( \mathbf{x} = 6\mathbf{q}_1 - 6\mathbf{q}_2 + 3\mathbf{q}_3 \). Notice that this required zero Gaussian elimination!

● Level 2 Analytical Application — Definition 8.2: Gram–Schmidt & QR Decomposition

The Gram–Schmidt Orthogonalization Process: Given a linearly independent set of vectors \( \{ \mathbf{x}_1, \mathbf{x}_2, \ldots, \mathbf{x}_p \} \) in \( \mathbb{R}^n \), the Gram–Schmidt algorithm constructs an orthogonal basis \( \{ \mathbf{v}_1, \mathbf{v}_2, \ldots, \mathbf{v}_p \} \) for the same subspace via sequential orthogonal projections: \[ \begin{aligned} \mathbf{v}_1 &= \mathbf{x}_1, \\ \mathbf{v}_2 &= \mathbf{x}_2 - \frac{\mathbf{x}_2 \cdot \mathbf{v}_1}{\mathbf{v}_1 \cdot \mathbf{v}_1} \mathbf{v}_1, \\ \mathbf{v}_3 &= \mathbf{x}_3 - \frac{\mathbf{x}_3 \cdot \mathbf{v}_1}{\mathbf{v}_1 \cdot \mathbf{v}_1} \mathbf{v}_1 - \frac{\mathbf{x}_3 \cdot \mathbf{v}_2}{\mathbf{v}_2 \cdot \mathbf{v}_2} \mathbf{v}_2, \\ &\;\vdots \\ \mathbf{v}_p &= \mathbf{x}_p - \sum_{j=1}^{p-1} \frac{\mathbf{x}_p \cdot \mathbf{v}_j}{\mathbf{v}_j \cdot \mathbf{v}_j} \mathbf{v}_j. \end{aligned} \] Normalizing yields an orthonormal basis: \( \mathbf{q}_i = \frac{\mathbf{v}_i}{\|\mathbf{v}_i\|} \) for each \( i = 1, \ldots, p \).

The \( QR \) Decomposition: If \( A \) is an \( m \times n \) matrix with linearly independent columns, then \( A \) can be factored uniquely as: \[ A = Q R \] where \( Q \) is an \( m \times n \) matrix whose columns form an orthonormal basis for \( \operatorname{Col}(A) \) (satisfying \( Q^T Q = I_n \)), and \( R \) is an \( n \times n \) upper triangular invertible matrix with positive diagonal entries: \[ R = Q^T A = \begin{pmatrix} \|\mathbf{v}_1\| & \mathbf{q}_1 \cdot \mathbf{x}_2 & \mathbf{q}_1 \cdot \mathbf{x}_3 & \cdot s \\ 0 & \|\mathbf{v}_2\| & \mathbf{q}_2 \cdot \mathbf{x}_3 & \cdot s \\ 0 & 0 & \|\mathbf{v}_3\| & \cdot s \\ \vdots & \vdots & \vdots & \ddots \end{pmatrix}. \]

▲ Level 2 Analytical Application — Theorem 8.2: Properties of Orthogonal Matrices

A square matrix \( Q \in \mathbb{R}^{n \times n} \) is called an orthogonal matrix if its columns form an orthonormal basis for \( \mathbb{R}^n \). The following conditions are strictly equivalent:

  1. \( Q^T Q = Q Q^T = I_n \) (hence \( Q^{-1} = Q^T \)).
  2. \( \|Q\mathbf{x}\| = \|\mathbf{x}\| \) for all \( \mathbf{x} \in \mathbb{R}^n \) (isometry: preserves lengths).
  3. \( (Q\mathbf{x}) \cdot (Q\mathbf{y}) = \mathbf{x} \cdot \mathbf{y} \) for all \( \mathbf{x}, \mathbf{y} \in \mathbb{R}^n \) (preserves angles and inner products).
  4. \( \det(Q) = \pm 1 \) (since \( \det(Q^T Q) = (\det Q)^2 = \det(I_n) = 1 \)).
Worked Example 8.B (Level 2) — Gram–Schmidt & QR Factorization
Problem. Apply the Gram–Schmidt process to find the \( QR \) factorization of: \[ A = \begin{pmatrix} 1 & 1 \\ 1 & 0 \\ 0 & 1 \end{pmatrix}. \]
▸ Show step-by-step solution

Step 1: Orthogonalize columns \( \mathbf{x}_1 = (1, 1, 0)^T \) and \( \mathbf{x}_2 = (1, 0, 1)^T \):
First vector: \( \mathbf{v}_1 = \mathbf{x}_1 = \begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix} \).
Second vector: subtract projection of \( \mathbf{x}_2 \) onto \( \mathbf{v}_1 \): \[ \mathbf{x}_2 \cdot \mathbf{v}_1 = 1(1) + 0(1) + 1(0) = 1, \quad \|\mathbf{v}_1\|^2 = 1^2 + 1^2 + 0^2 = 2. \] \[ \mathbf{v}_2 = \mathbf{x}_2 - \frac{1}{2}\mathbf{v}_1 = \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix} - \begin{pmatrix} 1/2 \\ 1/2 \\ 0 \end{pmatrix} = \begin{pmatrix} 1/2 \\ -1/2 \\ 1 \end{pmatrix}. \] Check orthogonality: \( \mathbf{v}_1 \cdot \mathbf{v}_2 = 1(1/2) + 1(-1/2) + 0(1) = 0 \). ✓

Step 2: Normalize to construct \( Q \):
\( \|\mathbf{v}_1\| = \sqrt{2} \implies \mathbf{q}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 1 \\ 0 \end{pmatrix} \).
\( \|\mathbf{v}_2\| = \sqrt{(1/2)^2 + (-1/2)^2 + 1^2} = \sqrt{1/4 + 1/4 + 1} = \sqrt{3/2} = \frac{\sqrt{6}}{2} \).
\( \mathbf{q}_2 = \frac{2}{\sqrt{6}}\begin{pmatrix} 1/2 \\ -1/2 \\ 1 \end{pmatrix} = \frac{1}{\sqrt{6}}\begin{pmatrix} 1 \\ -1 \\ 2 \end{pmatrix} \).
Therefore: \[ Q = \begin{pmatrix} 1/\sqrt{2} & 1/\sqrt{6} \\ 1/\sqrt{2} & -1/\sqrt{6} \\ 0 & 2/\sqrt{6} \end{pmatrix}. \]

Step 3: Compute \( R = Q^T A \): \[ R = \begin{pmatrix} \|\mathbf{v}_1\| & \mathbf{q}_1 \cdot \mathbf{x}_2 \\ 0 & \|\mathbf{v}_2\| \end{pmatrix} = \begin{pmatrix} \sqrt{2} & 1/\sqrt{2} \\ 0 & \sqrt{3/2} \end{pmatrix}. \] Checking product \( QR \): \[ QR = \begin{pmatrix} 1/\sqrt{2} & 1/\sqrt{6} \\ 1/\sqrt{2} & -1/\sqrt{6} \\ 0 & 2/\sqrt{6} \end{pmatrix} \begin{pmatrix} \sqrt{2} & 1/\sqrt{2} \\ 0 & \sqrt{3/2} \end{pmatrix} = \begin{pmatrix} 1 & 1/2 + 1/2 \\ 1 & 1/2 - 1/2 \\ 0 & 2(1/2) \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 1 & 0 \\ 0 & 1 \end{pmatrix} = A. \quad \text{\checkmark } \]

● Level 3 University Rigor — Definition 8.3: Orthogonal Projections & Least Squares

Orthogonal Projection Matrix: Let \( W \) be a subspace of \( \mathbb{R}^m \) spanned by the linearly independent columns of an \( m \times n \) matrix \( A \) (where \( m \ge n \)). The orthogonal projection matrix \( P \) that maps any vector \( \mathbf{b} \in \mathbb{R}^m \) to its closest point \( \hat{\mathbf{b}} = \operatorname{proj}_W(\mathbf{b}) \in W \) is given by: \[ P = A (A^T A)^{-1} A^T. \] \( P \) satisfies two algebraic hallmarks of orthogonal projectors:

  1. Idempotence: \( P^2 = P \) (projecting an already projected vector changes nothing).
  2. Symmetry: \( P^T = P \) (guaranteeing orthogonality of the projection).

The Least-Squares Problem: For an inconsistent system \( A\mathbf{x} = \mathbf{b} \), no vector \( \mathbf{x} \) achieves \( A\mathbf{x} = \mathbf{b} \). The least-squares solution \( \hat{\mathbf{x}} \) minimizes the Euclidean distance \( \|A\mathbf{x} - \mathbf{b}\| \), which is equivalent to finding \( \hat{\mathbf{x}} \) such that: \[ A\hat{\mathbf{x}} = \operatorname{proj}_{\operatorname{Col}(A)}(\mathbf{b}). \]

▲ Level 3 University Rigor — Theorem 8.3: Derivation of the Normal Equations

Let \( A \in \mathbb{R}^{m \times n} \) and \( \mathbf{b} \in \mathbb{R}^m \). A vector \( \hat{\mathbf{x}} \in \mathbb{R}^n \) minimizes \( \|A\mathbf{x} - \mathbf{b}\|^2 \) if and only if \( \hat{\mathbf{x}} \) satisfies the normal equations: \[ A^T A \hat{\mathbf{x}} = A^T \mathbf{b}. \] If \( A \) has full column rank (\( \operatorname{rank}(A) = n \)), then \( A^T A \) is strictly positive definite and invertible, yielding the unique least-squares solution: \[ \hat{\mathbf{x}} = (A^T A)^{-1} A^T \mathbf{b}. \]

Proof of Theorem 8.3 (Orthogonal Decomposition & Calculus)

Geometric Derivation: By the Best Approximation Theorem, the vector in \( \operatorname{Col}(A) \) closest to \( \mathbf{b} \) is the orthogonal projection \( \hat{\mathbf{b}} = A\hat{\mathbf{x}} \). The error vector (residual) is \( \mathbf{e} = \mathbf{b} - A\hat{\mathbf{x}} \).
By the definition of orthogonal projection, \( \mathbf{e} \) must be orthogonal to every vector in the subspace \( \operatorname{Col}(A) \). In particular, \( \mathbf{e} \) is perpendicular to each column of \( A \): \[ \mathbf{a}_j \cdot (\mathbf{b} - A\hat{\mathbf{x}}) = 0 \quad \text{for each } j = 1, 2, \ldots, n. \] In matrix notation, this condition is written compactly as: \[ A^T (\mathbf{b} - A\hat{\mathbf{x}}) = \mathbf{0} \iff A^T \mathbf{b} - A^T A \hat{\mathbf{x}} = \mathbf{0} \iff A^T A \hat{\mathbf{x}} = A^T \mathbf{b}. \]

Alternative Multivariable Calculus Derivation: Define the objective loss function \( f(\mathbf{x}) = \|A\mathbf{x} - \mathbf{b}\|^2 = (A\mathbf{x} - \mathbf{b})^T (A\mathbf{x} - \mathbf{b}) = \mathbf{x}^T A^T A \mathbf{x} - 2\mathbf{b}^T A\mathbf{x} + \mathbf{b}^T\mathbf{b} \). Taking the matrix gradient with respect to \( \mathbf{x} \) and setting it to zero: \[ \nabla_\mathbf{x} f(\mathbf{x}) = 2 A^T A \mathbf{x} - 2 A^T \mathbf{b} = \mathbf{0} \implies A^T A \hat{\mathbf{x}} = A^T \mathbf{b}. \] Since the Hessian matrix is \( \nabla^2 f(\mathbf{x}) = 2 A^T A \), which is positive semi-definite (and strictly positive definite when \( \operatorname{rank}(A) = n \)), the stationary point \( \hat{\mathbf{x}} \) is a global minimum. \( \blacksquare \)

▲ Level 3 University Rigor — Theorem 8.4: The Spectral Theorem for Symmetric Matrices

Let \( A \) be an \( n \times n \) real matrix. Then \( A \) is orthogonally diagonalizable (i.e., there exists an orthogonal matrix \( Q \) such that \( A = Q D Q^T \) with \( D \) diagonal) if and only if \( A \) is symmetric (\( A = A^T \)).

Consequences:

  1. All eigenvalues of a real symmetric matrix are strictly real (never complex).
  2. Eigenvectors corresponding to distinct eigenvalues are mutually orthogonal: \( \lambda_i \neq \lambda_j \implies \mathbf{v}_i \cdot \mathbf{v}_j = 0 \).
  3. For every eigenvalue, its geometric multiplicity equals its algebraic multiplicity (symmetric matrices are never defective).
Worked Example 8.C (Level 3) — Least Squares via QR Decomposition
Problem. Solve the least-squares problem \( A\mathbf{x} \approx \mathbf{b} \) using the \( QR \) decomposition of \( A \) from Worked Example 8.B, where \( \mathbf{b} = \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix} \).
▸ Show step-by-step solution

Theory: When \( A = QR \), the normal equations become: \[ A^T A \hat{\mathbf{x}} = A^T \mathbf{b} \iff (QR)^T (QR) \hat{\mathbf{x}} = (QR)^T \mathbf{b} \iff R^T (Q^T Q) R \hat{\mathbf{x}} = R^T Q^T \mathbf{b}. \] Since \( Q^T Q = I_n \), this simplifies to \( R^T R \hat{\mathbf{x}} = R^T Q^T \mathbf{b} \). Since \( R \) is invertible, multiplying both sides by \( (R^T)^{-1} \) yields the elegant system: \[ R \hat{\mathbf{x}} = Q^T \mathbf{b}. \] This eliminates the need to compute \( A^T A \) or its matrix inverse!

Step 1: Compute \( Q^T \mathbf{b} \): \[ Q^T \mathbf{b} = \begin{pmatrix} 1/\sqrt{2} & 1/\sqrt{2} & 0 \\ 1/\sqrt{6} & -1/\sqrt{6} & 2/\sqrt{6} \end{pmatrix} \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix} = \begin{pmatrix} (2+3)/\sqrt{2} \\ (2-3+2)/\sqrt{6} \end{pmatrix} = \begin{pmatrix} 5/\sqrt{2} \\ 1/\sqrt{6} \end{pmatrix}. \]

Step 2: Solve upper triangular system \( R\hat{\mathbf{x}} = Q^T\mathbf{b} \) via back-substitution: \[ \begin{pmatrix} \sqrt{2} & 1/\sqrt{2} \\ 0 & \sqrt{3/2} \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \end{pmatrix} = \begin{pmatrix} 5/\sqrt{2} \\ 1/\sqrt{6} \end{pmatrix}. \] From row 2: \[ \sqrt{\frac{3}{2}} \hat{x}_2 = \frac{1}{\sqrt{6}} \implies \hat{x}_2 = \frac{1}{\sqrt{6}} \cdot \frac{\sqrt{2}}{\sqrt{3}} = \frac{1}{3}. \] From row 1: \[ \sqrt{2}\hat{x}_1 + \frac{1}{\sqrt{2}}\left(\frac{1}{3}\right) = \frac{5}{\sqrt{2}} \implies 2\hat{x}_1 + \frac{1}{3} = 5 \implies 2\hat{x}_1 = \frac{14}{3} \implies \hat{x}_1 = \frac{7}{3}. \] Therefore, \( \hat{\mathbf{x}} = \begin{pmatrix} 7/3 \\ 1/3 \end{pmatrix} \).

⊙ Explorer · Least squares — minimizing the sum of squared residuals
interactive
sum of squared residuals\(6.000\)
least-squares optimum\(m = 1.6, b = -0.5\)

The four points are \((1,1)\), \((2,3)\), \((3,4)\), \((4,6)\) — Worked example 8.B's data. The dashed vertical segments are each point's residual (actual − predicted); the readout is the sum of their squares, exactly the quantity being minimized. Drag \(m\) and \(b\) toward the stated optimum and watch the sum of squared residuals bottom out — it can't go any lower for any other line, which is exactly what solving the normal equations guarantees.

⚠️ Common Traps & University Pitfalls — Orthogonality & Least Squares
  • Gram–Schmidt Projection Target: When subtracting projections in Gram–Schmidt to form \( \mathbf{v}_k \), you must project \( \mathbf{x}_k \) onto the already orthogonalized vectors \( \mathbf{v}_1, \ldots, \mathbf{v}_{k-1} \), NOT onto the original input vectors \( \mathbf{x}_1, \ldots, \mathbf{x}_{k-1} \). Projecting onto non-orthogonal vectors destroys mutual orthogonality completely.
  • Order of \( Q \) and \( Q^T \): For an \( m \times n \) matrix \( Q \) with orthonormal columns (where \( m > n \)), \( Q^T Q = I_n \), but \( Q Q^T \neq I_m \). In fact, \( Q Q^T = P \) is the \( m \times m \) orthogonal projector onto \( \operatorname{Col}(Q) \). Only square orthogonal matrices have \( Q Q^T = I \).
  • Singularity of \( A^T A \): The normal equations have a unique solution if and only if the columns of \( A \) are linearly independent. If \( A \) has multicollinear columns (rank \( < n \)), \( A^T A \) is singular, and regularized least squares (Ridge / Tikhonov regression: \( (A^T A + \lambda I)\hat{\mathbf{x}} = A^T \mathbf{b} \)) or pseudoinverse methods are required.
  • Residual Orthogonality Direction: The residual error vector \( \mathbf{e} = \mathbf{b} - A\hat{\mathbf{x}} \) is orthogonal to the column space \( \operatorname{Col}(A) \) (so \( A^T \mathbf{e} = \mathbf{0} \)). It is NOT orthogonal to \( \mathbf{b} \). Confusing \( \mathbf{e} \perp \operatorname{Col}(A) \) with \( \mathbf{e} \perp \mathbf{b} \) is a frequent conceptual exam blunder.
Orthogonal Projection
\( \operatorname{proj}_{\mathbf{a}}(\mathbf{b}) = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{a} \cdot \mathbf{a}} \mathbf{a} \)
Gram–Schmidt
\( \mathbf{v}_k = \mathbf{x}_k - \sum_{j=1}^{k-1} \frac{\mathbf{x}_k \cdot \mathbf{v}_j}{\|\mathbf{v}_j\|^2} \mathbf{v}_j \)
QR Least Squares
\( R\hat{\mathbf{x}} = Q^T\mathbf{b} \)
Normal Equations
\( A^T A \hat{\mathbf{x}} = A^T \mathbf{b} \)
Orthogonal projection of \( \mathbf{y} = \langle 3, 4 \rangle \) onto the subspace \( L = \text{span}\{\langle 2, 1 \rangle\} \). The projection \( \hat{\mathbf{y}} = \langle 4, 2 \rangle \) minimizes the distance to \( \mathbf{y} \), ensuring the error vector \( \mathbf{z} = \mathbf{y} - \hat{\mathbf{y}} = \langle -1, 2 \rangle \) is perpendicular to \( L \).
Practice Problem (Level 1) — Orthogonal Projection & Residual

Find the orthogonal projection of \( \mathbf{b}=(4,3)^T \) onto \( \mathbf{a}=(1,2)^T \), and verify the residual is orthogonal to \( \mathbf{a} \).

Show solution

\( \mathbf{a}\cdot\mathbf{b}=1(4)+2(3)=10 \), \( \mathbf{a}\cdot\mathbf{a}=1^2+2^2=5 \). \[ \operatorname{proj}_{\mathbf{a}}(\mathbf{b})=\frac{10}{5}\begin{pmatrix} 1 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 4 \end{pmatrix}. \]

The residual vector is \( \mathbf{e} = \mathbf{b} - \operatorname{proj}_{\mathbf{a}}(\mathbf{b}) = \begin{pmatrix} 4 \\ 3 \end{pmatrix} - \begin{pmatrix} 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 2 \\ -1 \end{pmatrix} \).
Check inner product: \( \mathbf{a} \cdot \mathbf{e} = 1(2) + 2(-1) = 2 - 2 = 0 \). Orthogonal, as guaranteed.

Worked Example  ·  Checking Orthonormality

Is \( \left\{ \begin{pmatrix} 1/\sqrt{2} \\ 1/\sqrt{2} \end{pmatrix}, \begin{pmatrix} 1/\sqrt{2} \\ -1/\sqrt{2} \end{pmatrix} \right\} \) orthonormal?

Solution: Inner product: \( \frac{1}{2} - \frac{1}{2} = 0 \) — orthogonal. Each vector norm: \( \sqrt{1/2 + 1/2} = 1 \). Yes, orthonormal.

Worked Example  ·  Distance to Subspace via Projection

Find the distance from \( \mathbf{b}=(3,4)^T \) to the line through the origin spanned by \( \mathbf{a}=(1,0)^T \).

Solution: \( \operatorname{proj}_{\mathbf{a}}(\mathbf{b}) = \frac{3}{1}(1,0)^T = (3,0)^T \). Residual \( \mathbf{e} = (3,4)^T - (3,0)^T = (0,4)^T \).
Perpendicular distance: \( \|\mathbf{e}\| = \|(0,4)^T\| = 4 \).

Worked Example \(D\) — Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares (Hard Application)
Problem. Consider the matrix \( A = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix} \). Let \( \mathbf{b} = \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} \). We want to find the vector \( \hat{\mathbf{x}} \) that minimizes \( \lVert A\mathbf{x} - \mathbf{b} \rVert \). This is equivalent to finding the projection of \( \mathbf{b} \) onto the column space of \( A \), denoted by \( \text{Col}(A) \). The normal equations for this least squares problem are \( A^T A \mathbf{x} = A^T \mathbf{b} \). The unique solution \( \hat{\mathbf{x}} \) to the normal equations yields the best approximate solution. Calculate the value of \( \hat{\mathbf{x}}_1 \), the first component of \( \hat{\mathbf{x}} \).
▸ Show step-by-step solution

The normal equations are given by \( A^T A \mathbf{x} = A^T \mathbf{b} \). First, we compute \( A^T A \) and \( A^T \mathbf{b} \). \\ \( A^T = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix} \) \\ \( A^T A = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix} \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix} = \begin{pmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{pmatrix} \) \\ \( A^T \mathbf{b} = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \\ 2 \end{pmatrix} \) \\ So, we need to solve the system: \( \begin{pmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{pmatrix} \hat{\mathbf{x}} = \begin{pmatrix} 2 \\ 2 \\ 2 \end{pmatrix} \) \\ From the symmetry of the matrix \( A^T A \) and the vector \( A^T \mathbf{b} \), it is clear that \( \hat{\mathbf{x}} = \begin{pmatrix} c \\ c \\ c \end{pmatrix} \) for some constant \( c \). Substituting this into the first row of the system: \( 2c + 1c + 1c = 2 \\ 4c = 2 \\ c = \frac{1}{2} \) \\ Thus, \( \hat{\mathbf{x}} = \begin{pmatrix} 1/2 \\ 1/2 \\ 1/2 \end{pmatrix} \). The first component of \( \hat{\mathbf{x}} \) is \( \hat{\mathbf{x}}_1 = 1/2 \).

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares)
Common Student TrapWhy It Fails MathematicallyCorrect Exam-Board Method
Computing angle at \(B\) using \(\overrightarrow{AB}\cdot\overrightarrow{BC}\)Vectors are head-to-tail instead of tail-to-tail, giving \(180^\circ - \theta\).Reverse \(\overrightarrow{AB}\) so both emanate from \(B\): use \(\overrightarrow{BA}\cdot\overrightarrow{BC}\).
Using the same parameter \(t\) for two intersecting 3D lines \(\mathbf{r}_1(t) = \mathbf{r}_2(t)\)Tests for a simultaneous collision at time \(t\) rather than geometric intersection of paths.Assign distinct parameters \(\lambda\) and \(\mu\) to the two lines before equating components.
Assuming \((AB)^{-1} = A^{-1}B^{-1}\)Multiplying \((AB)(A^{-1}B^{-1})\) does not cancel inner factors when \(AB \ne BA\).Use the shoe-sock reversal law: \((AB)^{-1} = B^{-1}A^{-1}\).
▲ Exam Pacing & Verification Strategy — Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares

Fast Matrix & Vector Verification (University Linear Algebra & Matrix Theory): Check every \(2\times 2\) or \(3\times 3\) eigenvalue computation using the trace and determinant invariants: \(\sum \lambda_i = \operatorname{tr}(A)\) (sum of diagonal entries) and \(\prod \lambda_i = \det(A)\).

Find the least-squares solution \( \hat{\mathbf{x}} \) to the inconsistent system \( A\mathbf{x} = \mathbf{b} \), where \[ A = \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix}, \qquad \mathbf{b} = \begin{pmatrix} 1 \\ 2 \\ 4 \end{pmatrix}. \]
💡 Hint 1 of 3
Set up normal equations \( A^T A \hat{\mathbf{x}} = A^T \mathbf{b} \): \(A^T A = \begin{pmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \end{pmatrix} \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix}\).
💡 Hint 2 of 3
Rewrite and simplify to obtain: \(A^T \mathbf{b} = \begin{pmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \end{pmatrix} \begin{pmatrix} 1 \\ 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 7 \\ 17 \end{pmatrix}\) Invert \( A^T A \) and solve: \(\det(A^T A) = 3(14) - 6(6) = 42 - 36\).
💡 Hint 3 of 3
Use the resulting form to finish: \(\hat{x} = \frac{1}{6}\begin{pmatrix} 14 & -6 \\ -6 & 3 \end{pmatrix} \begin{pmatrix} 7 \\ 17 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} 98 - 102 \\ -42 + 51 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} -4 \\ 9 \end{pmatrix}\).

Step 1: Set up normal equations \( A^T A \hat{\mathbf{x}} = A^T \mathbf{b} \):

\[ A^T A = \begin{pmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \end{pmatrix} \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix} = \begin{pmatrix} 3 & 6 \\ 6 & 14 \end{pmatrix}. \]\[ A^T \mathbf{b} = \begin{pmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \end{pmatrix} \begin{pmatrix} 1 \\ 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 7 \\ 17 \end{pmatrix}. \]

Step 2: Invert \( A^T A \) and solve: \[ \det(A^T A) = 3(14) - 6(6) = 42 - 36 = 6. \] \[ (A^T A)^{-1} = \frac{1}{6}\begin{pmatrix} 14 & -6 \\ -6 & 3 \end{pmatrix}. \] \[ \hat{\mathbf{x}} = \frac{1}{6}\begin{pmatrix} 14 & -6 \\ -6 & 3 \end{pmatrix} \begin{pmatrix} 7 \\ 17 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} 98 - 102 \\ -42 + 51 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} -4 \\ 9 \end{pmatrix} = \begin{pmatrix} -2/3 \\ 3/2 \end{pmatrix}. \]

[Practice 2 · Easy] Consider two vectors \( \mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix} \) and \( \mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix} \). What is the dot product \( \mathbf{v}_1 \cdot \mathbf{v}_2 \)?
💡 Hint 1 of 3
The dot product of two vectors \(\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix}\) and \(\mathbf{v}_2 = \begin{pmatrix} c \\ d \end{pmatrix}\) is given by \(\mathbf{v}_1 \cdot \mathbf{v}_2 = ac + bd\).
💡 Hint 2 of 3
In this case, \(\mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix}\) and \(\mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix}\). \(\text{Therefore, } \mathbf{v}_1 \cdot \mathbf{v}_2 = (3)(-4) + (4)(3) = -12 + 12\).
💡 Hint 3 of 3
A dot product of 0 indicates that the vectors are orthogonal.
\( \text{The dot product of two vectors } \mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix} \text{ and } \mathbf{v}_2 = \begin{pmatrix} c \\ d \end{pmatrix} \text{ is given by } \mathbf{v}_1 \cdot \mathbf{v}_2 = ac + bd. \) \( \text{In this case, } \mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix} \text{ and } \mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix}. \) \( \text{Therefore, } \mathbf{v}_1 \cdot \mathbf{v}_2 = (3)(-4) + (4)(3) = -12 + 12 = 0. \) \( \text{A dot product of 0 indicates that the vectors are orthogonal.} \)
[Practice 3 · Medium] Consider the matrix \( A = \begin{pmatrix} 1 & 2 \\ -2 & k \end{pmatrix} \). If the column vectors of \( A \) are orthogonal, find the value of \( k \).
💡 Hint 1 of 3
Let the column vectors of matrix \( A \) be \( \mathbf{v}_1 = \begin{pmatrix} 1 \\ -2 \end{pmatrix} \) and \( \mathbf{v}_2 = \begin{pmatrix} 2 \\ k \end{pmatrix} \).
💡 Hint 2 of 3
For the column vectors to be orthogonal, their dot product must be zero. \( \mathbf{v}_1 \cdot \mathbf{v}_2 = 0 \) \( (1)(2) + (-2)(k) = 0 \).
💡 Hint 3 of 3
Use the resulting form to finish: \(2 - 2k\).
Let the column vectors of matrix \( A \) be \( \mathbf{v}_1 = \begin{pmatrix} 1 \\ -2 \end{pmatrix} \) and \( \mathbf{v}_2 = \begin{pmatrix} 2 \\ k \end{pmatrix} \). For the column vectors to be orthogonal, their dot product must be zero. \( \mathbf{v}_1 \cdot \mathbf{v}_2 = 0 \) \( (1)(2) + (-2)(k) = 0 \) \( 2 - 2k = 0 \) \( 2k = 2 \) \( k = 1 \).
[Practice 4 · Hard] Consider the matrix \( A = \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \). Let \( \mathbf{v} = \begin{pmatrix} 3 \\ 1 \end{pmatrix} \). Suppose we want to find the vector \( \mathbf{x} \) of the form \( c_1 \mathbf{a}_1 + c_2 \mathbf{a}_2 \) where \( \{\mathbf{a}_1, \mathbf{a}_2\} \) is an orthogonal basis derived from the columns of \( A \), such that \( \| \mathbf{v} - \mathbf{x} \| \) is minimized. Find the value of \( \| \mathbf{x} \| \).
💡 Hint 1 of 3
The columns of matrix A are \( \mathbf{c}_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix} \) and \( \mathbf{c}_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix} \).
💡 Hint 2 of 3
This set of vectors is already orthogonal since \( \mathbf{c}_1 \cdot \mathbf{c}_2 = (1)(1) + (1)(-1) = 0 \). Thus, \( \{\mathbf{a}_1, \mathbf{a}_2\} = \{\mathbf{c}_1, \mathbf{c}_2\} \) is an orthogonal basis.
💡 Hint 3 of 3
The norm of \(x\) is \(\| x \| = \| v \| = \sqrt{3^2 + 1^2} = \sqrt{9 + 1}\).
The columns of matrix A are \( \mathbf{c}_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix} \) and \( \mathbf{c}_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix} \). This set of vectors is already orthogonal since \( \mathbf{c}_1 \cdot \mathbf{c}_2 = (1)(1) + (1)(-1) = 0 \). Thus, \( \{\mathbf{a}_1, \mathbf{a}_2\} = \{\mathbf{c}_1, \mathbf{c}_2\} \) is an orthogonal basis. The problem asks to find the projection of \( \mathbf{v} \) onto the subspace spanned by \( \mathbf{a}_1 \) and \( \mathbf{a}_2 \), which is the entire \( \mathbb{R}^2 \) in this case, as \( \{\mathbf{a}_1, \mathbf{a}_2\} \) forms a basis for \( \mathbb{R}^2 \). Therefore, the vector \( \mathbf{x} \) that minimizes \( \| \mathbf{v} - \mathbf{x} \| \) is simply \( \mathbf{v} \) itself, as \( \mathbf{v} \) is already in the span of \( \mathbf{a}_1 \) and \( \mathbf{a}_2 \). So, \( \mathbf{x} = \mathbf{v} = \begin{pmatrix} 3 \\ 1 \end{pmatrix} \). The norm of \( \mathbf{x} \) is \( \| \mathbf{x} \| = \| \mathbf{v} \| = \sqrt{3^2 + 1^2} = \sqrt{9 + 1} = \sqrt{10} \).
Consider two vectors \( \mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix} \) and \( \mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix} \). What is the dot product \( \mathbf{v}_1 \cdot \mathbf{v}_2 \)?
💡 Hint 1 of 3
The dot product of two vectors \(\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix}\) and \(\mathbf{v}_2 = \begin{pmatrix} c \\ d \end{pmatrix}\) is given by \(\mathbf{v}_1 \cdot \mathbf{v}_2 = ac + bd\).
💡 Hint 2 of 3
In this case, \(\mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix}\) and \(\mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix}\). \(\text{Therefore, } \mathbf{v}_1 \cdot \mathbf{v}_2 = (3)(-4) + (4)(3) = -12 + 12\).
💡 Hint 3 of 3
A dot product of 0 indicates that the vectors are orthogonal.
\( \text{The dot product of two vectors } \mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix} \text{ and } \mathbf{v}_2 = \begin{pmatrix} c \\ d \end{pmatrix} \text{ is given by } \mathbf{v}_1 \cdot \mathbf{v}_2 = ac + bd. \) \( \text{In this case, } \mathbf{v}_1 = \begin{pmatrix} 3 \\ 4 \end{pmatrix} \text{ and } \mathbf{v}_2 = \begin{pmatrix} -4 \\ 3 \end{pmatrix}. \) \( \text{Therefore, } \mathbf{v}_1 \cdot \mathbf{v}_2 = (3)(-4) + (4)(3) = -12 + 12 = 0. \) \( \text{A dot product of 0 indicates that the vectors are orthogonal.} \)

Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares — 6-Mark Structured Problem

6 pts No Calculator
For Orthogonality, Gram–Schmidt, QR Decomposition & Least Squares, examine the quadratic-rate model \(f(x) = 4x^2 - 4x + 1\) on \(x \in [0, 3]\).
  1. (a)2 pts
    Compute \(f(0)\) and \(f(2)\).
    Scoring Guideline & Justification
    • [M1] Substitutes x=0 and x=2 (1 pt)
    • [A1] Obtains 1 and 9 (1 pt)
  2. (b)2 pts
    Find the derivative/rate \(f'(x)\) and critical point \(x_c\).
    Scoring Guideline & Justification
    • [M1] Differentiates to 8x - 4 (1 pt)
    • [A1] Solves x_c = 4/8 (1 pt)
  3. (c)2 pts
    Calculate the average rate of change from \(x = 0\) to \(x = 2\).
    Scoring Guideline & Justification
    • [M1] Applies (f(2) - f(0)) / 2 (1 pt)
    • [A1] Evaluates 4 (1 pt)
Complete Worked Solution
(a) \(f(0)=1, f(2)=9\). (b) \(f'(x)=8x-4 \implies x_c = \frac{4}{8}\). (c) Average rate \(= \frac{8}{2} = 4\).
📝 Chapter Quiz