Best Approximation
in a Subspace
Learn how to find the closest point in a subspace to any vector: the foundation of projection, least squares, and countless applications in data science.
What Is Best Approximation?
Given a vector \(\mathbf{b}\) in \(\mathbb{R}^n\) and a subspace \(W\), the best approximation to \(\mathbf{b}\) in \(W\) is the vector \(\hat{\mathbf{b}} \in W\) that is closest to \(\mathbf{b}\).
"Closest" means smallest Euclidean distance: the length \(\|\mathbf{b} - \hat{\mathbf{b}}\|\) is as small as possible.
Visual Intuition: Dropping a Perpendicular
Why Does It Matter?
The Best Approximation Theorem
For every \(\mathbf{w} \in W\) with \(\mathbf{w} \neq \hat{\mathbf{b}}\):
Why Orthogonality Makes It Work
Projection vs. Approximation
| Orthogonal Projection | Best Approximation | |
|---|---|---|
| Question | Decompose \(\mathbf{b}\) relative to \(W\) | Find closest \(\mathbf{w}\in W\) to \(\mathbf{b}\) |
| Answer | \(\text{proj}_W \mathbf{b}\) | \(\hat{\mathbf{b}} = \text{proj}_W \mathbf{b}\) |
| Key property | \(\mathbf{b} - \hat{\mathbf{b}} \perp W\) | Minimizes \(\|\mathbf{b}-\mathbf{w}\|\) |
| Relationship | They give the same vector: two views of one idea | |
Computing \(\text{proj}_W \mathbf{b}\)
If \(\{\mathbf{u}_1, \mathbf{u}_2, \dots, \mathbf{u}_p\}\) is an orthogonal basis for \(W\), then:
If the basis is orthonormal (each \(\|\mathbf{u}_i\|=1\)), this simplifies to:
How to Find the Best Approximation
Example 1: Projection onto a Line
Find the best approximation to \(\mathbf{b} = \begin{bmatrix}1\\4\end{bmatrix}\) in \(W = \text{Span}\!\left\{\begin{bmatrix}2\\1\end{bmatrix}\right\}\).
Verify: Is It Really Closest?
Check that the residual \(\mathbf{b}-\hat{\mathbf{b}}\) is orthogonal to \(\mathbf{u}\):
The dot product is zero, confirming orthogonality. The approximation error is \(\|\mathbf{b}-\hat{\mathbf{b}}\| = \tfrac{7\sqrt{5}}{5}\).
Example 2: Projection onto a Plane
Find the best approximation to \(\mathbf{b}=\begin{bmatrix}1\\1\\3\end{bmatrix}\) in \(W=\text{Span}\!\left\{\mathbf{u}_1=\begin{bmatrix}1\\0\\1\end{bmatrix},\;\mathbf{u}_2=\begin{bmatrix}0\\1\\0\end{bmatrix}\right\}\).
Verify Example 2
Example 3: Non-Orthogonal Basis
Find the best approximation to \(\mathbf{b}=\begin{bmatrix}3\\-1\\2\end{bmatrix}\) in \(W = \text{Col}(A)\) where \(A = \begin{bmatrix}1 & 1\\0 & 1\\1 & 0\end{bmatrix}\).
Common Mistakes
Summary: Methods at a Glance
| Scenario | Formula | When to Use |
|---|---|---|
| Orthogonal basis | $$\hat{\mathbf{b}}=\sum \frac{\mathbf{b}\cdot\mathbf{u}_i}{\mathbf{u}_i\cdot\mathbf{u}_i}\mathbf{u}_i$$ | Basis vectors are pairwise orthogonal |
| Orthonormal basis | $$\hat{\mathbf{b}}=\sum (\mathbf{b}\cdot\mathbf{u}_i)\mathbf{u}_i$$ | Basis vectors are unit length and orthogonal |
| General basis | \(A^T A\hat{\mathbf{x}}=A^T\mathbf{b}\), then \(\hat{\mathbf{b}}=A\hat{\mathbf{x}}\) | Basis is not orthogonal |
| Verification | \((\mathbf{b}-\hat{\mathbf{b}})\cdot\mathbf{u}_i=0\;\forall\, i\) | Always: confirms correctness |
Question 1 of 5
The best approximation \(\hat{\mathbf{b}}\) to a vector \(\mathbf{b}\) in a subspace \(W\) is defined as the vector in \(W\) that:
Question 2 of 5
If \(\hat{\mathbf{b}}\) is the best approximation to \(\mathbf{b}\) in \(W\), which statement is always true?
Question 3 of 5
Find the best approximation to \(\mathbf{b}=\begin{bmatrix}3\\4\end{bmatrix}\) in \(W=\text{Span}\!\left\{\begin{bmatrix}1\\1\end{bmatrix}\right\}\).
Question 4 of 5
You are given a non-orthogonal basis for \(W\) and need to find \(\hat{\mathbf{b}}\). Which approach is correct?
Question 5 of 5
Let \(W\) be a subspace and \(\hat{\mathbf{b}} = \text{proj}_W\mathbf{b}\). If \(\mathbf{b}\) is already in \(W\), what is the approximation error \(\|\mathbf{b}-\hat{\mathbf{b}}\|\)?