Tutorials › Linear Algebra › Proof That Gram-Schmidt Outputs Are Orthogonal

Orthogonal Sets and Gram-Schmidt · Tutorial 647 of 1000

Proof That Gram-Schmidt Outputs Are Orthogonal

See why the Gram–Schmidt subtraction makes each new residual orthogonal to every earlier normalized vector, and prove that the resulting normalized vectors are orthonormal.

Intermediate 9 min read

What You'll Learn

  • State the Gram–Schmidt recursion and when its normalized outputs are defined
  • Prove by induction that each residual is orthogonal to all earlier normalized vectors
  • Explain how orthonormality of earlier outputs makes the subtraction cancel
  • Verify the orthonormality of the normalized outputs
  • Use the correct projection coefficient when the inner product is linear in the first slot

The Claim Behind the Recursion

Gram–Schmidt builds vectors one at a time. At each step, it subtracts from the new input its components in the directions of the normalized vectors already produced. The central claim of this tutorial is that this subtraction does what it is meant to do: the new residual is orthogonal to every earlier normalized output. The proof is an induction, because the cancellation at each step depends on the earlier outputs being orthonormal.

Let \(V\) be a finite-dimensional inner product space over \(\mathbb{F}\), where \(\mathbb{F}\) is \(\mathbb{R}\) or \(\mathbb{C}\). We use the convention that the inner product is linear in its first slot and conjugate-linear in its second slot. The norm is \(\|\mathbf{v}\|=\sqrt{\langle\mathbf{v},\mathbf{v}\rangle}\). Vectors \(\mathbf{x}\) and \(\mathbf{y}\) are orthogonal when \(\langle\mathbf{x},\mathbf{y}\rangle=0\). A list is orthonormal if every vector has norm \(1\) and every two distinct vectors in the list are orthogonal.

Definition: Given inputs \(\mathbf{v}_1,\dots,\mathbf{v}_p\), define the Gram–Schmidt residuals recursively by \(\mathbf{r}_1=\mathbf{v}_1\) and, for \(k\ge2\), by \(\mathbf{r}_k=\mathbf{v}_k-\sum_{j=1}^{k-1}\langle\mathbf{v}_k,\mathbf{q}_j\rangle\mathbf{q}_j\). Whenever \(\mathbf{r}_k\ne\mathbf{0}\), define the normalized output \(\mathbf{q}_k=\mathbf{r}_k/\|\mathbf{r}_k\|\). Thus, to define all \(p\) normalized outputs by this recursion, each residual must be nonzero.

The coefficient in each subtraction is determined by our inner-product convention. If \(\mathbf{q}_j\) has norm \(1\), then subtracting \(c\mathbf{q}_j\) changes the inner product with \(\mathbf{q}_j\) to \(\langle\mathbf{v}_k-c\mathbf{q}_j,\mathbf{q}_j\rangle=\langle\mathbf{v}_k,\mathbf{q}_j\rangle-c\). Here we used linearity in the first slot and \(\langle\mathbf{q}_j,\mathbf{q}_j\rangle=1\). Choosing \(c=\langle\mathbf{v}_k,\mathbf{q}_j\rangle\) cancels that inner product. The induction proof shows that all the subtractions work together, not just one at a time.

The Induction Proof

Theorem: Suppose the Gram–Schmidt recursion above produces nonzero residuals \(\mathbf{r}_1,\dots,\mathbf{r}_p\). Then, for each \(k\ge2\), \(\mathbf{r}_k\) is orthogonal to every earlier normalized output \(\mathbf{q}_1,\dots,\mathbf{q}_{k-1}\). Consequently, \(\mathbf{q}_1,\dots,\mathbf{q}_p\) is an orthonormal list.

Proof. We use induction on the number of outputs constructed. For the first output, \(\mathbf{q}_1=\mathbf{r}_1/\|\mathbf{r}_1\|\), so \(\|\mathbf{q}_1\|=1\). There are no earlier vectors to test against, so the orthogonality claim at this stage has no cases.

Now suppose \(2\le k\le p\), and assume that \(\mathbf{q}_1,\dots,\mathbf{q}_{k-1}\) are orthonormal. Fix any index \(i\) with \(1\le i<k\). Using the recursion and linearity in the first slot gives

$$ \begin{aligned} \langle\mathbf{r}_k,\mathbf{q}_i\rangle &=\left\langle\mathbf{v}_k-\sum_{j=1}^{k-1}\langle\mathbf{v}_k,\mathbf{q}_j\rangle\mathbf{q}_j,\mathbf{q}_i\right\rangle\\ &=\langle\mathbf{v}_k,\mathbf{q}_i\rangle- \sum_{j=1}^{k-1}\langle\mathbf{v}_k,\mathbf{q}_j\rangle \langle\mathbf{q}_j,\mathbf{q}_i\rangle. \end{aligned} $$

By the induction hypothesis, \(\langle\mathbf{q}_j,\mathbf{q}_i\rangle=0\) when \(j\ne i\), and \(\langle\mathbf{q}_i,\mathbf{q}_i\rangle=1\). Therefore every term in the sum vanishes except the term with \(j=i\), which equals \(\langle\mathbf{v}_k,\mathbf{q}_i\rangle\). Hence \(\langle\mathbf{r}_k,\mathbf{q}_i\rangle=\langle\mathbf{v}_k,\mathbf{q}_i\rangle-\langle\mathbf{v}_k,\mathbf{q}_i\rangle=0\). Since \(i\) was any index less than \(k\), the residual is orthogonal to every earlier output.

Because \(\mathbf{r}_k\ne\mathbf{0}\), its norm is positive and \(\mathbf{q}_k=\mathbf{r}_k/\|\mathbf{r}_k\|\) is defined. Its norm is \(1\), since dividing a vector by its norm gives a unit vector. Also, for each \(i<k\), conjugate-linearity in the second slot gives \(\langle\mathbf{q}_k,\mathbf{q}_i\rangle=\langle\mathbf{r}_k,\mathbf{q}_i\rangle/\|\mathbf{r}_k\|=0\). Thus the list through \(\mathbf{q}_k\) is orthonormal, which supplies the induction hypothesis needed at the next step. Induction proves the claim for every \(k\). \(\square\)

The proof has two linked parts. First, orthonormality of the earlier outputs makes the sum in the inner product collapse to exactly one term. Second, normalizing a nonzero residual preserves its orthogonality to those earlier outputs and gives the new output norm \(1\). Both parts are needed for the induction to continue.

Worked Examples of the Cancellation

Worked Example: Two Inputs in R²

Apply Gram–Schmidt to \(\mathbf{v}_1=(1,1)\) and \(\mathbf{v}_2=(1,0)\), using the usual dot product.

The first residual is \(\mathbf{r}_1=(1,1)\), with \(\|\mathbf{r}_1\|=\sqrt{2}\). Therefore \(\mathbf{q}_1=(1,1)/\sqrt{2}\). The coefficient for the second step is

$$ \langle\mathbf{v}_2,\mathbf{q}_1\rangle =(1,0)\cdot\frac{(1,1)}{\sqrt{2}} =\frac{1}{\sqrt{2}}. $$

Subtract that coefficient times \(\mathbf{q}_1\):

$$ \mathbf{r}_2 =(1,0)-\frac{1}{\sqrt{2}}\frac{(1,1)}{\sqrt{2}} =(1,0)-\left(\frac12,\frac12\right) =\left(\frac12,-\frac12\right). $$

The residual has norm \(\sqrt{1/4+1/4}=1/\sqrt{2}\), so \(\mathbf{q}_2=(1,-1)/\sqrt{2}\). Check the claimed orthogonality and the two unit norms:

$$ \mathbf{r}_2\cdot\mathbf{q}_1 =\frac{1}{2\sqrt{2}}-\frac{1}{2\sqrt{2}}=0,\qquad \|\mathbf{q}_1\|^2=\|\mathbf{q}_2\|^2=1,\qquad \mathbf{q}_2\cdot\mathbf{q}_1=\frac12-\frac12=0. $$

The calculation displays the induction step directly: the subtracted component is precisely what makes the residual’s inner product with the earlier unit vector vanish.

Worked Example: Three Successive Residuals in R³

Take \(\mathbf{v}_1=(1,0,0)\), \(\mathbf{v}_2=(1,1,0)\), and \(\mathbf{v}_3=(1,1,1)\), with the usual dot product. Compute each residual and check it against all earlier normalized outputs.

First, \(\mathbf{r}_1=(1,0,0)\), so \(\|\mathbf{r}_1\|=1\) and \(\mathbf{q}_1=(1,0,0)\). Next, \(\langle\mathbf{v}_2,\mathbf{q}_1\rangle=1\), giving

$$ \mathbf{r}_2=(1,1,0)-1(1,0,0)=(0,1,0),\qquad \mathbf{q}_2=(0,1,0). $$

Now \(\langle\mathbf{v}_3,\mathbf{q}_1\rangle=1\) and \(\langle\mathbf{v}_3,\mathbf{q}_2\rangle=1\). The next residual subtracts both earlier components:

$$ \mathbf{r}_3=(1,1,1)-(1,0,0)-(0,1,0)=(0,0,1),\qquad \mathbf{q}_3=(0,0,1). $$

For the first residual check, \(\mathbf{r}_2\cdot\mathbf{q}_1=(0,1,0)\cdot(1,0,0)=0\). For the second, \(\mathbf{r}_3\cdot\mathbf{q}_1=(0,0,1)\cdot(1,0,0)=0\) and \(\mathbf{r}_3\cdot\mathbf{q}_2=(0,0,1)\cdot(0,1,0)=0\). Each output has norm \(1\), and the same dot products show that the outputs are mutually orthogonal. In the last step, both terms in the recursion are required: checking against only one earlier vector would not verify the full claim.

Worked Example: A Complex Inner Product

Use \(\langle\mathbf{x},\mathbf{y}\rangle=x_1\overline{y_1}+x_2\overline{y_2}\), which is linear in the first slot, on \(\mathbb{C}^2\). Let \(\mathbf{v}_1=(1,i)\) and \(\mathbf{v}_2=(1,1)\).

Since \(\|\mathbf{v}_1\|^2=1+|i|^2=2\), the first normalized output is \(\mathbf{q}_1=(1,i)/\sqrt{2}\). The coefficient for the next subtraction is

$$ \langle\mathbf{v}_2,\mathbf{q}_1\rangle =\frac{1}{\sqrt{2}}+\frac{\overline{i}}{\sqrt{2}} =\frac{1-i}{\sqrt{2}}. $$

Multiplying this coefficient by \(\mathbf{q}_1\) gives \(((1-i)/2,(1+i)/2)\). Thus

$$ \mathbf{r}_2 =(1,1)-\left(\frac{1-i}{2},\frac{1+i}{2}\right) =\left(\frac{1+i}{2},\frac{1-i}{2}\right). $$

Each component of \(\mathbf{r}_2\) has squared modulus \(1/2\), so \(\|\mathbf{r}_2\|^2=1\) and \(\mathbf{q}_2=\mathbf{r}_2\). Directly check orthogonality, using conjugates in the second slot:

$$ \langle\mathbf{r}_2,\mathbf{q}_1\rangle =\frac{1+i}{2\sqrt{2}}+ \frac{(1-i)(-i)}{2\sqrt{2}} =\frac{1+i}{2\sqrt{2}}-\frac{1+i}{2\sqrt{2}}=0. $$

Also \(\|\mathbf{q}_1\|=\|\mathbf{q}_2\|=1\). The explicit check agrees with the theorem and shows why the conjugation convention matters.

Why These Coefficients Are Forced

Proposition: Let \(\mathbf{q}_1,\dots,\mathbf{q}_m\) be an orthonormal list in an inner product space over \(\mathbb{F}\), and let \(\mathbf{v}\) be any vector in the space. For scalars \(c_1,\dots,c_m\), the vector \(\mathbf{v}-\sum_{j=1}^{m}c_j\mathbf{q}_j\) is orthogonal to every \(\mathbf{q}_i\) if and only if \(c_i=\langle\mathbf{v},\mathbf{q}_i\rangle\) for every \(i\).

Proof. Put \(\mathbf{w}=\mathbf{v}-\sum_{j=1}^{m}c_j\mathbf{q}_j\). For each \(i\), linearity in the first slot and orthonormality give \(\langle\mathbf{w},\mathbf{q}_i\rangle=\langle\mathbf{v},\mathbf{q}_i\rangle-\sum_{j=1}^{m}c_j\langle\mathbf{q}_j,\mathbf{q}_i\rangle=\langle\mathbf{v},\mathbf{q}_i\rangle-c_i\). If \(\mathbf{w}\) is orthogonal to every \(\mathbf{q}_i\), this expression is zero for each \(i\), so \(c_i=\langle\mathbf{v},\mathbf{q}_i\rangle\). Conversely, if all these coefficient equalities hold, the displayed expression is zero for each \(i\), so \(\mathbf{w}\) is orthogonal to every vector in the list. This proves both directions. \(\square\)

This proposition explains the subtraction rule: among sums using the earlier orthonormal vectors, the coefficients that make the remainder orthogonal to each of them are exactly the inner products in the recursion. At stage \(k\), the induction hypothesis supplies the orthonormal list needed to apply this calculation.

Common Mistake: Reversing the Complex Inner Product

In \(\mathbb{C}^2\) with the convention used above, a tempting mistake is to use \(\langle\mathbf{q}_1,\mathbf{v}_2\rangle\) as the coefficient instead of \(\langle\mathbf{v}_2,\mathbf{q}_1\rangle\). For the complex example, these values are \((1+i)/\sqrt{2}\) and \((1-i)/\sqrt{2}\), respectively. They are conjugates, not equal. Using the reversed coefficient gives the incorrect proposed residual

$$ \widetilde{\mathbf{r}}_2 =(1,1)-\frac{1+i}{\sqrt{2}}\frac{(1,i)}{\sqrt{2}} =\left(\frac{1-i}{2},\frac{3-i}{2}\right). $$

It fails the required test:

$$ \langle\widetilde{\mathbf{r}}_2,\mathbf{q}_1\rangle =\frac{1-i}{2\sqrt{2}}+\frac{(3-i)(-i)}{2\sqrt{2}} =-\sqrt{2}\,i\ne0. $$

The correction is to keep the vector being adjusted in the first slot: with the stated convention, the coefficient is \(\langle\mathbf{v}_2,\mathbf{q}_1\rangle\). In a real inner product, reversing the slots does not change the value, so this particular error can go unnoticed in real calculations. The complex check exposes it.

The orthogonality result has a precise scope. It guarantees that each defined residual is orthogonal to the earlier normalized outputs; it does not by itself guarantee that a residual is nonzero. If a residual is zero, the division needed to define its normalized output is unavailable, and the induction proceeds only through the outputs that are defined.

Check Your Understanding

Use the convention that the inner product is linear in its first slot.

  1. In the induction step, why does the sum for \(\langle\mathbf{r}_k,\mathbf{q}_i\rangle\) retain only its \(j=i\) term?
  2. For \(\mathbf{q}_1=(1,0)\) and \(\mathbf{v}_2=(2,3)\) in \(\mathbb{R}^2\), compute the coefficient and residual, then verify orthogonality.
  3. In a complex inner product space, which coefficient does the stated convention place in the Gram–Schmidt recursion?
  4. Why is nonzero residual required to define the normalized output \(\mathbf{q}_k\)?
  5. State both directions of the proposition about the coefficients that make a remainder orthogonal to an orthonormal list.

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