Gram-Schmidt
Orthonormalization
Transform any set of linearly independent vectors into an orthonormal basis using projection and normalization.
What Is an Orthonormal Basis?
A set of vectors \(\{e_1, e_2, \ldots, e_n\}\) forms an orthonormal basis if every pair is orthogonal (perpendicular) and every vector has unit length:
Why Orthonormal Bases Matter
Working in an orthonormal basis simplifies nearly every computation in linear algebra. Coordinates, projections, and decompositions all become trivial.
The Projection Idea
The heart of Gram-Schmidt is vector projection. To remove the component of \(v\) along a direction \(u\), subtract its projection:
The dashed line is the residual: the part of \(v\) perpendicular to \(u\). Gram-Schmidt collects these residuals one at a time.
The Gram-Schmidt Formula
Given linearly independent vectors \(\{v_1, v_2, \ldots, v_n\}\), produce orthogonal vectors \(\{u_1, u_2, \ldots, u_n\}\) and then normalize:
\(\displaystyle u_k = v_k - \sum_{j=1}^{k-1} \frac{\langle v_k, u_j \rangle}{\langle u_j, u_j \rangle}\, u_j\)
Visualizing the Process: Two Vectors
Orthogonal vs Orthonormal
| Orthogonal Set | Orthonormal Set | |
|---|---|---|
| Inner product | \(\langle u_i, u_j \rangle = 0\) for \(i \neq j\) | \(\langle e_i, e_j \rangle = 0\) for \(i \neq j\) |
| Vector length | Any nonzero length | \(\|e_i\| = 1\) exactly |
| Projection formula | \(\displaystyle \frac{\langle v,u\rangle}{\langle u,u\rangle}u\) | \(\langle v,e\rangle\, e\) (simpler!) |
| Matrix form | \(Q^TQ\) is diagonal | \(Q^TQ = I\) (identity) |
How to Apply Gram-Schmidt
Example 1: Two Vectors in \(\mathbb{R}^2\)
Orthonormalize \(v_1 = \begin{pmatrix}3\\1\end{pmatrix}\) and \(v_2 = \begin{pmatrix}2\\2\end{pmatrix}\).
\(\displaystyle \operatorname{proj}_{u_1}(v_2) = \frac{\langle v_2, u_1 \rangle}{\langle u_1, u_1 \rangle}\, u_1 = \frac{2\cdot3 + 2\cdot1}{9+1}\begin{pmatrix}3\\1\end{pmatrix} = \frac{8}{10}\begin{pmatrix}3\\1\end{pmatrix} = \begin{pmatrix}12/5\\4/5\end{pmatrix}\)
\(\displaystyle u_2 = v_2 - \operatorname{proj}_{u_1}(v_2) = \begin{pmatrix}2\\2\end{pmatrix} - \begin{pmatrix}12/5\\4/5\end{pmatrix} = \begin{pmatrix}-2/5\\6/5\end{pmatrix}\)
Example 1: Normalize
\(\|u_1\| = \sqrt{9+1} = \sqrt{10}\), so \(\displaystyle e_1 = \frac{1}{\sqrt{10}}\begin{pmatrix}3\\1\end{pmatrix}\)
\(\|u_2\| = \sqrt{4/25 + 36/25} = \sqrt{40/25} = \frac{2\sqrt{10}}{5}\), so \(\displaystyle e_2 = \frac{5}{2\sqrt{10}}\begin{pmatrix}-2/5\\6/5\end{pmatrix} = \frac{1}{\sqrt{10}}\begin{pmatrix}-1\\3\end{pmatrix}\)
Example 2: Three Vectors in \(\mathbb{R}^3\)
Orthonormalize: \(v_1 = \begin{pmatrix}1\\1\\0\end{pmatrix}\), \(v_2 = \begin{pmatrix}1\\0\\1\end{pmatrix}\), \(v_3 = \begin{pmatrix}0\\1\\1\end{pmatrix}\).
\(\langle v_2, u_1 \rangle = 1\), so \(\operatorname{proj}_{u_1}(v_2) = \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix}\).
\(u_2 = \begin{pmatrix}1\\0\\1\end{pmatrix} - \begin{pmatrix}1/2\\1/2\\0\end{pmatrix} = \begin{pmatrix}1/2\\-1/2\\1\end{pmatrix}\), with \(\|u_2\|^2 = \frac{3}{2}\).
Example 2: Finding \(u_3\) and Normalizing
\(\langle v_3, u_1 \rangle = 1\), \(\operatorname{proj}_{u_1}(v_3) = \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix}\).
\(\langle v_3, u_2 \rangle = -\frac{1}{2}+1 = \frac{1}{2}\), \(\operatorname{proj}_{u_2}(v_3) = \frac{1/2}{3/2}\begin{pmatrix}1/2\\-1/2\\1\end{pmatrix} = \begin{pmatrix}1/6\\-1/6\\1/3\end{pmatrix}\).
\(u_3 = \begin{pmatrix}0\\1\\1\end{pmatrix} - \begin{pmatrix}1/2\\1/2\\0\end{pmatrix} - \begin{pmatrix}1/6\\-1/6\\1/3\end{pmatrix} = \begin{pmatrix}-2/3\\2/3\\2/3\end{pmatrix}\).
\(e_1 = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix}\), \(e_2 = \sqrt{\frac{2}{3}}\begin{pmatrix}1/2\\-1/2\\1\end{pmatrix}\), \(e_3 = \frac{1}{2/\sqrt{3}}\begin{pmatrix}-2/3\\2/3\\2/3\end{pmatrix} = \frac{1}{\sqrt{3}}\begin{pmatrix}-1\\1\\1\end{pmatrix}\).
Connection to \(QR\) Decomposition
If we arrange the original vectors as columns of a matrix \(A = [v_1 \mid v_2 \mid \cdots \mid v_n]\), the Gram-Schmidt process yields:
The \(QR\) factorization is essential in least-squares problems, eigenvalue algorithms, and numerical stability.
Geometric View in \(\mathbb{R}^3\)
Common Mistakes
Summary Table
| Step | Operation | Result |
|---|---|---|
| 1 | \(u_1 = v_1\) | First orthogonal vector |
| 2 | \(u_k = v_k - \sum \operatorname{proj}_{u_j}(v_k)\) | Remove all previous directions |
| 3 | \(e_k = u_k / \|u_k\|\) | Scale to unit length |
| 4 | Verify \(\langle e_i, e_j \rangle = \delta_{ij}\) | Confirm orthonormality |
| 5 | Build \(Q = [e_1 \mid \cdots \mid e_n]\) | \(A = QR\) decomposition |
Question 1 of 5
What does the Gram-Schmidt process produce from a set of linearly independent vectors?
Question 2 of 5
Given \(u = \begin{pmatrix}2\\1\end{pmatrix}\) and \(v = \begin{pmatrix}1\\3\end{pmatrix}\), what is \(\operatorname{proj}_{u}(v)\)?
Question 3 of 5
If \(u_1\) and \(u_2\) are the orthogonal vectors produced by Gram-Schmidt, which property must hold?
Question 4 of 5
In the \(QR\) decomposition \(A = QR\), what is the structure of the matrix \(R\)?
Question 5 of 5
When computing \(u_3\) in Gram-Schmidt, how many projection terms must you subtract from \(v_3\)?