Tutorials › Linear Algebra › Why Gram-Schmidt Removes Earlier Components

Orthogonal Sets and Gram-Schmidt · Tutorial 638 of 1000

Why Gram-Schmidt Removes Earlier Components

Learn why subtracting the inner-product coefficients removes exactly the components along previously constructed orthonormal vectors.

Intermediate 8 min read

What You'll Learn

  • Derive the coefficient that makes a residual orthogonal to a given unit vector
  • Prove that the coefficients for an orthonormal list are unique
  • Interpret the subtraction as removing the component in the earlier vectors’ span
  • Verify the formula with real and complex inner-product examples
  • Identify why the formula changes for orthogonal vectors that are not unit vectors

The Goal: Remove Components Without Losing Orthogonality

In Gram-Schmidt, a new input vector may point partly in directions already represented by previously constructed unit vectors. The subtraction step removes those parts, leaving a residual orthogonal to every earlier direction. The coefficients are not guessed: each one is forced by the requirement that the residual have zero inner product with the corresponding unit vector.

Work over \(\mathbb{F}=\mathbb{R}\) or \(\mathbb{C}\), with the inner product linear in its first slot and conjugate-linear in its second. Suppose \(\mathbf{q}_1,\dots,\mathbf{q}_m\) are orthonormal: each has norm \(1\), and \(\langle\mathbf{q}_j,\mathbf{q}_i\rangle=0\) whenever \(i\ne j\). Given a vector \(\mathbf{x}\), seek coefficients \(c_1,\dots,c_m\) so that subtracting the corresponding multiples gives a residual \(\mathbf{r}\) orthogonal to all the \(\mathbf{q}_i\).

Definition: For an orthonormal list \(\mathbf{q}_1,\dots,\mathbf{q}_m\), the residual after removing the earlier components of \(\mathbf{x}\) is a vector of the form \(\mathbf{r}=\mathbf{x}-\sum_{j=1}^{m}c_j\mathbf{q}_j\) satisfying \(\langle\mathbf{r},\mathbf{q}_i\rangle=0\) for every \(i=1,\dots,m\). The subtracted vector \(\sum_{j=1}^{m}c_j\mathbf{q}_j\) is the part of \(\mathbf{x}\) in the directions of the given orthonormal list.

To determine \(c_i\), impose the \(i\)-th orthogonality condition. The inner product of the proposed residual with \(\mathbf{q}_i\) is

$$ \left\langle \mathbf{x}-\sum_{j=1}^{m}c_j\mathbf{q}_j,\mathbf{q}_i\right\rangle = \langle\mathbf{x},\mathbf{q}_i\rangle -\sum_{j=1}^{m}c_j\langle\mathbf{q}_j,\mathbf{q}_i\rangle. $$

All terms in the sum vanish except the \(j=i\) term, because the vectors are orthonormal. That remaining inner product is \(\langle\mathbf{q}_i,\mathbf{q}_i\rangle=1\). Therefore the condition becomes \(0=\langle\mathbf{x},\mathbf{q}_i\rangle-c_i\), which forces \(c_i=\langle\mathbf{x},\mathbf{q}_i\rangle\). Applying this to every earlier unit vector gives the subtraction formula.

Formula: If \(\mathbf{q}_1,\dots,\mathbf{q}_m\) are orthonormal, the unique residual of \(\mathbf{x}\) orthogonal to all of them is $$ \mathbf{r}=\mathbf{x}-\sum_{j=1}^{m}\langle\mathbf{x},\mathbf{q}_j\rangle\mathbf{q}_j. $$ The coefficient \(\langle\mathbf{x},\mathbf{q}_j\rangle\) is the amount of \(\mathbf{x}\) in the direction of the unit vector \(\mathbf{q}_j\).

Why These Coefficients Work—and Are Forced

The formula gives more than one way to calculate a residual. It explains why the subtraction has the required effect and why no different set of coefficients can do the same job.

Theorem: Let \(\mathbf{q}_1,\dots,\mathbf{q}_m\) be an orthonormal list in an inner product space over \(\mathbb{F}\), and let \(\mathbf{x}\) be any vector in that space. There is exactly one choice of scalars \(c_1,\dots,c_m\) for which \(\mathbf{x}-\sum_{j=1}^{m}c_j\mathbf{q}_j\) is orthogonal to every \(\mathbf{q}_i\). That choice is \(c_i=\langle\mathbf{x},\mathbf{q}_i\rangle\).

Proof. First take \(c_i=\langle\mathbf{x},\mathbf{q}_i\rangle\) for each \(i\), and set \(\mathbf{r}=\mathbf{x}-\sum_{j=1}^{m}c_j\mathbf{q}_j\). For any \(i\), linearity in the first slot gives \(\langle\mathbf{r},\mathbf{q}_i\rangle=\langle\mathbf{x},\mathbf{q}_i\rangle-\sum_{j=1}^{m}c_j\langle\mathbf{q}_j,\mathbf{q}_i\rangle\). Orthonormality makes this \( \langle\mathbf{x},\mathbf{q}_i\rangle-c_i=0\), so the proposed residual is orthogonal to every vector in the list. Now suppose some coefficients \(d_1,\dots,d_m\) also give a residual \(\mathbf{s}=\mathbf{x}-\sum_{j=1}^{m}d_j\mathbf{q}_j\) orthogonal to every \(\mathbf{q}_i\). Taking its inner product with \(\mathbf{q}_i\) gives \(0=\langle\mathbf{x},\mathbf{q}_i\rangle-d_i\), again by orthonormality. Hence \(d_i=\langle\mathbf{x},\mathbf{q}_i\rangle=c_i\) for every \(i\). The coefficients are therefore both sufficient and unique. \(\square\)

The subtracted sum lies in \(\operatorname{span}\{\mathbf{q}_1,\dots,\mathbf{q}_m\}\), while the residual is orthogonal to every vector in that span. Indeed, for any scalars \(a_1,\dots,a_m\), conjugate-linearity in the second slot gives \(\left\langle\mathbf{r},\sum_{i=1}^{m}a_i\mathbf{q}_i\right\rangle=\sum_{i=1}^{m}\overline{a_i}\langle\mathbf{r},\mathbf{q}_i\rangle=0\). Thus the formula separates \(\mathbf{x}\) into a part in the listed directions and a part perpendicular to all of them. The earlier material on orthogonal sums explains why this separation also gives a Pythagorean norm identity.

Worked Examples: Seeing the Removed Components

Worked Example: Removing Two Coordinate Components

Let \(\mathbf{q}_1=(1,0,0)^{\top}\) and \(\mathbf{q}_2=(0,1,0)^{\top}\). For \(\mathbf{x}=(3,-2,5)^{\top}\), find the residual orthogonal to both unit vectors.

First, the list is orthonormal: each vector has norm \(1\), and \(\langle\mathbf{q}_1,\mathbf{q}_2\rangle=0\). The coefficients are

$$ \langle\mathbf{x},\mathbf{q}_1\rangle=3, \qquad \langle\mathbf{x},\mathbf{q}_2\rangle=-2. $$

Subtract these multiples from \(\mathbf{x}\):

$$ \mathbf{r} = \begin{bmatrix}3\\-2\\5\end{bmatrix} -3\begin{bmatrix}1\\0\\0\end{bmatrix} -(-2)\begin{bmatrix}0\\1\\0\end{bmatrix} = \begin{bmatrix}3\\-2\\5\end{bmatrix} -\begin{bmatrix}3\\0\\0\end{bmatrix} -\begin{bmatrix}0\\-2\\0\end{bmatrix} = \begin{bmatrix}0\\0\\5\end{bmatrix}. $$

Check: \(\langle\mathbf{r},\mathbf{q}_1\rangle=0\cdot1+0\cdot0+5\cdot0=0\), and \(\langle\mathbf{r},\mathbf{q}_2\rangle=0\cdot0+0\cdot1+5\cdot0=0\). Reconstructing gives \(\mathbf{r}+3\mathbf{q}_1-2\mathbf{q}_2=(0,0,5)^{\top}+(3,0,0)^{\top}+(0,-2,0)^{\top}=(3,-2,5)^{\top}=\mathbf{x}\).

Worked Example: Components Along Tilted Directions

Consider \(\mathbf{q}_1=(1/\sqrt{2},1/\sqrt{2},0)^{\top}\) and \(\mathbf{q}_2=(0,0,1)^{\top}\), and take \(\mathbf{x}=(2,0,1)^{\top}\). The first vector has squared norm \(1/2+1/2=1\); the second has norm \(1\); and their inner product is \(0\). They are orthonormal.

The coefficients are \(\langle\mathbf{x},\mathbf{q}_1\rangle=2/\sqrt{2}=\sqrt{2}\) and \(\langle\mathbf{x},\mathbf{q}_2\rangle=1\). The removed part and residual are

$$ \sqrt{2}\mathbf{q}_1+\mathbf{q}_2 = \begin{bmatrix}1\\1\\0\end{bmatrix} + \begin{bmatrix}0\\0\\1\end{bmatrix} = \begin{bmatrix}1\\1\\1\end{bmatrix}, \qquad \mathbf{r} = \begin{bmatrix}2\\0\\1\end{bmatrix} - \begin{bmatrix}1\\1\\1\end{bmatrix} = \begin{bmatrix}1\\-1\\0\end{bmatrix}. $$

Check: \(\langle\mathbf{r},\mathbf{q}_1\rangle=1/\sqrt{2}-1/\sqrt{2}+0=0\), and \(\langle\mathbf{r},\mathbf{q}_2\rangle=0\). Adding back the removed part gives \((1,-1,0)^{\top}+(1,1,1)^{\top}=(2,0,1)^{\top}=\mathbf{x}\).

Worked Example: The Complex Inner Product Convention

Over \(\mathbb{C}\), use the standard inner product \(\langle\mathbf{u},\mathbf{v}\rangle=\sum_j u_j\overline{v_j}\), which is linear in the first slot. Let \(\mathbf{q}=(1,i)^{\top}/\sqrt{2}\) and \(\mathbf{x}=(1,0)^{\top}\). Since \(\langle\mathbf{q},\mathbf{q}\rangle=(1+|i|^2)/2=1\), \(\mathbf{q}\) is a unit vector.

The coefficient is \(\langle\mathbf{x},\mathbf{q}\rangle=1/\sqrt{2}\). Therefore the removed component is \((1/\sqrt{2})\mathbf{q}=(1/2,i/2)^{\top}\), and the residual is \(\mathbf{r}=(1/2,-i/2)^{\top}\).

Check: Because \(\overline{i}=-i\), we have \(\langle\mathbf{r},\mathbf{q}\rangle=(1/2)(1/\sqrt{2})+(-i/2)(-i/\sqrt{2})=1/(2\sqrt{2})-1/(2\sqrt{2})=0\). Also \(\mathbf{r}+(1/\sqrt{2})\mathbf{q}=(1/2,-i/2)^{\top}+(1/2,i/2)^{\top}=(1,0)^{\top}=\mathbf{x}\).

Why Unit Length Matters

The coefficient formula \(\langle\mathbf{x},\mathbf{q}_i\rangle\) relies on the fact that \(\langle\mathbf{q}_i,\mathbf{q}_i\rangle=1\). If the earlier vectors are mutually orthogonal but not unit vectors, the same calculation leaves a factor of their squared norm. For a nonzero orthogonal vector \(\mathbf{u}_i\), choosing a coefficient \(c_i\) in \(\mathbf{x}-c_i\mathbf{u}_i\) and requiring orthogonality to \(\mathbf{u}_i\) gives \(0=\langle\mathbf{x},\mathbf{u}_i\rangle-c_i\langle\mathbf{u}_i,\mathbf{u}_i\rangle\). Since \(\langle\mathbf{u}_i,\mathbf{u}_i\rangle=\|\mathbf{u}_i\|^2\ne0\), this forces \(c_i=\langle\mathbf{x},\mathbf{u}_i\rangle/\|\mathbf{u}_i\|^2\).

Common mistake: using the unit-vector formula without a unit vector. Take \(\mathbf{u}=(2,0)^{\top}\) and \(\mathbf{x}=(3,1)^{\top}\). The incorrect coefficient \(\langle\mathbf{x},\mathbf{u}\rangle=6\) would give the residual \((3,1)^{\top}-6(2,0)^{\top}=(-9,1)^{\top}\). But \(\langle(-9,1)^{\top},\mathbf{u}\rangle=-18\ne0\), so this subtraction has not removed the component. The correct coefficient is \(6/\|\mathbf{u}\|^2=6/4=3/2\); it gives \(\mathbf{r}=(3,1)^{\top}-(3/2)(2,0)^{\top}=(0,1)^{\top}\), and \(\langle\mathbf{r},\mathbf{u}\rangle=0\).

A second potential error arises over \(\mathbb{C}\): with the stated convention, the coefficient is \(\langle\mathbf{x},\mathbf{q}\rangle\), not \(\langle\mathbf{q},\mathbf{x}\rangle\). In the complex example, \(\langle\mathbf{x},\mathbf{q}\rangle=1/\sqrt{2}\), whereas \(\langle\mathbf{q},\mathbf{x}\rangle=1/\sqrt{2}\) happens to agree because the value is real. That coincidence does not make the reversed order safe: for complex vectors the two inner products are conjugates, and a nonreal coefficient can be changed by reversing the slots. The reliable procedure is to expand \(\langle\mathbf{x}-c\mathbf{q},\mathbf{q}\rangle=0\) using the convention in force.

How This Subtraction Fits the Construction

At a Gram-Schmidt stage, the vectors already constructed are orthonormal unit vectors. For the next input \(\mathbf{x}\), the formula subtracts one multiple of each earlier vector, with its coefficient determined by orthogonality. The residual may be zero; the subtraction formula still applies, because its derivation does not require \(\mathbf{x}\) to point in a new direction. If the residual is nonzero, it is orthogonal to all earlier directions and can be normalized to obtain a new unit vector. That normalization is a separate step: the subtraction creates orthogonality, while division by the residual’s norm creates unit length.

The order of operations matters conceptually. The formula removes components along the already constructed orthonormal list, not arbitrary directions in the original input list. Orthogonality is what makes the coefficient equations separate: taking the inner product with \(\mathbf{q}_i\) isolates \(c_i\) and eliminates every other coefficient. Without that orthogonality, the coefficient equations would be coupled rather than reducing immediately to \(c_i=\langle\mathbf{x},\mathbf{q}_i\rangle\).

Check Your Understanding

For each question, use the inner-product condition directly to justify the coefficient or residual.

  1. For an orthonormal list \(\mathbf{q}_1,\mathbf{q}_2\), derive the coefficient of \(\mathbf{q}_2\) by taking the inner product of the residual with \(\mathbf{q}_2\).
  2. Let \(\mathbf{q}_1=(1,0)^{\top}\) and \(\mathbf{q}_2=(0,1)^{\top}\). Find the residual for \(\mathbf{x}=(4,-3)^{\top}\) and check both inner products.
  3. For a nonzero orthogonal vector \(\mathbf{u}\) that is not necessarily unit length, explain why the denominator in its coefficient is \(\|\mathbf{u}\|^2\).
  4. Using the complex inner product linear in the first slot, explain why \(\langle\mathbf{x},\mathbf{q}\rangle\) is the coefficient in the subtraction formula.
  5. Can the formula produce a zero residual? Give a condition on \(\mathbf{x}\) under which this happens.

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