The Gram-Schmidt Process

Suppose you have a list of linearly independent vectors in an inner product space. They are neither orthogonal nor of unit length. Can you systematically rebuild them into an orthonormal list? The goal is to do this without losing any geometric information they encode. This is the question the Gram–Schmidt process answers. It does so with a striking guarantee. At every intermediate step, a key property holds. The span of the first kk new orthonormal vectors equals the span of the first kk original vectors. The importance of this cannot be overstated. Orthonormal bases are the setting where coordinates, norms, and inner products all take their simplest form. A vector's coordinates are just inner products with basis vectors. The Pythagorean theorem also holds in full generality. But arbitrary bases arising "in the wild" are almost never orthonormal. These arise from solving differential equations, from data, or from a change of coordinates. Gram–Schmidt is the bridge between these cases. It is an explicit, constructive algorithm. It converts any linearly independent list into an orthonormal one. It uses only the inner product itself. The big picture is that this single procedure is important. It is the engine behind several landmark facts in linear algebra. It proves that every finite-dimensional inner product space has an orthonormal basis. It underlies the QR factorization of a matrix. This factorization is a computational cornerstone of numerical linear algebra. It gives the theoretical construction of orthogonal projections onto subspaces. It is also the machinery behind least-squares approximation. This article gives the precise construction. It proves the fundamental theorem with full rigor. That theorem is orthonormality plus span-preservation at every stage. The article also works through the subtleties. It considers what changes if the input vectors are only spanning, not independent. It examines what happens over the real numbers versus the complex numbers. Finally, it shows where the process is used. This includes applications across mathematics, statistics, and engineering.

Key takeaways
  • Gram–Schmidt converts a linearly independent list (v1,…,vn)(v_1,\dots,v_n) into an orthonormal list (e1,…,en)(e_1,\dots,e_n).
  • At every stage kk, span(e1,…,ek)=span(v1,…,vk)\mathrm{span}(e_1,\dots,e_k) = \mathrm{span}(v_1,\dots,v_k) — this is the defining feature, not an afterthought.
  • The construction is recursive: subtract off the projection onto the span so far, then normalize.
  • It proves every finite-dimensional inner product space has an orthonormal basis.
  • Applied to the columns of a matrix, it produces the QR factorization used in numerical computation.
  • Key idea: orthogonalize by subtracting projections onto everything built so far, one vector at a time.

Where this lives today

The Gram–Schmidt process is the theoretical proof, and a practical algorithm, behind the QR factorization of a matrix: writing A=QRA = QR with QQ orthogonal (or unitary) and RR upper triangular, used to solve least-squares problems, compute eigenvalues via the QR algorithm, and stabilize numerical linear algebra computations. In statistics, orthogonalizing regressors via Gram–Schmidt underlies sequential (Type I) sums of squares and the construction of orthogonal polynomial regression bases. In numerical analysis and approximation theory, applying the process to the monomials 1,x,x2,…1,x,x^2,\dots on an interval with a weighted inner product produces classical families of orthogonal polynomials, such as Legendre and Chebyshev polynomials. In quantum mechanics and more broadly in the theory of Hilbert spaces, Gram–Schmidt constructs orthonormal bases of state spaces from convenient but non-orthogonal spanning sets. In signal processing and coding theory, orthogonalizing a set of basis signals or codewords (as in some lattice reduction and precoding schemes) relies on the same recursive projection-and-subtract idea, and modified variants of the algorithm are used for numerically stable orthogonalization in large-scale linear algebra software.

Ask the tutor: How does the Gram-Schmidt process change if I only need an orthogonal (not orthonormal) list, and why might I prefer to skip normalization until the end?

DefinitionThe Gram–Schmidt Process

Let VV be an inner product space over F\mathbb{F} (where F=R\mathbb{F} = \mathbb{R} or F=C\mathbb{F} = \mathbb{C}), with inner product ⟨⋅,⋅⟩\langle \cdot,\cdot\rangle conjugate-linear in the second slot (or linear, if F=R\mathbb F=\mathbb R) and norm ∥v∥=⟨v,v⟩\|v\| = \sqrt{\langle v,v\rangle}. Let (v1,…,vn)(v_1,\dots,v_n) be a linearly independent list of vectors in VV. Define vectors e1,…,ene_1,\dots,e_n recursively as follows. Set

e1=v1∥v1∥.e_1 = \frac{v_1}{\|v_1\|}.

Having defined e1,…,ek−1e_1,\dots,e_{k-1} for some 2≤k≤n2 \le k \le n, set

uk=vk−∑j=1k−1⟨vk,ej⟩ ej,ek=uk∥uk∥.u_k = v_k - \sum_{j=1}^{k-1} \langle v_k, e_j\rangle\, e_j, \qquad e_k = \frac{u_k}{\|u_k\|}.

The list (e1,…,en)(e_1,\dots,e_n) produced by this recursion is called the Gram–Schmidt orthonormalization of (v1,…,vn)(v_1,\dots,v_n).

Intuition

Picture building an orthonormal list one vector at a time, always working inside the growing subspace spanned by the vectors processed so far. The first vector v1v_1 only needs rescaling: divide by its length to make it a unit vector e1e_1. This changes nothing about direction. The second vector v2v_2 is not generally orthogonal to e1e_1. But we can decompose v2v_2 into a piece parallel to e1e_1 and a piece orthogonal to it: the parallel piece is the orthogonal projection ⟨v2,e1⟩e1\langle v_2, e_1\rangle e_1, and subtracting it off leaves the orthogonal remainder u2=v2−⟨v2,e1⟩e1u_2 = v_2 - \langle v_2,e_1\rangle e_1. Normalizing u2u_2 gives e2e_2, a unit vector orthogonal to e1e_1 and lying in span(v1,v2)\mathrm{span}(v_1,v_2). The pattern repeats: at stage kk, subtract from vkv_k its projection onto the entire subspace spanned by the previously constructed orthonormal vectors e1,…,ek−1e_1,\dots,e_{k-1}. What remains, uku_k, is orthogonal to all of e1,…,ek−1e_1,\dots,e_{k-1} by construction, and it is nonzero precisely because vkv_k was not already in span(v1,…,vk−1)\mathrm{span}(v_1,\dots,v_{k-1}) — this is exactly where linear independence is used. Normalizing produces eke_k. The crucial invariant, illustrated below, is that no information about the span is ever lost: span(e1,…,ek)\mathrm{span}(e_1,\dots,e_k) always equals span(v1,…,vk)\mathrm{span}(v_1,\dots,v_k), so the new orthonormal list "sits inside" the old flag of subspaces at every stage.

Figure
Two independent vectors in the plane orthogonalized by Gram–Schmidt
v₁ = (3,0) v₂ = (2.7,2.3) ⟨v₂,e₁⟩e₁ u₂ = v₂ − ⟨v₂,e₁⟩e₁ e₁ e₂ e₁ = v₁/‖v₁‖, e₂ = u₂/‖u₂‖
TheoremGram–Schmidt Orthonormalization

Let VV be an inner product space over F\mathbb{F} and let (v1,…,vn)(v_1,\dots,v_n) be a linearly independent list in VV. Let (e1,…,en)(e_1,\dots,e_n) be the list produced by the Gram–Schmidt process applied to (v1,…,vn)(v_1,\dots,v_n). Then: 1. (Well-definedness) At every stage k=1,…,nk = 1,\dots,n, the vector uku_k (and hence eke_k) is well defined, meaning uk≠0u_k \ne 0, so division by ∥uk∥\|u_k\| never divides by zero. 2. (Orthonormality) The list (e1,…,en)(e_1,\dots,e_n) is orthonormal: ∥ek∥=1\|e_k\| = 1 for all kk, and ⟨ei,ej⟩=0\langle e_i, e_j\rangle = 0 for i≠ji \ne j. 3. (Span preservation) For every k=1,…,nk = 1,\dots,n,

span(e1,…,ek)=span(v1,…,vk).\mathrm{span}(e_1,\dots,e_k) = \mathrm{span}(v_1,\dots,v_k).

4. (Triangularity of coefficients) For every kk, vk∈span(e1,…,ek)v_k \in \mathrm{span}(e_1,\dots,e_k) with

vk=∑j=1k⟨vk,ej⟩ ej+rk,in fact rk=0,v_k = \sum_{j=1}^{k} \langle v_k, e_j \rangle\, e_j + r_k, \qquad \text{in fact } r_k = 0,

so that vkv_k is an explicit linear combination of e1,…,eke_1,\dots,e_k with the coefficient of eke_k equal to ∥uk∥>0\|u_k\| > 0.

Proof

We prove all four claims simultaneously by strong induction on kk, using the technique of induction with a compound inductive hypothesis: at stage kk we assume claims (1)–(3) hold for all indices less than kk, and deduce them for kk.

Base case k=1k=1. Since (v1,…,vn)(v_1,\dots,v_n) is linearly independent, in particular v1≠0v_1 \ne 0 (a list containing the zero vector is linearly dependent). Hence ∥v1∥>0\|v_1\| > 0 and e1=v1/∥v1∥e_1 = v_1/\|v_1\| is well defined. Clearly ∥e1∥=∥v1∥/∥v1∥=1\|e_1\| = \|v_1\|/\|v_1\| = 1, giving orthonormality of the singleton list (e1)(e_1) (there are no distinct pairs to check). Since e1e_1 is a nonzero scalar multiple of v1v_1, span(e1)=span(v1)\mathrm{span}(e_1) = \mathrm{span}(v_1). Finally v1=∥v1∥e1=⟨v1,e1⟩e1v_1 = \|v_1\| e_1 = \langle v_1, e_1\rangle e_1 since ⟨v1,e1⟩=⟨v1,v1/∥v1∥⟩=∥v1∥\langle v_1,e_1\rangle = \langle v_1, v_1/\|v_1\|\rangle = \|v_1\| (using conjugate-linearity in the second slot, and that ∥v1∥∈R\|v_1\|\in\mathbb R). This establishes (1)–(4) for k=1k=1.

Inductive step. Fix kk with 2≤k≤n2 \le k \le n, and assume (1)–(4) hold for all indices 1,…,k−11,\dots,k-1; in particular (e1,…,ek−1)(e_1,\dots,e_{k-1}) is a well-defined orthonormal list with

span(e1,…,ek−1)=span(v1,…,vk−1).\mathrm{span}(e_1,\dots,e_{k-1}) = \mathrm{span}(v_1,\dots,v_{k-1}).

Step A: uku_k is well defined, i.e. uk≠0u_k \neq 0. By definition,

uk=vk−∑j=1k−1⟨vk,ej⟩ej.u_k = v_k - \sum_{j=1}^{k-1} \langle v_k, e_j\rangle e_j.

The sum ∑j=1k−1⟨vk,ej⟩ej\sum_{j=1}^{k-1} \langle v_k,e_j\rangle e_j is a linear combination of e1,…,ek−1e_1,\dots,e_{k-1}, hence lies in span(e1,…,ek−1)=span(v1,…,vk−1)\mathrm{span}(e_1,\dots,e_{k-1}) = \mathrm{span}(v_1,\dots,v_{k-1}) by the inductive hypothesis. If uku_k were 00, then vkv_k would equal this sum, and thus vk∈span(v1,…,vk−1)v_k \in \mathrm{span}(v_1,\dots,v_{k-1}). But then vkv_k would be a linear combination of v1,…,vk−1v_1,\dots,v_{k-1}, contradicting the linear independence of (v1,…,vn)(v_1,\dots,v_n) (a linearly independent list has no vector in the span of the others). Hence uk≠0u_k \ne 0, so ∥uk∥>0\|u_k\| > 0 and ek=uk/∥uk∥e_k = u_k / \|u_k\| is well defined. Step B: orthogonality of eke_k with each eie_i, i<ki < k. Fix i∈{1,…,k−1}i \in \{1,\dots,k-1\}. Using linearity of the inner product in the first slot and the inductive orthonormality of e1,…,ek−1e_1,\dots,e_{k-1} (so ⟨ej,ei⟩=0\langle e_j, e_i \rangle = 0 for j≠ij \ne i and ⟨ei,ei⟩=1\langle e_i,e_i\rangle = 1):

⟨uk,ei⟩=⟨vk,ei⟩−∑j=1k−1⟨vk,ej⟩⟨ej,ei⟩=⟨vk,ei⟩−⟨vk,ei⟩⋅1=0.\langle u_k, e_i \rangle = \langle v_k, e_i \rangle - \sum_{j=1}^{k-1} \langle v_k, e_j\rangle \langle e_j, e_i\rangle = \langle v_k, e_i\rangle - \langle v_k, e_i\rangle \cdot 1 = 0.

Since eke_k is a positive scalar multiple of uku_k, we get ⟨ek,ei⟩=1∥uk∥⟨uk,ei⟩=0\langle e_k, e_i\rangle = \frac{1}{\|u_k\|}\langle u_k,e_i\rangle = 0. Combined with the inductive orthonormality of (e1,…,ek−1)(e_1,\dots,e_{k-1}), this shows (e1,…,ek)(e_1,\dots,e_k) is orthonormal — every pairwise inner product among indices ≤k\le k vanishes, and ∥ek∥=∥uk∥/∥uk∥=1\|e_k\| = \|u_k\|/\|u_k\| = 1. This proves (2) for kk. Step C: span preservation. We show the two inclusions. (⊆\subseteq) Each eje_j for j≤k−1j \le k-1 lies in span(v1,…,vk−1)⊆span(v1,…,vk)\mathrm{span}(v_1,\dots,v_{k-1}) \subseteq \mathrm{span}(v_1,\dots,v_k) by the inductive hypothesis. Also,

ek=1∥uk∥(vk−∑j=1k−1⟨vk,ej⟩ej)e_k = \frac{1}{\|u_k\|}\left(v_k - \sum_{j=1}^{k-1}\langle v_k,e_j\rangle e_j\right)

is a linear combination of vkv_k and of e1,…,ek−1e_1,\dots,e_{k-1} (each of which is in span(v1,…,vk−1)\mathrm{span}(v_1,\dots,v_{k-1})), hence ek∈span(v1,…,vk)e_k \in \mathrm{span}(v_1,\dots,v_k). Since every eje_j, j≤kj\le k, lies in span(v1,…,vk)\mathrm{span}(v_1,\dots,v_k), so does their span: span(e1,…,ek)⊆span(v1,…,vk)\mathrm{span}(e_1,\dots,e_k) \subseteq \mathrm{span}(v_1,\dots,v_k). (⊇\supseteq) Each vjv_j for j≤k−1j \le k-1 lies in span(e1,…,ek−1)⊆span(e1,…,ek)\mathrm{span}(e_1,\dots,e_{k-1}) \subseteq \mathrm{span}(e_1,\dots,e_k) by the inductive hypothesis. Rearranging the definition of uku_k,

vk=∥uk∥ek+∑j=1k−1⟨vk,ej⟩ej,v_k = \|u_k\| e_k + \sum_{j=1}^{k-1} \langle v_k, e_j\rangle e_j,

which exhibits vkv_k as a linear combination of e1,…,eke_1,\dots,e_k, so vk∈span(e1,…,ek)v_k \in \mathrm{span}(e_1,\dots,e_k). Hence every vjv_j, j≤kj \le k, lies in span(e1,…,ek)\mathrm{span}(e_1,\dots,e_k), giving span(v1,…,vk)⊆span(e1,…,ek)\mathrm{span}(v_1,\dots,v_k) \subseteq \mathrm{span}(e_1,\dots,e_k). Together these inclusions give span(e1,…,ek)=span(v1,…,vk)\mathrm{span}(e_1,\dots,e_k) = \mathrm{span}(v_1,\dots,v_k), proving (3) for kk. Step D: the explicit formula (4). The equation displayed at the end of Step C,

vk=∑j=1k−1⟨vk,ej⟩ej+∥uk∥ek,v_k = \sum_{j=1}^{k-1} \langle v_k,e_j\rangle e_j + \|u_k\| e_k,

is exactly the claimed formula with coefficient of eke_k equal to ⟨vk,ek⟩=∥uk∥\langle v_k, e_k\rangle = \|u_k\| (check: ⟨vk,ek⟩=⟨uk+∑j<k⟨vk,ej⟩ej, ek⟩=⟨uk,ek⟩=∥uk∥⟨ek,ek⟩=∥uk∥\langle v_k,e_k\rangle = \langle u_k + \sum_{j<k}\langle v_k,e_j\rangle e_j,\, e_k\rangle = \langle u_k,e_k\rangle = \|u_k\|\langle e_k,e_k\rangle=\|u_k\|, using Step B's orthogonality). This is positive by Step A, and rk=0r_k = 0 exactly. This proves (4) for kk. By induction, claims (1)–(4) hold for every k=1,…,nk = 1,\dots,n, completing the proof. ■\blacksquare

∎
CorollaryExistence of an Orthonormal Basis

Every finite-dimensional inner product space VV with dim⁡V=n≥1\dim V = n \ge 1 has an orthonormal basis.

Proof

Since dim⁡V=n\dim V = n, VV has some basis (v1,…,vn)(v_1,\dots,v_n), which is in particular a linearly independent list. Apply the Gram–Schmidt process to obtain an orthonormal list (e1,…,en)(e_1,\dots,e_n) with, by part (3) of the theorem (at k=nk=n), span(e1,…,en)=span(v1,…,vn)=V\mathrm{span}(e_1,\dots,e_n) = \mathrm{span}(v_1,\dots,v_n) = V. An orthonormal list is automatically linearly independent (a standard fact: if ∑ciei=0\sum c_i e_i = 0, taking the inner product with eje_j gives cj=0c_j = 0 for each jj), so (e1,…,en)(e_1,\dots,e_n) is a linearly independent spanning list of size n=dim⁡Vn = \dim V, hence a basis. ■\blacksquare

∎

Worked examples

Example 1: an asymmetric list in R3\mathbb{R}^3. Let V=R3V = \mathbb{R}^3 with the standard inner product, and let

v1=(1,1,0),v2=(2,0,1),v3=(0,3,1).v_1 = (1,1,0), \qquad v_2 = (2,0,1), \qquad v_3 = (0,3,1).

First check linear independence: the matrix with these as rows,

(110201031),\begin{pmatrix} 1&1&0\\ 2&0&1\\ 0&3&1\end{pmatrix},

has determinant 1(0⋅1−1⋅3)−1(2⋅1−1⋅0)+0=1(−3)−1(2)+0=−5≠01(0\cdot1 - 1\cdot3) - 1(2\cdot1-1\cdot0) + 0 = 1(-3) - 1(2) + 0 = -5 \ne 0, so (v1,v2,v3)(v_1,v_2,v_3) is linearly independent.

Step 1. ∥v1∥=12+12+02=2\|v_1\| = \sqrt{1^2+1^2+0^2} = \sqrt2, so

e1=12(1,1,0).e_1 = \frac{1}{\sqrt2}(1,1,0).

Step 2. Compute ⟨v2,e1⟩=12(2⋅1+0⋅1+1⋅0)=22=2\langle v_2, e_1\rangle = \frac{1}{\sqrt2}(2\cdot1 + 0\cdot1 + 1\cdot0) = \frac{2}{\sqrt2} = \sqrt2. Then

u2=v2−2 e1=(2,0,1)−2⋅12(1,1,0)=(2,0,1)−(1,1,0)=(1,−1,1).u_2 = v_2 - \sqrt2\, e_1 = (2,0,1) - \sqrt2\cdot\frac{1}{\sqrt2}(1,1,0) = (2,0,1) - (1,1,0) = (1,-1,1).

Check orthogonality directly: ⟨u2,v1⟩=1⋅1+(−1)⋅1+1⋅0=0\langle u_2, v_1\rangle = 1\cdot1 + (-1)\cdot1 + 1\cdot0 = 0. Good. Now ∥u2∥=1+1+1=3\|u_2\| = \sqrt{1+1+1} = \sqrt3, so

e2=13(1,−1,1).e_2 = \frac{1}{\sqrt3}(1,-1,1).

Step 3. Compute ⟨v3,e1⟩=12(0⋅1+3⋅1+1⋅0)=32\langle v_3,e_1\rangle = \frac{1}{\sqrt2}(0\cdot1 + 3\cdot1 + 1\cdot0) = \frac{3}{\sqrt2}, and ⟨v3,e2⟩=13(0⋅1+3⋅(−1)+1⋅1)=−23\langle v_3, e_2\rangle = \frac{1}{\sqrt3}(0\cdot1 + 3\cdot(-1) + 1\cdot1) = \frac{-2}{\sqrt3}. Then

u3=v3−32e1−(−23)e2=(0,3,1)−32⋅12(1,1,0)+23⋅13(1,−1,1).u_3 = v_3 - \frac{3}{\sqrt2} e_1 - \left(\frac{-2}{\sqrt3}\right) e_2 = (0,3,1) - \frac{3}{\sqrt2}\cdot\frac{1}{\sqrt2}(1,1,0) + \frac{2}{\sqrt3}\cdot\frac{1}{\sqrt3}(1,-1,1).

Compute each piece: 32⋅12(1,1,0)=32(1,1,0)=(1.5,1.5,0)\frac{3}{\sqrt2}\cdot\frac{1}{\sqrt2}(1,1,0) = \frac{3}{2}(1,1,0) = (1.5, 1.5, 0), and 23⋅13(1,−1,1)=23(1,−1,1)=(2/3,−2/3,2/3)\frac{2}{\sqrt3}\cdot\frac{1}{\sqrt3}(1,-1,1) = \frac{2}{3}(1,-1,1) = (2/3, -2/3, 2/3). So

u3=(0,3,1)−(1.5,1.5,0)+(2/3,−2/3,2/3)=(−1.5+2/3,  1.5−2/3,  1+2/3).u_3 = (0,3,1) - (1.5,1.5,0) + (2/3,-2/3,2/3) = (-1.5 + 2/3,\; 1.5 - 2/3,\; 1 + 2/3).

Converting to thirds: −1.5=−3/2=−9/6-1.5 = -3/2 = -9/6, 2/3=4/62/3 = 4/6, sum =−5/6= -5/6. Similarly 1.5−2/3=9/6−4/6=5/61.5 - 2/3 = 9/6 - 4/6 = 5/6. And 1+2/3=5/3=10/61+2/3 = 5/3 = 10/6. So

u3=(−56,56,53)=56(−1,1,2).u_3 = \left(-\tfrac{5}{6}, \tfrac{5}{6}, \tfrac{5}{3}\right) = \tfrac{5}{6}(-1,1,2).

Sanity check: ⟨u3,e1⟩\langle u_3, e_1\rangle should be 00: 12(−56+56)=0\frac{1}{\sqrt2}(-\tfrac56 + \tfrac56) = 0. ✓. And ⟨u3,e2⟩=13(−56⋅1+56⋅(−1)+53⋅1)=13(−56−56+106)=13(0)=0\langle u_3,e_2\rangle = \frac{1}{\sqrt3}\left(-\tfrac56\cdot1 + \tfrac56\cdot(-1) + \tfrac{5}{3}\cdot1\right) = \frac{1}{\sqrt3}\left(-\tfrac56-\tfrac56+\tfrac{10}{6}\right) = \frac{1}{\sqrt3}(0) = 0. ✓ Now ∥u3∥=561+1+4=566\|u_3\| = \tfrac56\sqrt{1+1+4} = \tfrac56\sqrt6, so

e3=u3∥u3∥=56(−1,1,2)566=16(−1,1,2).e_3 = \frac{u_3}{\|u_3\|} = \frac{\tfrac56(-1,1,2)}{\tfrac56\sqrt6} = \frac{1}{\sqrt6}(-1,1,2).

Final answer:

e1=12(1,1,0),e2=13(1,−1,1),e3=16(−1,1,2).e_1 = \tfrac{1}{\sqrt2}(1,1,0),\quad e_2 = \tfrac{1}{\sqrt3}(1,-1,1),\quad e_3 = \tfrac{1}{\sqrt6}(-1,1,2).

One can verify span(e1,e2)=span(v1,v2)\mathrm{span}(e_1,e_2) = \mathrm{span}(v_1,v_2) by checking both v1,v2∈span(e1,e2)v_1,v_2 \in \mathrm{span}(e_1,e_2) (immediate from the recursion) and vice versa.

Example 2: a complex inner product space, C2\mathbb{C}^2. Let V=C2V=\mathbb{C}^2 with ⟨x,y⟩=x1y1‾+x2y2‾\langle x,y\rangle = x_1\overline{y_1} + x_2\overline{y_2} (linear in the first slot, conjugate-linear in the second). Take

v1=(1,i),v2=(2,1−i).v_1 = (1, i), \qquad v_2 = (2, 1-i).

Check independence: if c1v1+c2v2=0c_1 v_1 + c_2 v_2 = 0 then c1+2c2=0c_1 + 2c_2 = 0 and c1i+c2(1−i)=0c_1 i + c_2(1-i) = 0; substituting c1=−2c2c_1=-2c_2 into the second gives −2ic2+c2(1−i)=c2(1−3i)=0-2ic_2 + c_2(1-i) = c_2(1-3i) = 0, forcing c2=0c_2=0 (since 1−3i≠01-3i\ne0) and then c1=0c_1=0. So the list is independent.

Step 1. ∥v1∥2=1⋅1‾+ii‾=1+i(−i)=1+1=2\|v_1\|^2 = 1\cdot\overline1 + i\overline i = 1 + i(-i) = 1+1 = 2, so ∥v1∥=2\|v_1\|=\sqrt2 and

e1=12(1,i).e_1 = \frac{1}{\sqrt2}(1,i).

Step 2. Compute ⟨v2,e1⟩=12(2⋅1‾+(1−i)⋅i‾)=12(2+(1−i)(−i))\langle v_2, e_1\rangle = \frac{1}{\sqrt2}\left(2\cdot\overline{1} + (1-i)\cdot\overline{i}\right) = \frac{1}{\sqrt2}\left(2 + (1-i)(-i)\right). Compute (1−i)(−i)=−i+i2=−i−1(1-i)(-i) = -i + i^2 = -i - 1. So the bracket is 2+(−1−i)=1−i2 + (-1-i) = 1 - i. Thus

⟨v2,e1⟩=1−i2.\langle v_2,e_1\rangle = \frac{1-i}{\sqrt2}.

Then

u2=v2−⟨v2,e1⟩e1=(2, 1−i)−1−i2⋅12(1,i)=(2,1−i)−1−i2(1,i).u_2 = v_2 - \langle v_2,e_1\rangle e_1 = (2,\,1-i) - \frac{1-i}{\sqrt2}\cdot\frac{1}{\sqrt2}(1,i) = (2,1-i) - \frac{1-i}{2}(1,i).

Compute 1−i2(1,i)=(1−i2, i(1−i)2)=(1−i2, i+12)\frac{1-i}{2}(1,i) = \left(\frac{1-i}{2},\ \frac{i(1-i)}{2}\right) = \left(\frac{1-i}{2},\ \frac{i+1}{2}\right) (since i(1−i)=i−i2=i+1i(1-i) = i - i^2 = i+1). So

u2=(2−1−i2, (1−i)−1+i2)=(4−1+i2, 2(1−i)−(1+i)2)=(3+i2, 1−3i2).u_2 = \left(2 - \frac{1-i}{2},\ (1-i) - \frac{1+i}{2}\right) = \left(\frac{4-1+i}{2},\ \frac{2(1-i) - (1+i)}{2}\right) = \left(\frac{3+i}{2},\ \frac{1 - 3i}{2}\right).

Check orthogonality: ⟨u2,e1⟩\langle u_2, e_1\rangle should vanish. Using linearity in the first slot and conjugate-linearity in the second, since we already engineered this, we trust the algebra but verify numerically:

⟨u2,v1⟩=3+i2⋅1‾+1−3i2⋅i‾=3+i2+1−3i2⋅(−i).\langle u_2,v_1\rangle = \frac{3+i}{2}\cdot\overline1 + \frac{1-3i}{2}\cdot\overline{i} = \frac{3+i}{2} + \frac{1-3i}{2}\cdot(-i).

Compute 1−3i2⋅(−i)=−i+3i22=−i−32\frac{1-3i}{2}\cdot(-i) = \frac{-i + 3i^2}{2} = \frac{-i-3}{2}. Sum: 3+i2+−3−i2=0\frac{3+i}{2} + \frac{-3-i}{2} = 0. ✓ Now compute ∥u2∥2=∣3+i2∣2+∣1−3i2∣2=9+14+1+94=104+104=5\|u_2\|^2 = \left|\frac{3+i}{2}\right|^2 + \left|\frac{1-3i}{2}\right|^2 = \frac{9+1}{4} + \frac{1+9}{4} = \frac{10}{4}+\frac{10}{4} = 5. So ∥u2∥=5\|u_2\| = \sqrt5 and

e2=15(3+i2, 1−3i2)=125(3+i, 1−3i).e_2 = \frac{1}{\sqrt5}\left(\frac{3+i}{2},\ \frac{1-3i}{2}\right) = \frac{1}{2\sqrt5}\left(3+i,\ 1-3i\right).

This example illustrates the extra bookkeeping care required with the conjugate: the inner product ⟨v2,e1⟩\langle v_2,e_1\rangle is generally a complex number, and one must remember which slot is conjugate-linear when computing both the projection coefficient and its conjugate appearing in later verifications.

CounterexampleDropping linear independence breaks well-definedness

The hypothesis that (v1,…,vn)(v_1,\dots,v_n) is linearly independent is not a convenience — it is exactly what guarantees uk≠0u_k \ne 0 at every stage (Step A of the proof). Drop it, and the process can fail outright. Let V=R2V = \mathbb{R}^2 with the standard inner product, and consider the list

v1=(1,0),v2=(2,0).v_1 = (1,0), \qquad v_2 = (2,0).

This list is linearly dependent (v2=2v1v_2 = 2v_1), so it fails the theorem's hypothesis. Attempt the process anyway:

e1=v1∥v1∥=(1,0).e_1 = \frac{v_1}{\|v_1\|} = (1,0).

Then

u2=v2−⟨v2,e1⟩e1=(2,0)−2⋅(1,0)=(0,0).u_2 = v_2 - \langle v_2, e_1\rangle e_1 = (2,0) - 2\cdot(1,0) = (0,0).

Here u2=0u_2 = 0, so e2=u2/∥u2∥e_2 = u_2/\|u_2\| requires dividing by zero — the process is undefined at stage 2, not merely "orthonormal but span-violating." This is precisely the failure mode ruled out by Step A of the proof, which used linear independence in an essential, non-circumventable way: without it there is no contradiction available to conclude uk≠0u_k \ne 0. If one instead modifies the algorithm to simply discard vkv_k whenever uk=0u_k = 0 (a standard fix used when orthonormalizing a spanning but dependent list, in order to extract a basis), the resulting shorter list is still orthonormal, but the clean statement "span(e1,…,ek)=span(v1,…,vk)\mathrm{span}(e_1,\dots,e_k)=\mathrm{span}(v_1,\dots,v_k) for every kk" as stated in the theorem no longer holds for the original indexing — the theorem as proved genuinely requires independence of the full list.

Scope, edge cases & common traps

SituationWhat happens
(v1,…,vn)(v_1,\dots,v_n) linearly independentTheorem applies exactly as stated; (e1,…,en)(e_1,\dots,e_n) orthonormal, spans preserved at every stage.
(v1,…,vn)(v_1,\dots,v_n) linearly dependentProcess breaks down (division by zero) at the first index kk where vk∈span(v1,…,vk−1)v_k \in \mathrm{span}(v_1,\dots,v_{k-1}).
VV infinite-dimensional, list still finiteTheorem still applies verbatim — nothing in the proof used finite-dimensionality of VV, only finiteness of the list.
F=C\mathbb{F} = \mathbb{C}Works identically, but inner-product coefficients ⟨vk,ej⟩\langle v_k,e_j\rangle are complex; care needed with conjugate-linear slot conventions.
Order of the list changedA different permutation of (v1,…,vn)(v_1,\dots,v_n) generally produces a genuinely different orthonormal list (though always spanning the same total space) — span preservation is about initial segments, which depend on order.
Applying to columns of a matrix AAProduces the factorization A=QRA = QR with QQ having orthonormal columns and RR upper triangular with positive diagonal, directly from part (4) of the theorem.

The mathematician behind it

Origins · 1 minJørgen Pedersen Gram and how this was discovered
JP
Jørgen Pedersen Gram
1850–1916 · Danish actuary and mathematician

Jørgen Pedersen Gram worked as an actuary for a Danish insurance company and pursued mathematics largely outside formal academic institutions, publishing on probability, numerical analysis, and number theory (he made early computations related to the Riemann zeta function's zeros). Independently, Erhard Schmidt (1876–1959), a student of David Hilbert and a founder of modern functional analysis, formalized and popularized the orthogonalization procedure in his 1907 work on integral equations, where it became a foundational tool for what would become Hilbert space theory.

History
- 1883 — Gram's work on least squares and determinants contains the essential orthogonalization idea, applied to problems in numerical approximation.
- 1907 — Erhard Schmidt publishes the systematic orthogonalization procedure in the context of integral equations, in a paper foundational to Hilbert space theory.
- Early 20th c. — the method becomes standard machinery in the emerging theory of Hilbert spaces and functional analysis.
- Mid 20th c. — Gram–Schmidt becomes a core tool in numerical linear algebra, especially via the QR factorization of matrices.
- Late 20th c. — variants (modified Gram–Schmidt, Householder/Givens alternatives) are developed for numerical stability in floating-point computation.
Does Gram-Schmidt require the vector space to be finite-dimensional?

No. The process only requires the input list (v1,…,vn)(v_1,\dots,v_n) to be finite and linearly independent; it makes no reference to the dimension of the ambient space VV, which may be infinite-dimensional, as in many Hilbert spaces of functions. The proof, being an induction on the finite index k=1,…,nk=1,\dots,n, goes through unchanged. What does require finite-dimensionality is the corollary that every orthonormal basis of VV can be reached this way — in infinite dimensions, orthonormal bases require additional care (Zorn's-lemma-type arguments or completeness conditions), which is beyond the scope of the finite-list version treated here.

Does the order of the input vectors matter?

Yes, substantially. Gram–Schmidt applied to (v1,v2)(v_1,v_2) versus (v2,v1)(v_2,v_1) generally produces different orthonormal lists, even though both span the same two-dimensional subspace. The theorem's span-preservation guarantee is specifically about initial segments in the given order: span(e1,…,ek)=span(v1,…,vk)\mathrm{span}(e_1,\dots,e_k)=\mathrm{span}(v_1,\dots,v_k) for that particular ordering. Reordering the input list changes which intermediate subspaces are preserved, and generally changes every eke_k except when k=nk=n (the full span is order-independent).

What happens if two of the vectors are equal, or nearly parallel?

If two vectors are literally equal, the list is linearly dependent and the process breaks down exactly as in the counterexample: some uku_k becomes zero and division by zero occurs. If two vectors are merely nearly parallel (but the list remains independent), the process is still mathematically well defined, but in floating-point computation, catastrophic cancellation can occur when subtracting nearly equal quantities, causing severe loss of orthogonality in practice. This numerical instability is why the "classical" Gram–Schmidt described here is often replaced computationally by the mathematically equivalent but numerically superior "modified Gram–Schmidt" algorithm.

How does Gram-Schmidt relate to QR factorization?

If AA is an m×nm\times n matrix with linearly independent columns v1,…,vnv_1,\dots,v_n, applying Gram–Schmidt to these columns produces orthonormal vectors e1,…,ene_1,\dots,e_n. Part (4) of the theorem gives exactly vk=∑j≤k⟨vk,ej⟩ejv_k = \sum_{j\le k}\langle v_k,e_j\rangle e_j, which assembled into matrix form reads A=QRA = QR, where QQ has columns e1,…,ene_1,\dots,e_n (orthonormal) and RR is upper triangular with entries Rjk=⟨vk,ej⟩R_{jk} = \langle v_k,e_j\rangle for j≤kj\le k and diagonal entries Rkk=∥uk∥>0R_{kk} = \|u_k\| > 0. This is precisely the QR factorization, and the theorem's triangularity claim is the algebraic content that makes it upper triangular.

Is the orthonormal list produced by Gram-Schmidt unique?

Given a fixed ordered independent list (v1,…,vn)(v_1,\dots,v_n), the Gram–Schmidt recursion as defined here — with the convention that each eke_k is a positive multiple of uku_k — produces a unique orthonormal list. If one instead allowed eke_k to be any unit scalar multiple of uku_k (e.g. −ek-e_k, or in the complex case λek\lambda e_k for any ∣λ∣=1|\lambda|=1), one would get equally valid orthonormal lists with the same span-preservation property, so uniqueness genuinely depends on fixing a sign/phase convention, which is exactly the positivity requirement built into the theorem's formula for the diagonal coefficients.

Can Gram-Schmidt be used on a spanning list that is not independent, to extract a basis?

Yes, with a modification: process the vectors in order, and whenever the current vector's remainder uku_k turns out to be zero, simply discard that vector and move to the next one without incrementing the orthonormal list. The vectors kept form a linearly independent sublist (since discarding happens exactly when the current vector is in the span of the earlier kept ones), and the final orthonormal list spans the same space as the whole original list. This variant is a standard tool for pruning a spanning set down to a basis while simultaneously orthonormalizing it, though it is a modification of, not identical to, the theorem as stated for independent lists.

Before this

Where this leads