📚 Linear Algebra, Interactive Edition
⇩ Download ▾

6.4 Orthogonal Sets and Gram-Schmidt

The least-squares computation of the last section was heavy in a specific way. Fitting a plane to seven points meant assembling the normal equations and solving a 3×3 system, and the reason was that the model's columns were oblique — the x-column overlapped both of the others, so no coefficient could be settled without settling the rest at once. (Not every pair was at fault: on that particular data the y-column and the column of ones happen to be orthogonal already. One oblique pair is enough to force the system.)

Suppose the spanning vectors had been mutually perpendicular. Then projecting onto their span would decompose completely: for an orthogonal set 𝐮1,,𝐮k the projection of any vector 𝐲 is

proj ( 𝐲 ) = 𝐲 · 𝐮 1 𝐮 1 · 𝐮 1 𝐮 1 + + 𝐲 · 𝐮 k 𝐮 k · 𝐮 k 𝐮 k

with each coefficient computed on its own, from two dot products, with no system to solve. The formula is right precisely because the vectors do not overlap: adding a multiple of 𝐮2 changes nothing about the 𝐮1 component, since their dot product is zero.

So it is worth having a way to manufacture orthogonality. Start with vectors that span what you want but sit at awkward angles:

𝐯 1 = ( 1 , 1 , 0 ) , 𝐯 2 = ( 1 , 0 , 1 ) , 𝐯 3 = ( 0 , 1 , 1 )

They are independent — their determinant is not zero — so they are a basis of 3, just not a convenient one.

2
A basis, but an awkward one ✓ Computed · mojocas 0.1.0 ✓ Agrees with the text A basis, but an awkward one, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.

The determinant of the three starting vectors is 2, so by the Invertible Matrix Theorem they are independent and span 3. Nothing is wrong with this basis except its angles: 𝐯1·𝐯2=1, not 0, so the vectors overlap and projections onto their span cannot be computed one coefficient at a time.

One step, watched

Gram-Schmidt fixes the angles one vector at a time. Keep the first vector as it is, 𝐮1=𝐯1. Then take 𝐯2 and remove the part of it that points along 𝐮1 — its projection — leaving only what is perpendicular:

𝐮 2 = 𝐯 2 𝐯 2 · 𝐮 1 𝐮 1 · 𝐮 1 𝐮 1 = ( 1 , 0 , 1 ) 1 2 ( 1 , 1 , 0 ) = ( 0.5 , 0.5 , 1 )

using 𝐯2·𝐮1=1 and 𝐮1·𝐮1=2. Check the result: 𝐮1·𝐮2=0.50.5+0=0, as intended.

A semi-transparent tilted plane holding two arrows that both start at a marked origin: a fixed red one and a blue one that swings as a slider is dragged. A short dashed gray arrow along the red one marks the projection of the blue vector onto it, and a dashed amber segment runs from the blue arrow's original tip to its current tip, showing the correction being removed. At the start of the slider the two arrows meet at a noticeably acute angle; at the end of the slider they meet at a right angle. Throughout, both arrows stay inside the same plane, so the pair always describes the same set of combinations.Explore in 3D (opens in a new tab)
The plane spanned by 𝐯1 and 𝐯2, with the red 𝐮1=(1,1,0) fixed and the blue vector swinging as the slider a subtracts more and more of the projection. The short dashed gray arrow along the red one is the projection (0.5,0.5,0) being removed, and the dashed amber segment joins the blue vector's original tip to its current one.

Explore the figure

  1. At a=0 the blue vector is 𝐯2=(1,0,1) and the two arrows meet at an obviously acute angle. This is the awkward basis you started with.
  2. Drag a to 1. The blue vector swings to (0.5,0.5,1)=𝐮2 and now meets the red one at a right angle. The dashed amber segment has grown to exactly the length of the gray projection arrow, but it points the opposite way: it runs from the old tip to the new, because the projection is being subtracted rather than added.
  3. Watch the plane while you drag, not the arrows. The blue vector stays inside the sheet the whole way. It has to: you only ever subtracted a multiple of 𝐮1, which is itself in the sheet.
  4. That is the property worth keeping. At every slider setting the red and blue vectors span the same plane, so Gram-Schmidt has changed the description without changing the thing described.

Doing all three

The third vector must be cleared of both previous directions, so subtract both projections:

𝐮 3 = 𝐯 3 𝐯 3 · 𝐮 1 𝐮 1 · 𝐮 1 𝐮 1 𝐯 3 · 𝐮 2 𝐮 2 · 𝐮 2 𝐮 2

The dot products are 𝐯3·𝐮1=1 against 𝐮1·𝐮1=2, giving coefficient 12; and 𝐯3·𝐮2=0(0.5)+1(0.5)+1(1)=0.5 against 𝐮2·𝐮2=0.25+0.25+1=1.5, giving coefficient 13. So

𝐮 3 = ( 0 , 1 , 1 ) 1 2 ( 1 , 1 , 0 ) 1 3 ( 0.5 , 0.5 , 1 ) = ( 2 3 , 2 3 , 2 3 )

and the three are now mutually perpendicular: 𝐮1·𝐮3=23+23+0=0, and 𝐮2·𝐮3=1313+23=0.

Notice that subtracting the 𝐮2 projection did not disturb the 𝐮1 work already done — because 𝐮1 and 𝐮2 are perpendicular, adding a multiple of one leaves the other's component untouched. Each step is safe from the steps before it, which is what makes the process work at all rather than chasing its own tail.

An original work of XYZ Homework, built around interactive XYZ 3D figures. Its chapter sequence is aligned to Interactive Linear Algebra (Margalit & Rabinoff, Georgia Tech, GNU FDL); this work is original, copies nothing from it, and is not affiliated with or endorsed by its authors. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.