The Gram–Schmidt process converts a basis x₁, …, x_p of a subspace into an orthogonal basis of the same subspace. Keep the first vector; from each later vector subtract its projections onto the vectors already built, leaving only the part orthogonal to them. Dividing each result by its length gives an orthonormal basis. Recording the process in matrix form writes A = QR, with orthonormal columns in Q and an upper triangular R, a factorization that computers use to solve least-squares problems.
What you'll learn
Apply the Gram–Schmidt process to a basis
Normalize an orthogonal basis to an orthonormal one
Explain why each step keeps the same span
Form the QR factorization of a matrix with independent columns
Orthogonal bases turn coordinates and
projections into dot products, but the bases that come out of row reduction are
rarely orthogonal. The Gram–Schmidt process fixes that. Given a basis
x1,…,xp of a subspace W:
and so on: each new vector minus its projections onto every vector already
built. The result v1,…,vp is an orthogonal basis of
W. Dividing each by its length gives an orthonormal basis.
At step k, the vectors v1,…,vk−1 are already
orthogonal and span the same subspace as x1,…,xk−1.
The subtracted terms are exactly the
projection of xk onto
that subspace. So vk is the error of that projection, and the error
is orthogonal to the subspace. It is not zero, since xk is not in
the span of the earlier vectors. And vk differs from xk
by a combination of earlier vectors, so the span is unchanged. Each step
strips away the part of the new vector that the earlier ones already cover, and
what remains is orthogonal to all of them.
The coefficient is 21+3=2, so v2=(1,3)−(2,2)=(−1,1).
Normalize the answer to exercise 2.
Answer
21(1,1) and 21(−1,1)
Full solution
Both vectors have length 2.
Apply Gram–Schmidt to (1,0,1) and (2,1,0).
Answer
(1,0,1) and (1,1,−1)
Full solution
The coefficient is 22+0+0=1, so v2=(2,1,0)−(1,0,1)=(1,1,−1). Check: 1+0−1=0.
What does Gram–Schmidt produce from (1,2) and (2,4)?
Answer
(1,2) and the zero vector
Full solution
The second vector is twice the first, so its projection is itself and nothing is left. The span is only a line.
Why may (21,−21,1) be replaced by (1,−1,2) in the middle of the process?
Answer
Scaling keeps orthogonality and keeps the span.
Full solution
If u⋅v=0 then u⋅(cv)=0, and cv spans the same line as v for c=0. Later projections onto that line come out the same.
Is {21(1,1,0),61(1,−1,2),31(−1,1,1)} a basis of ℝ³?
Answer
Yes, an orthonormal one
Full solution
Three orthogonal nonzero vectors are independent, and three independent vectors in ℝ³ form a basis.
In Example 4, what is QTQ?
Answer
The identity matrix
Full solution
Its entries are the dot products of the columns of Q: 1 on the diagonal because they are unit vectors, and 0 off it because they are orthogonal.
Why is the factor R in A=QR upper triangular?
Answer
Each column of Q is orthogonal to every earlier column of A.
Full solution
Entry (i,j) of R=QTA is qi⋅xj. Gram–Schmidt makes qi orthogonal to x1,…,xi−1, so every entry below the diagonal is 0.
A student computes v3 by subtracting from x3 its projections onto x1 and x2. What went wrong?
Hint
Is {x1,x2} orthogonal?
Answer
The projections must be onto the orthogonal vectors v1 and v2.
Full solution
The sum of projections onto separate vectors equals the projection onto their span only when those vectors are orthogonal. With x1 and x2 the pieces overlap, and the result is not orthogonal to the span.
Frequently asked questions
What does the Gram–Schmidt process do?
It takes any basis of a subspace and produces an orthogonal basis of the same subspace, one vector at a time.
What is the formula for each step?
v_k = x_k minus the projections of x_k onto v₁, …, v_(k−1). Each projection is (x_k · v_j)/(v_j · v_j) v_j.
Can I rescale the vectors along the way?
Yes. Multiplying a vector by a nonzero number keeps it orthogonal to the others and keeps the span, so clearing fractions is safe.
What happens if the starting vectors are dependent?
At the step where a vector lies in the span of the earlier ones, subtracting its projections leaves the zero vector. That vector adds nothing and is dropped.
What is the QR factorization?
A = QR, where Q has orthonormal columns from Gram–Schmidt and R = QᵀA is upper triangular. It exists whenever A has independent columns.