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 system, and the reason was that the model's columns were oblique — the -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 -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 the projection of any vector is
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 changes nothing about the 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:
They are independent — their determinant is not zero — so they are a basis of , just not a convenient one.
The determinant of the three starting vectors is , so by the Invertible Matrix Theorem they are independent and span . Nothing is wrong with this basis except its angles: , not , 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, . Then take and remove the part of it that points along — its projection — leaving only what is perpendicular:
using and . Check the result: , as intended.
Explore in 3D (opens in a new tab)Explore the figure
- At the blue vector is and the two arrows meet at an obviously acute angle. This is the awkward basis you started with.
- Drag to . The blue vector swings to 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.
- 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 , which is itself in the sheet.
- 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:
The dot products are against , giving coefficient ; and against , giving coefficient . So
and the three are now mutually perpendicular: , and .
Notice that subtracting the projection did not disturb the work already done — because and 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.