Orthogonal Projections and the Gram-Schmidt Process
Before Projection uses the dot product, a basis of the subspace, and independence. Builds on: Inner Products, Length, and Orthogonality · Null Space, Column Space, and Basis · Linear Independence
Next The closest point is the idea behind least squares, the method that finds a line of best fit.
Before You Start: Prerequisite Check
Can you do these? (Click to reveal self-test)
Test yourself on these prerequisite skills:
Dot product: Compute $\begin{pmatrix}3\\1\\-2\end{pmatrix} \cdot \begin{pmatrix}1\\2\\3\end{pmatrix}$.
Check
$3(1)+1(2)+(-2)(3) = 3+2-6 = -1$.
Orthogonality: Is $\begin{pmatrix}1\\2\end{pmatrix}$ orthogonal to $\begin{pmatrix}2\\-1\end{pmatrix}$?
Check
$1(2)+2(-1) = 0$. Yes, orthogonal.
Basis: What is the definition of a basis for a subspace?
Check
A linearly independent set that spans the subspace. Every vector in the subspace is a unique linear combination of the basis vectors.
If you struggled: Review Inner Products, Length, and Orthogonality.
Try This First
Find the closest point on the line $\text{Span}\left\{\begin{pmatrix}1\\2\end{pmatrix}\right\}$ to the point $\mathbf{y} = \begin{pmatrix}3\\1\end{pmatrix}$.
Before computing: draw a sketch. The closest point is the foot of the perpendicular from $\mathbf{y}$ to the line.
Show Solution
The closest point on $\text{Span}\left\{\mathbf{u}\right\}$ to $\mathbf{y}$ is the projection of $\mathbf{y}$ onto $\mathbf{u}$:
\[ \hat{\mathbf{y}} = \frac{\mathbf{y} \cdot \mathbf{u}}{\mathbf{u} \cdot \mathbf{u}}\mathbf{u} = \frac{3(1)+1(2)}{1+4}\begin{pmatrix}1\\2\end{pmatrix} = \frac{5}{5}\begin{pmatrix}1\\2\end{pmatrix} = \begin{pmatrix}1\\2\end{pmatrix} \]
The closest point is $\begin{pmatrix}1\\2\end{pmatrix}$.
Verify: the error vector is $\mathbf{y} - \hat{\mathbf{y}} = \begin{pmatrix}2\\-1\end{pmatrix}$. Check orthogonality with $\mathbf{u} = \begin{pmatrix}1\\2\end{pmatrix}$: $(2)(1)+(-1)(2) = 0$. The error is perpendicular to the line.
The Projection Idea
The projection of $\mathbf{y}$ onto a subspace $W$ gives the point in $W$ that is closest to $\mathbf{y}$. The “leftover,” $\mathbf{y} - \hat{\mathbf{y}}$, is always orthogonal to $W$.
This decomposition $\mathbf{y} = \hat{\mathbf{y}} + (\mathbf{y} - \hat{\mathbf{y}})$ separates $\mathbf{y}$ into a part inside $W$ and a part perpendicular to $W$, and it generalizes the familiar idea of dropping a perpendicular from a point to a line.
Prerequisite Map
Quick Reference
| Property | Value |
|---|---|
| Course | MATH 231 |
| Difficulty | Advanced |
| Time | ~30 minutes |
| Source | Lay, Linear Algebra and Its Applications, Sections 6.3 and 6.4 |
Projection Formulas
| Situation | Formula |
|---|---|
| Project $\mathbf{y}$ onto a vector $\mathbf{u}$ | $\hat{\mathbf{y}} = \dfrac{\mathbf{y}\cdot\mathbf{u}}{\mathbf{u}\cdot\mathbf{u}}\mathbf{u}$ |
| Project $\mathbf{y}$ onto a subspace with orthogonal basis $\{\mathbf{u}_1,\ldots,\mathbf{u}_p\}$ | $\hat{\mathbf{y}} = \dfrac{\mathbf{y}\cdot\mathbf{u}_1}{\mathbf{u}_1\cdot\mathbf{u}_1}\mathbf{u}_1 + \cdots + \dfrac{\mathbf{y}\cdot\mathbf{u}_p}{\mathbf{u}_p\cdot\mathbf{u}_p}\mathbf{u}_p$ |
| Error vector | $\mathbf{z} = \mathbf{y} - \hat{\mathbf{y}}$ (always orthogonal to $W$) |
Key Concepts
Projection onto a Vector
The orthogonal projection of $\mathbf{y} \in \mathbb{R}^n$ onto a nonzero vector $\mathbf{u}$ is: \[ \text{proj}_\mathbf{u}\mathbf{y} = \frac{\mathbf{y}\cdot\mathbf{u}}{\mathbf{u}\cdot\mathbf{u}}\mathbf{u} \]
The scalar $\frac{\mathbf{y}\cdot\mathbf{u}}{\|\mathbf{u}\|^2}$ is the coefficient; it can be positive (projection in the direction of $\mathbf{u}$), negative (opposite direction), or zero (projection is $\mathbf{0}$).
If $\mathbf{u}$ is a unit vector, the formula simplifies: $\text{proj}_\mathbf{u}\mathbf{y} = (\mathbf{y}\cdot\mathbf{u})\mathbf{u}$.
Source: Lay, Linear Algebra and Its Applications, Section 6.3: Orthogonal Projections.
Projection onto a Subspace
If $W$ has an orthogonal basis $\{\mathbf{u}_1, \ldots, \mathbf{u}_p\}$, the orthogonal projection of $\mathbf{y}$ onto $W$ is:
\[ \hat{\mathbf{y}} = \frac{\mathbf{y}\cdot\mathbf{u}_1}{\mathbf{u}_1\cdot\mathbf{u}_1}\mathbf{u}_1 + \frac{\mathbf{y}\cdot\mathbf{u}_2}{\mathbf{u}_2\cdot\mathbf{u}_2}\mathbf{u}_2 + \cdots + \frac{\mathbf{y}\cdot\mathbf{u}_p}{\mathbf{u}_p\cdot\mathbf{u}_p}\mathbf{u}_p \]
The error $\mathbf{z} = \mathbf{y} - \hat{\mathbf{y}}$ is orthogonal to every vector in $W$.
Orthogonal Decomposition Theorem: every $\mathbf{y}$ can be written uniquely as $\mathbf{y} = \hat{\mathbf{y}} + \mathbf{z}$ where $\hat{\mathbf{y}} \in W$ and $\mathbf{z} \in W^\perp$.
Best Approximation Theorem: $\hat{\mathbf{y}}$ is the closest point in $W$ to $\mathbf{y}$: for any other $\mathbf{v} \in W$, $\|\mathbf{y} - \hat{\mathbf{y}}\| \leq \|\mathbf{y} - \mathbf{v}\|$.
The Gram-Schmidt Process
Input: any basis $\{\mathbf{x}_1, \mathbf{x}_2, \ldots, \mathbf{x}_p\}$ for a subspace $W$.
Output: an orthogonal basis $\{\mathbf{v}_1, \mathbf{v}_2, \ldots, \mathbf{v}_p\}$ for the same subspace $W$.
Algorithm:
\[ \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 \]
and so on: at step $k$, subtract from $\mathbf{x}_k$ the projection of $\mathbf{x}_k$ onto each previously computed $\mathbf{v}_j$.
Gram-Schmidt preserves the span: at each step, $\text{Span}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\} = \text{Span}\{\mathbf{x}_1,\ldots,\mathbf{x}_k\}$.
To get an orthonormal basis, normalize each $\mathbf{v}_j$: $\mathbf{u}_j = \mathbf{v}_j / \|\mathbf{v}_j\|$.
Source: Lay, Linear Algebra and Its Applications, Section 6.4: The Gram-Schmidt Process.
Worked Example: Gram-Schmidt in $\mathbb{R}^3$
Apply Gram-Schmidt to the basis $\mathbf{x}_1 = \begin{pmatrix}1\\1\\0\end{pmatrix}$, $\mathbf{x}_2 = \begin{pmatrix}1\\0\\1\end{pmatrix}$.
Step 1: $\mathbf{v}_1 = \mathbf{x}_1 = \begin{pmatrix}1\\1\\0\end{pmatrix}$
Step 2: Subtract the projection of $\mathbf{x}_2$ onto $\mathbf{v}_1$:
\[ \frac{\mathbf{x}_2\cdot\mathbf{v}_1}{\mathbf{v}_1\cdot\mathbf{v}_1} = \frac{1+0+0}{1+1+0} = \frac{1}{2} \]
\[ \mathbf{v}_2 = \mathbf{x}_2 - \frac{1}{2}\mathbf{v}_1 = \begin{pmatrix}1\\0\\1\end{pmatrix} - \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix} = \begin{pmatrix}1/2\\-1/2\\1\end{pmatrix} \]
Verify orthogonality: $\mathbf{v}_1 \cdot \mathbf{v}_2 = \frac{1}{2} - \frac{1}{2} + 0 = 0$ (correct).
Normalize to get an orthonormal basis:
\[ \|\mathbf{v}_1\| = \sqrt{2}, \quad \mathbf{u}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix} \]
\[ \|\mathbf{v}_2\| = \sqrt{\frac{1}{4}+\frac{1}{4}+1} = \sqrt{\frac{3}{2}} = \frac{\sqrt{6}}{2}, \quad \mathbf{u}_2 = \frac{1}{\sqrt{6}/2}\begin{pmatrix}1/2\\-1/2\\1\end{pmatrix} = \frac{1}{\sqrt{6}}\begin{pmatrix}1\\-1\\2\end{pmatrix} \]
Verify: $\mathbf{u}_1 \cdot \mathbf{u}_2 = \frac{1}{\sqrt{2}} \cdot \frac{1}{\sqrt{6}}(1-1+0) = 0$ (orthogonal), $\|\mathbf{u}_1\| = 1$ (unit), $\|\mathbf{u}_2\|^2 = \frac{1}{6}(1+1+4) = 1$ (unit).
Common Pitfalls
| Mistake | Why It Is Wrong | Correct Approach |
|---|---|---|
| Thinking the projection $\hat{\mathbf{y}}$ lies on the vector $\mathbf{u}$ itself | The projection lies in $\text{Span}\{\mathbf{u}\}$, the line through the origin in the direction of $\mathbf{u}$; it is a scalar multiple of $\mathbf{u}$ | Projection = $\frac{\mathbf{y}\cdot\mathbf{u}}{\mathbf{u}\cdot\mathbf{u}}\mathbf{u}$: a specific point on the line through $\mathbf{u}$ |
| Believing Gram-Schmidt changes the subspace | Gram-Schmidt builds a different basis for the SAME subspace: the span is invariant | Verify by checking $\text{Span}\{\mathbf{v}_1,\mathbf{v}_2\} = \text{Span}\{\mathbf{x}_1,\mathbf{x}_2\}$ |
| Applying the subspace projection formula without an orthogonal basis | The formula $\hat{\mathbf{y}} = \sum \frac{\mathbf{y}\cdot\mathbf{u}_i}{\mathbf{u}_i\cdot\mathbf{u}_i}\mathbf{u}_i$ requires the $\mathbf{u}_i$ to be ORTHOGONAL; it fails for a non-orthogonal basis | First run Gram-Schmidt to make the basis orthogonal, then project |
Practice Problems
Find the orthogonal projection of $\mathbf{y} = \begin{pmatrix}4\\2\\-1\end{pmatrix}$ onto $\mathbf{u} = \begin{pmatrix}1\\-1\\2\end{pmatrix}$.
Then find the error vector and verify it is orthogonal to $\mathbf{u}$.
Let $W = \text{Span}\left\{\begin{pmatrix}2\\1\\-1\end{pmatrix}\right\}$ and $\mathbf{y} = \begin{pmatrix}3\\-1\\2\end{pmatrix}$.
Find $\hat{\mathbf{y}} = \text{proj}_W\mathbf{y}$ and $\mathbf{z} = \mathbf{y} - \hat{\mathbf{y}}$.
Verify $\mathbf{z} \in W^\perp$.
Let $W = \text{Span}\left\{\mathbf{u}_1, \mathbf{u}_2\right\}$ where $\mathbf{u}_1 = \begin{pmatrix}1\\0\\-1\end{pmatrix}$ and $\mathbf{u}_2 = \begin{pmatrix}1\\2\\1\end{pmatrix}$ (you verified these are orthogonal in [Inner Products, Level 3]).
Find $\hat{\mathbf{y}} = \text{proj}_W\mathbf{y}$ for $\mathbf{y} = \begin{pmatrix}2\\3\\-1\end{pmatrix}$.
Apply the Gram-Schmidt process to the basis $\left\{\begin{pmatrix}1\\1\\1\end{pmatrix}, \begin{pmatrix}1\\2\\0\end{pmatrix}, \begin{pmatrix}1\\0\\0\end{pmatrix}\right\}$ for $\mathbb{R}^3$.
Produce an orthogonal basis $\{\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3\}$. Verify pairwise orthogonality.
Let $W = \text{Col}(A)$ where $A = \begin{pmatrix}1&1\\1&0\\0&1\end{pmatrix}$.
(a) Apply Gram-Schmidt to the columns of $A$ to produce an orthogonal basis $\{\mathbf{v}_1, \mathbf{v}_2\}$ for $W$.
(b) Find the orthogonal projection of $\mathbf{y} = \begin{pmatrix}2\\1\\3\end{pmatrix}$ onto $W$.
(c) Verify that $\mathbf{y} - \hat{\mathbf{y}}$ is orthogonal to both columns of $A$.
Common Misconceptions
the projection $\hat{\mathbf{y}}$ is the foot of the perpendicular onto the vector $\mathbf{u}$ itself, not the line $\text{Span}\{\mathbf{u}\}$. The projection lands in $\text{Span}\{\mathbf{u}\}$, which is the entire line through the origin in the direction of $\mathbf{u}$. If $\mathbf{u} = \begin{pmatrix}1\\2\end{pmatrix}$, the projection of $\mathbf{y}$ onto $\mathbf{u}$ is a scalar multiple of $\mathbf{u}$, potentially far from the endpoint $\mathbf{u}$ itself.
Gram-Schmidt changes the subspace. At every step of the process, $\text{Span}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\} = \text{Span}\{\mathbf{x}_1,\ldots,\mathbf{x}_k\}$. The algorithm builds a new DESCRIPTION (orthogonal basis) of the SAME subspace. The subspace does not change.
the subspace projection formula works for any basis, not just orthogonal ones. The formula $\hat{\mathbf{y}} = \sum \frac{\mathbf{y}\cdot\mathbf{u}_i}{\mathbf{u}_i\cdot\mathbf{u}_i}\mathbf{u}_i$ is valid only when $\{\mathbf{u}_i\}$ is an orthogonal set. For a non-orthogonal basis, the individual projections interact (are not independent) and the formula overcounts. First apply Gram-Schmidt, then project.
Mastery Checklist
Novice (Level 1-2):
Competent (Level 3-4):
Proficient (Level 5):
Mental Model
The Shadow
The orthogonal projection of $\mathbf{y}$ onto a subspace $W$ is the “shadow” of $\mathbf{y}$ on $W$ when the light shines perpendicular to $W$. The shadow is the closest point in $W$ to $\mathbf{y}$, and the gap between the shadow and $\mathbf{y}$ (the error vector) is exactly perpendicular to $W$.
Gram-Schmidt is the construction of a “coordinate frame” for $W$: starting from an arbitrary basis, it builds one direction at a time by removing any component that overlaps with the already-established directions. The result is a set of arrows that are all at right angles to each other, spanning the same space as before but with no angular overlap.
Connections
Within MATH 231:
- Null Space, Column Space, and Basis: the projection onto Col$(A)$ is the least-squares solution to $A\mathbf{x} = \mathbf{b}$; Gram-Schmidt on the columns of $A$ produces the QR factorization
- Eigenvalues and Eigenvectors: the Spectral Theorem says every real symmetric matrix has an orthonormal eigenvector basis; Gram-Schmidt is one way to construct it
Real-world connections:
- Data fitting (least squares): the projection of $\mathbf{b}$ onto Col$(A)$ gives the best-fit coefficients when no exact solution exists.
- Signal processing: projection onto orthogonal frequency components is the foundation of the Fourier transform.
- Machine learning: dimensionality reduction (PCA) uses an orthogonal basis found via spectral methods.
Source: Lay, Linear Algebra and Its Applications, Section 6.3: Orthogonal Projections; Section 6.4: The Gram-Schmidt Process.
| Previous | Up | Next |
|---|---|---|
| Inner Products, Length, and Orthogonality | MATH231 Skills Index |
Last updated: 2026-06-16
Watch and Read
- Lynch, MATH 231 lecture playlists (YouTube)Recorded MATH 231 lectures at EWU. Use them to see each topic worked through in a full class session.