Tutorials › Linear Algebra › Gram-Schmidt for Three Vectors in R3

Orthogonal Sets and Gram-Schmidt · Tutorial 641 of 1000

Gram-Schmidt for Three Vectors in R3

Work through three-vector Gram–Schmidt calculations in \(\mathbb{R}^3\), from projection coefficients to a checked orthonormal list.

Intermediate 9 min read

What You'll Learn

  • Set up Gram–Schmidt for an ordered list of three independent vectors in \(\mathbb{R}^3\).
  • Compute the first and second residuals by subtracting projections onto earlier orthonormal vectors.
  • Find the exact norms and normalize each residual.
  • Check all three unit lengths and all three pairwise inner products.
  • Recognize and correct a projection-coefficient error.
  • See how changing the input order can change the resulting orthonormal list.

The Three-Vector Construction

Gram–Schmidt turns an ordered list of independent vectors into an orthonormal list by removing, one at a time, the components already accounted for. For three independent vectors in \(\mathbb{R}^3\), the first vector determines a direction; the second is adjusted to be perpendicular to that direction; and the third is adjusted to be perpendicular to both directions already obtained. Normalizing each nonzero result gives vectors of length \(1\).

All vectors here are columns in \(\mathbb{R}^3\), 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}}\). An ordered list is orthonormal when every vector has norm \(1\) and distinct vectors in the list have dot product \(0\). The order of the inputs matters: each subtraction uses the orthonormal vectors produced earlier in that order.

Definition: Given an ordered list of three independent vectors \(\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3\) in \(\mathbb{R}^3\), the Gram–Schmidt steps are $$ \mathbf{u}_1=\mathbf{v}_1,\qquad \mathbf{q}_1=\frac{\mathbf{u}_1}{\|\mathbf{u}_1\|}, $$ $$ \mathbf{u}_2=\mathbf{v}_2-(\mathbf{v}_2\cdot\mathbf{q}_1)\mathbf{q}_1,\qquad \mathbf{q}_2=\frac{\mathbf{u}_2}{\|\mathbf{u}_2\|}, $$ $$ \mathbf{u}_3=\mathbf{v}_3-(\mathbf{v}_3\cdot\mathbf{q}_1)\mathbf{q}_1-(\mathbf{v}_3\cdot\mathbf{q}_2)\mathbf{q}_2,\qquad \mathbf{q}_3=\frac{\mathbf{u}_3}{\|\mathbf{u}_3\|}. $$ The vectors \(\mathbf{u}_i\) are the residuals before normalization; the vectors \(\mathbf{q}_i\) are the normalized outputs.

The coefficient \(\mathbf{v}\cdot\mathbf{q}\) is the amount of a vector \(\mathbf{v}\) in the direction of a unit vector \(\mathbf{q}\). In the third step, both earlier directions must be removed, using the original \(\mathbf{v}_3\) in each coefficient. The calculations below display both subtractions explicitly rather than combining them into a single unexplained result.

Why the Subtractions Remove the Earlier Directions

Proposition: If \(\mathbf{q}_1,\mathbf{q}_2\) are orthonormal in \(\mathbb{R}^3\), then for any \(\mathbf{v}\in\mathbb{R}^3\), the residual $$ \mathbf{r}=\mathbf{v}-(\mathbf{v}\cdot\mathbf{q}_1)\mathbf{q}_1-(\mathbf{v}\cdot\mathbf{q}_2)\mathbf{q}_2 $$ is orthogonal to both \(\mathbf{q}_1\) and \(\mathbf{q}_2\).

Proof. Take the dot product of the displayed expression for \(\mathbf{r}\) with \(\mathbf{q}_1\). Bilinearity of the dot product and the equalities \(\mathbf{q}_1\cdot\mathbf{q}_1=1\), \(\mathbf{q}_2\cdot\mathbf{q}_1=0\) give $$ \mathbf{r}\cdot\mathbf{q}_1 =\mathbf{v}\cdot\mathbf{q}_1-(\mathbf{v}\cdot\mathbf{q}_1)(1)-(\mathbf{v}\cdot\mathbf{q}_2)(0)=0. $$ Taking the dot product with \(\mathbf{q}_2\), and using \(\mathbf{q}_1\cdot\mathbf{q}_2=0\), \(\mathbf{q}_2\cdot\mathbf{q}_2=1\), gives $$ \mathbf{r}\cdot\mathbf{q}_2 =\mathbf{v}\cdot\mathbf{q}_2-(\mathbf{v}\cdot\mathbf{q}_1)(0)-(\mathbf{v}\cdot\mathbf{q}_2)(1)=0. $$ Thus the residual is orthogonal to each of the two earlier vectors. \(\square\)

Theorem: If \(\mathbf{x}_1,\dots,\mathbf{x}_k\) are nonzero vectors in \(\mathbb{R}^3\), then their normalized list \(\mathbf{x}_i/\|\mathbf{x}_i\|\) is orthonormal if and only if the original list is orthogonal.

Proof. For each \(i\), \(\|\mathbf{x}_i/\|\mathbf{x}_i\|\|=1\), since \(\|\mathbf{x}_i\|>0\). For distinct \(i,j\), $$ \frac{\mathbf{x}_i}{\|\mathbf{x}_i\|}\cdot \frac{\mathbf{x}_j}{\|\mathbf{x}_j\|} =\frac{\mathbf{x}_i\cdot\mathbf{x}_j}{\|\mathbf{x}_i\|\|\mathbf{x}_j\|}. $$ The denominator is positive. Therefore the normalized vectors have dot product \(0\) exactly when \(\mathbf{x}_i\cdot\mathbf{x}_j=0\). This proves both directions: orthogonality of the original list gives orthonormality after normalization, and orthonormality of the normalized list implies orthogonality of the original vectors. \(\square\)

Worked Calculation: Three Independent Inputs

Worked Example: Two Successive Subtractions

Apply Gram–Schmidt to \(\mathbf{v}_1=(1,1,0)\), \(\mathbf{v}_2=(1,0,1)\), and \(\mathbf{v}_3=(0,1,1)\), in that order.

First, the vectors are independent: the determinant of the matrix with these columns is \(\det\begin{bmatrix}1&1&0\\1&0&1\\0&1&1\end{bmatrix}=-2\ne0\). Set \(\mathbf{u}_1=\mathbf{v}_1=(1,1,0)\). Its squared norm is \(1^2+1^2+0^2=2\), so \(\|\mathbf{u}_1\|=\sqrt{2}\) and \(\mathbf{q}_1=(1,1,0)/\sqrt{2}\).

For the second vector, its coefficient along \(\mathbf{q}_1\) is \(\mathbf{v}_2\cdot\mathbf{q}_1=(1+0+0)/\sqrt{2}=1/\sqrt{2}\). The component to subtract is therefore \((1/\sqrt{2})\mathbf{q}_1=(1/2,1/2,0)\), giving

$$ \mathbf{u}_2=(1,0,1)-\left(\frac12,\frac12,0\right) =\left(\frac12,-\frac12,1\right). $$

Its squared norm is \(1/4+1/4+1=3/2\), so its norm is \(\sqrt{6}/2\). Dividing each entry by that norm gives \(\mathbf{q}_2=(1,-1,2)/\sqrt{6}\).

For the third vector, first remove its component along \(\mathbf{q}_1\). The coefficient is \(\mathbf{v}_3\cdot\mathbf{q}_1=1/\sqrt{2}\), and that component is \((1/2,1/2,0)\). Next compute its coefficient along \(\mathbf{q}_2\): \(\mathbf{v}_3\cdot\mathbf{q}_2=(0-1+2)/\sqrt{6}=1/\sqrt{6}\). The second component is \((1/\sqrt{6})\mathbf{q}_2=(1,-1,2)/6\). Subtract both components:

$$ \begin{aligned} \mathbf{u}_3 &=(0,1,1)-\left(\frac12,\frac12,0\right) -\left(\frac16,-\frac16,\frac13\right)\\ &=\left(-\frac12,\frac12,1\right) -\left(\frac16,-\frac16,\frac13\right) =\left(-\frac23,\frac23,\frac23\right). \end{aligned} $$

The squared norm of \(\mathbf{u}_3\) is \(4/9+4/9+4/9=4/3\), so \(\|\mathbf{u}_3\|=2/\sqrt{3}\). Normalizing gives \(\mathbf{q}_3=(-1,1,1)/\sqrt{3}\).

Check: The squared lengths of \(\mathbf{q}_1,\mathbf{q}_2,\mathbf{q}_3\) are respectively \(2/2=1\), \(6/6=1\), and \(3/3=1\). Their pairwise dot products are \[ \mathbf{q}_1\cdot\mathbf{q}_2=\frac{1-1+0}{\sqrt{12}}=0,\quad \mathbf{q}_1\cdot\mathbf{q}_3=\frac{-1+1+0}{\sqrt{6}}=0,\quad \mathbf{q}_2\cdot\mathbf{q}_3=\frac{-1-1+2}{\sqrt{18}}=0. \] Thus the final list is orthonormal.

A Second Exact Calculation

Worked Example: A Different Set of Directions

Use Gram–Schmidt on \(\mathbf{v}_1=(1,0,1)\), \(\mathbf{v}_2=(1,1,0)\), \(\mathbf{v}_3=(0,1,1)\). The determinant of the matrix with these columns is \(2\), so the inputs are independent.

The first vector has norm \(\sqrt{2}\), giving \(\mathbf{q}_1=(1,0,1)/\sqrt{2}\). Since \(\mathbf{v}_2\cdot\mathbf{q}_1=1/\sqrt{2}\), subtract its component \((1/2,0,1/2)\): $$ \mathbf{u}_2=(1,1,0)-\left(\frac12,0,\frac12\right) =\left(\frac12,1,-\frac12\right). $$ Here \(\|\mathbf{u}_2\|^2=1/4+1+1/4=3/2\), so \(\mathbf{q}_2=(1,2,-1)/\sqrt{6}\).

For \(\mathbf{v}_3\), the coefficient along \(\mathbf{q}_1\) is \(1/\sqrt{2}\), giving component \((1/2,0,1/2)\). Its coefficient along \(\mathbf{q}_2\) is \((0+2-1)/\sqrt{6}=1/\sqrt{6}\), giving component \((1,2,-1)/6\). Consequently,

$$ \begin{aligned} \mathbf{u}_3 &=(0,1,1)-\left(\frac12,0,\frac12\right) -\left(\frac16,\frac13,-\frac16\right)\\ &=\left(-\frac23,\frac23,\frac23\right), \qquad \|\mathbf{u}_3\|=\frac{2}{\sqrt{3}}, \qquad \mathbf{q}_3=\frac{(-1,1,1)}{\sqrt{3}}. \end{aligned} $$

Check: Each \(\mathbf{q}_i\) has squared norm \(1\). The pairwise dot products have numerators \(1+0-1=0\), \(-1+0+1=0\), and \(-1+2-1=0\), respectively, over nonzero denominators. Hence these three outputs are orthonormal.

The Order of the Inputs Matters

Gram–Schmidt starts by preserving the direction of the first input, so changing the order can change the resulting orthonormal list. This is not a failure: the new list still consists of mutually perpendicular unit vectors. The next example reorders the first set and carries out the same checks.

Worked Example: Reordering the Same Three Vectors

Use the order \(\mathbf{v}_1=(1,1,0)\), \(\mathbf{v}_2=(0,1,1)\), \(\mathbf{v}_3=(1,0,1)\). These are the same independent vectors as in the first example, with the last two exchanged.

The first normalized vector remains \(\mathbf{q}_1=(1,1,0)/\sqrt{2}\). Since \(\mathbf{v}_2\cdot\mathbf{q}_1=1/\sqrt{2}\), the first subtraction gives \(\mathbf{u}_2=(0,1,1)-(1/2,1/2,0)=(-1/2,1/2,1)\). Its squared norm is \(1/4+1/4+1=3/2\), so \(\mathbf{q}_2=(-1,1,2)/\sqrt{6}\).

For the last input, the first coefficient is \(\mathbf{v}_3\cdot\mathbf{q}_1=1/\sqrt{2}\), producing \((1/2,1/2,0)\). The second coefficient is \(\mathbf{v}_3\cdot\mathbf{q}_2=(-1+2)/\sqrt{6}=1/\sqrt{6}\), producing \((-1,1,2)/6\). Thus

$$ \begin{aligned} \mathbf{u}_3 &=(1,0,1)-\left(\frac12,\frac12,0\right) -\left(-\frac16,\frac16,\frac13\right)\\ &=\left(\frac23,-\frac23,\frac23\right), \qquad \|\mathbf{u}_3\|=\frac{2}{\sqrt{3}}, \qquad \mathbf{q}_3=\frac{(1,-1,1)}{\sqrt{3}}. \end{aligned} $$

Check: The three squared norms are \(1\). The pairwise dot-product numerators are \( -1+1+0=0\), \(1-1+0=0\), and \(-1-1+2=0\), so the list is orthonormal. Its second and third vectors differ from those in the first calculation, as expected from the changed order.

Common Mistake: Omitting the Denominator

When subtracting a projection onto a vector that is not a unit vector, the coefficient must include a denominator. In the first calculation, \(\mathbf{u}_2=(1/2,-1/2,1)\) has squared norm \(3/2\), not \(1\). Also, \(\mathbf{v}_3\cdot\mathbf{u}_2=1/2\). A mistaken calculation might subtract \((1/2)\mathbf{u}_2\) directly, as though \(\mathbf{u}_2\) were a unit vector.

That mistake gives $$ \left(0,1,1\right)-\left(\frac12,\frac12,0\right) -\frac12\left(\frac12,-\frac12,1\right) =\left(-\frac34,\frac34,\frac12\right). $$ But its dot product with \(\mathbf{u}_2\) is \((-3/8)+(-3/8)+1/2=-1/4\ne0\), so it has not removed the component in that direction. The correct coefficient for subtracting along \(\mathbf{u}_2\) is \((\mathbf{v}_3\cdot\mathbf{u}_2)/(\mathbf{u}_2\cdot\mathbf{u}_2)=(1/2)/(3/2)=1/3\). Alternatively, normalize first and use the coefficient \(\mathbf{v}_3\cdot\mathbf{q}_2\). The two approaches agree when the coefficient and vector are paired correctly.

A Reliable Check at the End

For three outputs, a complete orthonormality check has six pieces: three norm calculations and three pairwise dot products. The norms confirm that the vectors were normalized; the dot products confirm that each subtraction removed the intended earlier directions. Checking only that each output has norm \(1\) is insufficient, because unit vectors need not be perpendicular.

The calculation is also order-sensitive. The first output is set by the first input, the second is determined after removing its component along the first, and the third is determined after removing two components. Use the ordered inputs consistently, keep each residual visible, and normalize only after completing its subtractions. If the inputs are independent, the Gram–Schmidt process applies with nonzero residuals; in a specific calculation, the displayed residuals and their norms make that check concrete.

Check Your Understanding

For each calculation, keep the vectors as columns and show the residual before normalizing.

  1. For \((1,0,1)\), \((0,1,1)\), \((1,1,0)\), find the three Gram–Schmidt outputs and check all pairwise dot products.
  2. In the first worked example, calculate \(\mathbf{v}_3\cdot\mathbf{q}_2\) directly from the coordinates of \(\mathbf{v}_3\) and \(\mathbf{q}_2\).
  3. Why does the coefficient for subtracting a component along a unit vector have no additional denominator?
  4. Give all three norm checks needed to confirm that a list of three vectors has unit length.
  5. Explain why changing the input order can change the outputs without preventing them from being orthonormal.

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