Theorem 5.6.1 · Gram–Schmidt
Let be a basis for an inner product space . Define and, recursively,
Then is an orthonormal basis for , and each is orthogonal to everything built before it.
→Shortcut
By hand, don't normalise as you go. Compute the un-normalised first — everything stays rational and the square roots only appear at the very end.
Theorem 5.6.2 · Gram–Schmidt QR
If is with rank , then where is with orthonormal columns and is upper triangular with positive diagonal entries.
is upper triangular precisely because is built only from , so it has no component along later inputs.
Theorem 5.6.3 · Least squares via QR
With of rank , the unique least squares solution of solves
Substituting into the normal equations: and , then cancel the nonsingular . is triangular, so finish with back substitution — no inverse anywhere.
Worked example
0/5 stepsGram–Schmidt and QR on a matrix
Apply Gram–Schmidt to the columns of and write .
Check your work
Gram–Schmidt & QR
Columns of the matrix are the input vectors. The un-normalised vectors stay exact; Q and R are shown numerically because norms bring in square roots.
v₁ = x₁
| 1 |
| 1 |
| 1 |
| 1 |
v₂ = x₂ − (3/2)v₁
| -5/2 |
| 5/2 |
| 5/2 |
| -5/2 |
v₃ = x₃ − (1)v₁ − (-2/5)v₂
| 2 |
| -2 |
| 2 |
| -2 |
Q (orthonormal columns)
| 0.5 | -0.5 | 0.5 |
| 0.5 | 0.5 | -0.5 |
| 0.5 | 0.5 | 0.5 |
| 0.5 | -0.5 | -0.5 |
R (upper triangular, positive diagonal)
| 2 | 3 | 2 |
| 0 | 5 | -2 |
| 0 | 0 | 4 |
Check yourself
Q1
In Gram–Schmidt, the next vector is . What is ?
T / F
If is of rank and is its Gram–Schmidt factorization, then the least squares solution of satisfies .
T / F
Gram–Schmidt can be applied to any spanning set, independent or not, and always returns an orthonormal basis of the same size.