When basis vectors come out of real data or a system of equations, they are usually at awkward angles and have uneven lengths, so we need a way to replace them with perpendicular unit vectors that span the exact same space.
Why We Want an Orthonormal Basis
An orthonormal basis is a set of basis vectors that are orthogonal (at 90∘ angles to each other, so moving along one axis has zero effect on your position along the others) and normalized (each scaled to a unit vector of length 1). Gram-Schmidt builds an orthonormal basis one vector at a time.
1
Building an Orthonormal Basis in 2D
Given two vectors a and b that span a flat 2D plane, we want to build two perpendicular unit vectors q1 and q2 that span that same plane.
How Gram-Schmidt Works in 2D
The first direction has nothing to be perpendicular to yet, so we get our first axis q1 simply by dividing a by its length:
q1=∥a∥a
The second vector b is tilted toward q1. Because q1 is already a unit vector, the shadow of b along the line of q1 is (b⋅q1)q1: it has length ∣b⋅q1∣, and it points in the direction of q1 when b⋅q1 is positive and the opposite way when b⋅q1 is negative. Subtracting this projection removes all of b's movement along the first axis, leaving only the piece perpendicular to q1:
bperp=b−projection onto q1(b⋅q1)q1
Dividing that perpendicular piece by its length gives the second unit vector:
q2=∥bperp∥bperp
Try dragging b around the plane to see how bperp and q2 stay at a 90∘ angle to q1, and what happens when b lines up directly with q1.
Removing the shadow of the second vector along the first axis leaves a piece that always sits at a right angle to it, giving us our second axis.
Let's use these steps to find an orthonormal basis q1,q2 for the plane spanned by a=⟨3,4⟩ and b=⟨−1,7⟩.
2D Example: Orthonormalizing Two Vectors
Text solution
Normalize a to get q1Find the length of a=⟨3,4⟩ and divide a by that length to make our first unit vector.
∥a∥=32+42=9+16=25=5
q1=∥a∥a=51⟨3,4⟩=⟨53,54⟩
Find the projection of b onto q1Take the dot product of b=⟨−1,7⟩ with the unit vector q1 to get the projection's length, then multiply that number by q1.
b⋅q1=⟨−1,7⟩⋅⟨53,54⟩=−53+528=525=5
(b⋅q1)q1=5⟨53,54⟩=⟨3,4⟩
Subtract the projection from bSubtract the projection vector from b to keep only the piece perpendicular to q1.
bperp=b−(b⋅q1)q1=⟨−1,7⟩−⟨3,4⟩=⟨−4,3⟩
Normalize bperp to get q2Divide the perpendicular vector bperp by its length to turn it into a unit vector.
∥bperp∥=(−4)2+32=16+9=25=5
q2=∥bperp∥bperp=51⟨−4,3⟩=⟨−54,53⟩
So q1=⟨53,54⟩ and q2=⟨−54,53⟩ are perpendicular unit vectors that span the exact same plane as a and b.
2
Extending Gram-Schmidt to 3D
When we have three vectors a,b, and c in 3D space, the first two vectors give us two perpendicular unit axes q1 and q2, and we now want a third unit vector q3 that is perpendicular to both q1 and q2, and therefore perpendicular to the entire plane they span.
Extending Gram-Schmidt to 3D
Because c is tilted toward both q1 and q2, we subtract its projections onto both unit vectors to remove its entire shadow in the q1–q2 plane:
cperp=c−projection onto the q1–q2 plane((c⋅q1)q1+(c⋅q2)q2)=c−(c⋅q1)q1−(c⋅q2)q2
Dividing the remaining vertical piece by its length gives the third unit vector:
q3=∥cperp∥cperp
Move c parallel to the plane at a fixed height to see how its two axis projections add up to its shadow in the plane, leaving cperp and q3 at a 90∘ angle to the plane.
Because the two axes are at right angles, a vector's projections along each axis change on their own and add up to its full shadow in the plane, so subtracting both leaves only the part perpendicular to the plane.
Now let's find an orthonormal basis q1,q2,q3 for the 3D space spanned by a=⟨1,2,2⟩,b=⟨3,3,0⟩, and c=⟨6,3,3⟩.
3D Example: Orthonormalizing Three Vectors
abcq1,q2,q3=⟨1,2,2⟩=⟨3,3,0⟩=⟨6,3,3⟩=?
Text solution
Normalize a to get q1Divide a=⟨1,2,2⟩ by its length to get the first unit axis.
∥a∥=12+22+22=9=3
q1=∥a∥a=31⟨1,2,2⟩=⟨31,32,32⟩
Subtract the projection of b onto q1 and normalize to get q2Subtract the projection of b=⟨3,3,0⟩ onto q1, then divide the remaining perpendicular piece by its length.
b⋅q1=⟨3,3,0⟩⋅⟨31,32,32⟩=1+2+0=3
(b⋅q1)q1=3⟨31,32,32⟩=⟨1,2,2⟩
bperp=⟨3,3,0⟩−⟨1,2,2⟩=⟨2,1,−2⟩
∥bperp∥=22+12+(−2)2=9=3
q2=∥bperp∥bperp=31⟨2,1,−2⟩=⟨32,31,−32⟩
Subtract the projections of c onto both q1 and q2Project c=⟨6,3,3⟩ onto each of the first two unit axes and subtract both projections from c.
c⋅q1=⟨6,3,3⟩⋅⟨31,32,32⟩=2+2+2=6
(c⋅q1)q1=6⟨31,32,32⟩=⟨2,4,4⟩
c⋅q2=⟨6,3,3⟩⋅⟨32,31,−32⟩=4+1−2=3
(c⋅q2)q2=3⟨32,31,−32⟩=⟨2,1,−2⟩
cperp=⟨6,3,3⟩−⟨2,4,4⟩−⟨2,1,−2⟩=⟨2,−2,1⟩
Normalize cperp to get q3Divide cperp by its length to get the third unit vector.
∥cperp∥=22+(−2)2+12=9=3
q3=∥cperp∥cperp=31⟨2,−2,1⟩=⟨32,−32,31⟩
So q1=⟨31,32,32⟩,q2=⟨32,31,−32⟩, and q3=⟨32,−32,31⟩ form an orthonormal basis for 3D space, where every vector has length 1 and any pair has dot product 0.
3
Avoiding Square Roots by Normalizing at the End
In the first two examples, the lengths happened to be whole numbers (5 and 3). Most of the time, the very first vector has a length like 3, and normalizing right away means carrying square roots through every dot product. Or sometimes a question only asks for an orthogonal basis without needing unit vectors at all. Either way, we can find unnormalized orthogonal vectors u1,u2,u3 first and save normalizing for the very end.
When an axis vector u is not a unit vector, projecting b onto u divides by u⋅u=∥u∥2 to adjust for its length:
Projection of b onto u=∥u∥2u⋅ub⋅uu
Because u⋅u is the length squared, the square root disappears completely during the projection steps. Let's use this to find orthogonal vectors from a=⟨1,1,1⟩,b=⟨1,2,3⟩, and c=⟨1,5,3⟩.
Avoiding Square Roots by Normalizing at the End
abcu1,u2,u3=⟨1,1,1⟩=⟨1,2,3⟩=⟨1,5,3⟩=?
Text solution
Keep a as the first orthogonal vector u1Leave a=⟨1,1,1⟩ at its original length so we do not bring 3 into the dot products.
u1=⟨1,1,1⟩
Subtract the projection of b onto u1 to get u2Project b=⟨1,2,3⟩ onto the unnormalized vector u1 by dividing b⋅u1 by u1⋅u1, then subtract that projection from b.
Subtract the projections of c onto u1 and u2 to get u3Project c=⟨1,5,3⟩ onto both u1 and u2 using their squared lengths u1⋅u1 and u2⋅u2, then subtract both projections from c.
The vectors u1=⟨1,1,1⟩,u2=⟨−1,0,1⟩, and u3=⟨−1,2,−1⟩ give an orthogonal basis using only whole-number arithmetic, and dividing by their lengths gives the orthonormal basis q1,q2,q3. (On a test, check carefully whether the question asks for an orthogonal basis or an orthonormal basis so you don't do the final square-root step when it isn't asked for.)
4
When a Vector Collapses to Zero
Sometimes subtracting a vector's projections onto the earlier axes cancels the vector out completely, leaving the zero vector ⟨0,0,0⟩. Let's see what that zero result tells us about the vectors and their span.
Keeping a=⟨1,1,1⟩ and b=⟨1,2,3⟩ from the last problem, so we already have u1=⟨1,1,1⟩ and u2=⟨−1,0,1⟩, let's replace the third vector with c=⟨0,3,6⟩.
When a Vector Collapses to Zero
u1u2cu3=⟨1,1,1⟩=⟨−1,0,1⟩=⟨0,3,6⟩=?
cu3=⟨1,5,3⟩=c−⟨3,3,3⟩−⟨−1,0,1⟩=⟨−1,2,−1⟩
cu3=⟨0,3,6⟩=c−⟨3,3,3⟩−⟨−3,0,3⟩=⟨0,0,0⟩
Text solution
Keep u1 and u2 from the first two vectorsSince a=⟨1,1,1⟩ and b=⟨1,2,3⟩ have not changed, the first two perpendicular axes are still u1=⟨1,1,1⟩ (with u1⋅u1=3) and u2=⟨−1,0,1⟩ (with u2⋅u2=2).
Subtract the projections of c onto u1 and u2Project c=⟨0,3,6⟩ onto both u1 and u2 and subtract those projections from c.
c⋅u1=⟨0,3,6⟩⋅⟨1,1,1⟩=0+3+6=9
(u1⋅u1c⋅u1)u1=39⟨1,1,1⟩=⟨3,3,3⟩
c⋅u2=⟨0,3,6⟩⋅⟨−1,0,1⟩=0+0+6=6
(u2⋅u2c⋅u2)u2=26⟨−1,0,1⟩=⟨−3,0,3⟩
u3=⟨0,3,6⟩−⟨3,3,3⟩−⟨−3,0,3⟩=⟨0,0,0⟩
Discard the zero vectorBecause ⟨0,0,0⟩ has length 0 and adds no new direction, throw it away and keep only u1 and u2.
Getting ⟨0,0,0⟩ means c equals its own shadow in the u1–u2 plane, so c=3b−3a was already sitting inside the plane of a and b. All three vectors span only that 2D plane in 3D space, with orthogonal basis u1=⟨1,1,1⟩ and u2=⟨−1,0,1⟩.
Key concepts
Gram-Schmidt builds perpendicular axes one vector at a time by taking the next vector and subtracting its projections onto every perpendicular axis built so far.
Choosing whether to normalize as you go or at the end
Check the length ∥a∥ of the first vector before you start.
Whole-number lengths (normalize as you go): When ∥a∥ is a whole number (such as a=⟨3,4⟩ with ∥a∥=5), divide by the length right away to get q1=⟨53,54⟩ and project using unit-vector dot products:
When not to normalize as you go (square-root lengths or orthogonal-only questions): When ∥a∥ is a square root (such as a=⟨1,1,1⟩ with ∥a∥=3) or the problem only asks for an orthogonal basis, leave u1=a unnormalized and, in each projection, divide the dot product by u⋅u so the squared length gets rid of the square root:
When not to subtract a projection, or when to discard a vector
If a dot product is already 0 (for example, b⋅u1=0), the vector is already at 90∘ to that axis and its projection term is zero. If subtracting all projections cancels a vector down to ⟨0,0,0⟩ (as with c=⟨0,3,6⟩ giving u3=⟨0,0,0⟩), that vector is just a combination of the earlier ones, so throw it away and never include ⟨0,0,0⟩ in a basis.
5
Practice
1
Use Gram-Schmidt to find an orthonormal basis q1,q2 for the plane spanned by a=⟨4,−3⟩ and b=⟨2,11⟩.
Check the length of a first: is ∥a∥ a whole number so that you can normalize a into q1 right away?
Find the length of a and normalize to get q1:
∥a∥=42+(−3)2=25=5⟹q1=⟨54,−53⟩
Take the dot product of b with q1 to find the projection onto q1:
b⋅q1=⟨2,11⟩⋅⟨54,−53⟩=58−33=−5
(b⋅q1)q1=−5⟨54,−53⟩=⟨−4,3⟩
Subtract the projection from b (watch the negative sign on b⋅q1=−5: dropping the minus sign and subtracting ⟨4,−3⟩ instead of ⟨−4,3⟩ is the most common mistake, which leads to the wrong vector ⟨−2,14⟩):
bperp=⟨2,11⟩−⟨−4,3⟩=⟨6,8⟩
Normalize bperp (which has length 62+82=10):
q1q2=⟨54,−53⟩,=⟨53,54⟩
2
Find an orthonormal basis q1,q2,q3 for the space spanned by a=⟨2,2,1⟩,b=⟨3,0,3⟩, and c=⟨7,1,2⟩.
Normalize a to get q1 and build q2 from b first, then remember that c is tilted toward both q1 and q2.
Normalize a (length 22+22+12=3):
q1=⟨32,32,31⟩
Subtract the projection of b onto q1, using b⋅q1=⟨3,0,3⟩⋅⟨32,32,31⟩=3:
Project c onto both q1 and q2, with c⋅q1=6 and c⋅q2=3 (be careful to project c onto the new perpendicular unit vector q2 rather than onto the original vector b, and do not forget to subtract the q2 projection ⟨1,−2,2⟩, or you will get ⟨3,−3,0⟩ and the wrong third vector ⟨21,−21,0⟩):
Given a=⟨1,0,1⟩,b=⟨2,1,0⟩, and c=⟨2,3,2⟩, first find an orthogonal basis u1,u2,u3 without normalizing as you go, then normalize at the end to get an orthonormal basis q1,q2,q3.
Don't forget to divide by u1⋅u1: treating u1 as a unit vector and subtracting 2u1=⟨2,0,2⟩ is a common mistake here, giving the wrong vector ⟨0,1,−2⟩.
Set u1=a, and when projecting onto an unnormalized vector uk, what do you divide the dot product by so no square roots appear?
Keep u1=⟨1,0,1⟩, which has u1⋅u1=12+02+12=2.
For b=⟨2,1,0⟩, we have b⋅u1=2. Divide by u1⋅u1=2 (don't forget to divide by u1⋅u1: treating u1 as a unit vector and subtracting 2u1=⟨2,0,2⟩ is a common mistake here, giving the wrong vector ⟨0,1,−2⟩):
Find an orthogonal basis for the space spanned by a=⟨1,1,2⟩,b=⟨2,0,2⟩, and c=⟨−1,5,4⟩, and describe the space they span.
Use the unnormalized projection formula starting with u1=a, and see what remains of c once you subtract its projections onto u1 and u2.
Set u1=⟨1,1,2⟩, which has u1⋅u1=12+12+22=6.
Since b⋅u1=2+0+4=6, subtract the projection of b onto u1:
u2=⟨2,0,2⟩−66⟨1,1,2⟩=⟨1,−1,0⟩(with u2⋅u2=2)
For c=⟨−1,5,4⟩, we have c⋅u1=−1+5+8=12 and c⋅u2=−1−5+0=−6. Subtract both projections (watch the minus sign on 2−6u2=⟨−3,3,0⟩: adding ⟨−3,3,0⟩ instead of subtracting it gives ⟨−6,6,0⟩ and misses the collapse to zero, and never keep ⟨0,0,0⟩ as a third basis vector):
Because u3 collapses to ⟨0,0,0⟩,c lies in the plane of a and b and is discarded; the space spanned is a 2D plane in 3D space with orthogonal basis u1=⟨1,1,2⟩ and u2=⟨1,−1,0⟩.