Write with having orthonormal columns and upper triangular. Gram-Schmidt on the columns of gives both: the unit vectors are , and the dot products and lengths it computes along the way are .
| Step | On | |
|---|---|---|
| 1 | Normalize the first column. and . | , |
| 2 | Dot the next column with the unit vectors found so far. Each goes above the diagonal in column of . | |
| 3 | Subtract and normalize. ; its length is , and . | , , |
| 4 | Assemble Q and R. The are the columns of ; the fill on and above the diagonal. | , |
| 5 | Check. and . The diagonal of must be positive. | ✓ |