Tutorials › Linear Algebra › The Best Approximation Theorem

Orthogonal Complements and Projections · Tutorial 676 of 1000

The Best Approximation Theorem

Use orthogonal decomposition and the Pythagorean identity to prove why projection gives the unique best approximation in a subspace.

Intermediate 10 min read

What You'll Learn

  • Define the distance from a vector to a vector in a subspace.
  • State the best approximation theorem and its hypotheses.
  • Prove the Pythagorean identity for orthogonal vectors.
  • Show that the projection uniquely minimizes distance to the subspace.
  • Test the theorem with explicit orthogonal decompositions.
  • Identify and correct a sign error in the distance comparison.

Projection as a Best Approximation

Suppose a vector \(\mathbf{b}\) does not lie in a subspace \(W\). We may still want a vector in \(W\) that represents \(\mathbf{b}\) as closely as possible. The natural candidate is the orthogonal projection of \(\mathbf{b}\) onto \(W\): it is the part of \(\mathbf{b}\) that lies in \(W\), while the remaining part is perpendicular to \(W\). The best approximation theorem makes “as closely as possible” precise and proves that this candidate is the only closest vector in \(W\).

Throughout, work in \(\mathbb{R}^n\) with the standard dot product \(\mathbf{x}\cdot\mathbf{y}=\mathbf{x}^{\top}\mathbf{y}\) and norm \(\|\mathbf{x}\|=\sqrt{\mathbf{x}\cdot\mathbf{x}}\). For \(\mathbf{b}\in\mathbb{R}^n\) and \(\mathbf{w}\in W\), the distance from \(\mathbf{b}\) to \(\mathbf{w}\) is \(\|\mathbf{b}-\mathbf{w}\|\). A vector \(\mathbf{r}\) is perpendicular to \(W\) if \(\mathbf{r}\cdot\mathbf{w}=\mathbf{0}\) in the scalar sense—that is, \(\mathbf{r}\cdot\mathbf{w}=0\)—for every \(\mathbf{w}\in W\).

Definition: Let \(W\) be a subspace of \(\mathbb{R}^n\). The orthogonal projection of \(\mathbf{b}\in\mathbb{R}^n\) onto \(W\), written \(\operatorname{proj}_W\mathbf{b}\), is the vector \(\mathbf{p}\in W\) such that \(\mathbf{b}-\mathbf{p}\) is perpendicular to every vector in \(W\). Equivalently, \(\mathbf{b}=\mathbf{p}+\mathbf{r}\), where \(\mathbf{p}\in W\) and \(\mathbf{r}\in W^\perp\). The distance from \(\mathbf{b}\) to \(W\) is minimized at \(\mathbf{p}\) if \(\|\mathbf{b}-\mathbf{p}\|\leq\|\mathbf{b}-\mathbf{w}\|\) for every \(\mathbf{w}\in W\).

The orthogonal decomposition theorem gives a unique decomposition \(\mathbf{b}=\mathbf{p}+\mathbf{r}\) with \(\mathbf{p}\in W\) and \(\mathbf{r}\in W^\perp\). We use that result here: it ensures that the projection exists and is uniquely defined. The theorem below proves the further claim that this projection is not merely a vector in \(W\), but the unique vector in \(W\) closest to \(\mathbf{b}\).

The Pythagorean Identity

The key calculation compares the residual \(\mathbf{b}-\mathbf{p}\) with the difference between two vectors in the subspace. Because both \(\mathbf{p}\) and any \(\mathbf{w}\in W\) belong to \(W\), their difference \(\mathbf{p}-\mathbf{w}\) also belongs to \(W\). The residual is perpendicular to that difference.

Theorem (Pythagorean identity): If \(\mathbf{x},\mathbf{y}\in\mathbb{R}^n\) and \(\mathbf{x}\cdot\mathbf{y}=0\), then \(\|\mathbf{x}+\mathbf{y}\|^2=\|\mathbf{x}\|^2+\|\mathbf{y}\|^2\).

Proof. By the definition of the norm and the distributive property of the dot product,

$$ \|\mathbf{x}+\mathbf{y}\|^2 =(\mathbf{x}+\mathbf{y})\cdot(\mathbf{x}+\mathbf{y}) =\mathbf{x}\cdot\mathbf{x}+\mathbf{x}\cdot\mathbf{y} +\mathbf{y}\cdot\mathbf{x}+\mathbf{y}\cdot\mathbf{y}. $$

In \(\mathbb{R}^n\), \(\mathbf{x}\cdot\mathbf{y}=\mathbf{y}\cdot\mathbf{x}\). Since \(\mathbf{x}\cdot\mathbf{y}=0\), both cross terms are zero. The remaining terms are \(\|\mathbf{x}\|^2\) and \(\|\mathbf{y}\|^2\), which gives the stated identity. \(\square\)

The Best Approximation Theorem

Theorem (Best approximation): Let \(W\) be a finite-dimensional subspace of \(\mathbb{R}^n\), and let \(\mathbf{b}\in\mathbb{R}^n\). The orthogonal projection \(\mathbf{p}=\operatorname{proj}_W\mathbf{b}\) is the unique vector in \(W\) that minimizes \(\|\mathbf{b}-\mathbf{w}\|\) over all \(\mathbf{w}\in W\). More precisely, for every \(\mathbf{w}\in W\),

\(\|\mathbf{b}-\mathbf{w}\|^2=\|\mathbf{b}-\mathbf{p}\|^2+\|\mathbf{p}-\mathbf{w}\|^2.\)

Equality \(\|\mathbf{b}-\mathbf{w}\|=\|\mathbf{b}-\mathbf{p}\|\) holds if and only if \(\mathbf{w}=\mathbf{p}\).

Proof. By the definition of the projection, \(\mathbf{p}\in W\) and \(\mathbf{b}-\mathbf{p}\in W^\perp\). Fix any \(\mathbf{w}\in W\). Since \(W\) is a subspace, \(\mathbf{p}-\mathbf{w}\in W\), so \((\mathbf{b}-\mathbf{p})\cdot(\mathbf{p}-\mathbf{w})=0\). Decompose the difference from \(\mathbf{b}\) to \(\mathbf{w}\) as

$$ \mathbf{b}-\mathbf{w}=(\mathbf{b}-\mathbf{p})+(\mathbf{p}-\mathbf{w}). $$

The two vectors on the right are perpendicular. Applying the Pythagorean identity gives

$$ \|\mathbf{b}-\mathbf{w}\|^2 =\|\mathbf{b}-\mathbf{p}\|^2+\|\mathbf{p}-\mathbf{w}\|^2. $$

A squared norm is nonnegative, so \(\|\mathbf{b}-\mathbf{w}\|^2\geq\|\mathbf{b}-\mathbf{p}\|^2\). Both norms are nonnegative, and squaring preserves their order; hence \(\|\mathbf{b}-\mathbf{w}\|\geq\|\mathbf{b}-\mathbf{p}\|\). Equality holds exactly when \(\|\mathbf{p}-\mathbf{w}\|^2=0\), which holds exactly when \(\mathbf{p}-\mathbf{w}=\mathbf{0}\), or \(\mathbf{w}=\mathbf{p}\). Thus \(\mathbf{p}\) is a minimizer and no other vector in \(W\) is a minimizer. \(\square\)

The identity is stronger than a comparison of distances: it tells exactly how much squared distance is added by choosing \(\mathbf{w}\) instead of the projection. The extra term is \(\|\mathbf{p}-\mathbf{w}\|^2\), which is zero only when the choice is the projection itself. This also explains why uniqueness follows from the geometry rather than from a particular formula for computing \(\mathbf{p}\).

Worked Examples

Worked Example: Projection onto a Line

Let \(W=\operatorname{span}\{(1,1)\}\subset\mathbb{R}^2\), and let \(\mathbf{b}=(3,1)\). Verify that \(\mathbf{p}=(2,2)\) is the unique closest vector in \(W\).

First, \(\mathbf{p}=2(1,1)\), so \(\mathbf{p}\in W\). The residual is

$$ \mathbf{b}-\mathbf{p}=(3,1)-(2,2)=(1,-1). $$

Its dot product with the generator of \(W\) is \((1,-1)\cdot(1,1)=1-1=0\). Every vector in \(W\) is a multiple of this generator, so the residual is perpendicular to all of \(W\). Thus \(\mathbf{p}\) is the projection. Write an arbitrary vector in \(W\) as \(\mathbf{w}=(t,t)\), with \(t\in\mathbb{R}\). The theorem gives

$$ \|\mathbf{b}-\mathbf{w}\|^2 =\|\mathbf{b}-\mathbf{p}\|^2+\|\mathbf{p}-\mathbf{w}\|^2 =2+2(2-t)^2. $$

This is at least \(2\), with equality exactly when \(t=2\). Directly, \(\|\mathbf{b}-\mathbf{p}\|^2=\|(1,-1)\|^2=1+1=2\). For a check at \(t=3\), \(\mathbf{w}=(3,3)\), so \(\|\mathbf{b}-\mathbf{w}\|^2=\|(0,-2)\|^2=4\); the identity gives \(2+\|(2,2)-(3,3)\|^2=2+2=4\). The projection is indeed uniquely closest.

Worked Example: Projection onto a Plane in R³

Let \(W=\operatorname{span}\{(1,0,1),(0,1,1)\}\) and \(\mathbf{b}=(1,2,0)\). Check that \(\mathbf{p}=(0,1,1)\) is the unique closest vector in \(W\).

The proposed vector is the second generator, so \(\mathbf{p}\in W\). Its residual is \(\mathbf{r}=\mathbf{b}-\mathbf{p}=(1,1,-1)\). Check perpendicularity against both generators:

$$ (1,1,-1)\cdot(1,0,1)=1+0-1=0,\qquad (1,1,-1)\cdot(0,1,1)=0+1-1=0. $$

Every vector in \(W\) is a linear combination of those generators, so \(\mathbf{r}\) is perpendicular to every vector in \(W\). For a specific comparison, take \(\mathbf{w}=(1,0,1)\in W\). The projection distance squared is \(\|\mathbf{b}-\mathbf{p}\|^2=1+1+1=3\), while

$$ \|\mathbf{b}-\mathbf{w}\|^2 =\|(1,2,0)-(1,0,1)\|^2 =\|(0,2,-1)\|^2 =0+4+1=5. $$

The theorem accounts for the difference: \(\mathbf{p}-\mathbf{w}=(-1,1,0)\), whose squared norm is \(1+1+0=2\), and \(3+2=5\). For every other \(\mathbf{w}\in W\), the same identity says its squared distance is \(3+\|\mathbf{p}-\mathbf{w}\|^2\), so only \(\mathbf{w}=\mathbf{p}\) attains the minimum.

Worked Example: A Coordinate Subspace

Let \(W=\{(x,y,0):x,y\in\mathbb{R}\}\subset\mathbb{R}^3\) and \(\mathbf{b}=(2,-1,3)\). Show that \(\mathbf{p}=(2,-1,0)\) is the unique closest vector in \(W\).

The vector \(\mathbf{p}\) belongs to \(W\), and \(\mathbf{b}-\mathbf{p}=(0,0,3)\). For any \(\mathbf{w}=(x,y,0)\in W\), the dot product \((0,0,3)\cdot(x,y,0)=0\). Hence \(\mathbf{b}-\mathbf{p}\) is perpendicular to \(W\), and \(\mathbf{p}\) is the projection. Applying the theorem to an arbitrary \(\mathbf{w}\) gives

$$ \|\mathbf{b}-\mathbf{w}\|^2 =9+(2-x)^2+(-1-y)^2. $$

The right side is at least \(9\), and it equals \(9\) only if \(x=2\) and \(y=-1\), which makes \(\mathbf{w}=\mathbf{p}\). As a check, \(\|\mathbf{b}-\mathbf{p}\|^2=\|(0,0,3)\|^2=9\). For the alternative \(\mathbf{w}=(0,0,0)\), the squared distance is \(2^2+(-1)^2+3^2=14\); the theorem gives \(9+\|(2,-1,0)\|^2=9+5=14\).

Why the Orthogonality Condition Matters

For any \(\mathbf{w}\in W\), the decomposition used in the proof has two parts: the residual \(\mathbf{b}-\mathbf{p}\), which points away from the subspace, and the in-subspace adjustment \(\mathbf{p}-\mathbf{w}\). Perpendicularity ensures their squared lengths add. Without that perpendicularity, the dot-product expansion has cross terms, and the distance need not be minimized at \(\mathbf{p}\). This is why merely choosing a vector in \(W\) is not enough; it must satisfy the projection condition.

The conclusion also applies when \(\mathbf{b}\in W\). In that case the decomposition is \(\mathbf{b}=\mathbf{b}+\mathbf{0}\), so \(\operatorname{proj}_W\mathbf{b}=\mathbf{b}\). The minimum distance is \(0\), and the theorem says no other vector in \(W\) has distance \(0\) from \(\mathbf{b}\). At the other boundary case \(W=\{\mathbf{0}\}\), the only available vector is \(\mathbf{0}\), which is necessarily the unique minimizer; the theorem’s comparison remains valid.

A Common Pitfall

A frequent error is to subtract the squared correction term instead of adding it. In the line example, \(\mathbf{b}=(3,1)\), \(\mathbf{p}=(2,2)\), and \(\mathbf{w}=(3,3)\). The incorrect calculation would claim

$$ \|\mathbf{b}-\mathbf{w}\|^2 =\|\mathbf{b}-\mathbf{p}\|^2-\|\mathbf{p}-\mathbf{w}\|^2 =2-2=0. $$

But direct substitution gives \(\mathbf{b}-\mathbf{w}=(0,-2)\), so \(\|\mathbf{b}-\mathbf{w}\|^2=4\), not \(0\). The correct Pythagorean identity uses a plus sign: \(2+2=4\). Geometrically, moving from the projection to another vector in \(W\) adds a perpendicular displacement to the residual, so it increases the squared distance rather than subtracting from it.

Check Your Understanding

Use the projection condition and the best approximation identity to justify each conclusion.

  1. Suppose \(\mathbf{b}=\mathbf{p}+\mathbf{r}\), with \(\mathbf{p}\in W\) and \(\mathbf{r}\in W^\perp\). Write the identity for \(\|\mathbf{b}-\mathbf{w}\|^2\) for an arbitrary \(\mathbf{w}\in W\).
  2. For \(W=\operatorname{span}\{(1,0)\}\subset\mathbb{R}^2\) and \(\mathbf{b}=(4,3)\), verify that \((4,0)\) is the projection, then compare its distance with the distance to \((2,0)\).
  3. Why does equality of the distances to \(\mathbf{b}\) force \(\mathbf{w}=\mathbf{p}\) in the best approximation theorem?
  4. For \(W=\{(x,0):x\in\mathbb{R}\}\) and \(\mathbf{b}=(1,2)\), calculate the projection distance and the distance to \((0,0)\), and check the Pythagorean identity.
  5. State which step in the proof fails if the proposed vector \(\mathbf{p}\in W\) does not have residual \(\mathbf{b}-\mathbf{p}\) perpendicular to \(W\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon