The Gram–Schmidt Process Given a basis { x ⃗ 1 , … , x ⃗ p } \{ \vec{x}_1, \dots, \vec{x}_p \} { x 1 , … , x p } for a subspace W W W of R n \mathbb{R}^n R n , define:
v ⃗ 1 = x ⃗ 1 \vec{v}_1 = \vec{x}_1 v 1 = x 1
v ⃗ 2 = x ⃗ 2 − x ⃗ 2 ⋅ v ⃗ 1 v ⃗ 1 ⋅ v ⃗ 1 v ⃗ 1 \vec{v}_2 = \vec{x}_2 - \frac{\vec{x}_2 \cdot \vec{v}_1}{\vec{v}_1 \cdot \vec{v}_1}\vec{v}_1 v 2 = x 2 − v 1 ⋅ v 1 x 2 ⋅ v 1 v 1
v ⃗ 3 = x ⃗ 3 − x ⃗ 3 ⋅ v ⃗ 1 v ⃗ 1 ⋅ v ⃗ 1 v ⃗ 1 − x ⃗ 3 ⋅ v ⃗ 2 v ⃗ 2 ⋅ v ⃗ 2 v ⃗ 2 \vec{v}_3 = \vec{x}_3 - \frac{\vec{x}_3 \cdot \vec{v}_1}{\vec{v}_1 \cdot \vec{v}_1}\vec{v}_1 - \frac{\vec{x}_3 \cdot \vec{v}_2}{\vec{v}_2 \cdot \vec{v}_2}\vec{v}_2 v 3 = x 3 − v 1 ⋅ v 1 x 3 ⋅ v 1 v 1 − v 2 ⋅ v 2 x 3 ⋅ v 2 v 2
⋮ \vdots ⋮
v ⃗ p = x ⃗ p − x ⃗ p ⋅ v ⃗ 1 v ⃗ 1 ⋅ v ⃗ 1 v ⃗ 1 − x ⃗ p ⋅ v ⃗ 2 v ⃗ 2 ⋅ v ⃗ 2 v ⃗ 2 − ⋯ − x ⃗ p ⋅ v ⃗ p − 1 v ⃗ p − 1 ⋅ v ⃗ p − 1 v ⃗ p − 1 . \vec{v}_p = \vec{x}_p - \frac{\vec{x}_p \cdot \vec{v}_1}{\vec{v}_1 \cdot \vec{v}_1}\vec{v}_1 - \frac{\vec{x}_p \cdot \vec{v}_2}{\vec{v}_2 \cdot \vec{v}_2}\vec{v}_2 - \cdots - \frac{\vec{x}_p \cdot \vec{v}_{p-1}}{\vec{v}_{p-1} \cdot \vec{v}_{p-1}}\vec{v}_{p-1}. v p = x p − v 1 ⋅ v 1 x p ⋅ v 1 v 1 − v 2 ⋅ v 2 x p ⋅ v 2 v 2 − ⋯ − v p − 1 ⋅ v p − 1 x p ⋅ v p − 1 v p − 1 .
Then { v ⃗ 1 , … , v ⃗ p } \{ \vec{v}_1, \dots, \vec{v}_p \} { v 1 , … , v p } is an orthogonal basis for W W W . In addition:
Span { v ⃗ 1 , … , v ⃗ k } = Span { x ⃗ 1 , … , x ⃗ k } for 1 ≤ k ≤ p . \text{Span} \{ \vec{v}_1, \dots, \vec{v}_k \} = \text{Span} \{ \vec{x}_1, \dots, \vec{x}_k \} \quad \text{for } 1 \leq k \leq p. Span { v 1 , … , v k } = Span { x 1 , … , x k } for 1 ≤ k ≤ p .
The QR Factorization If A A A is an m × n m \times n m × n matrix with linearly independent columns, then A A A can be factored as A = Q R A = QR A = QR , where Q Q Q is an m × n m \times n m × n matrix whose columns form an orthonormal basis for Col A A A and R R R is an n × n n \times n n × n upper triangular invertible matrix with positive entries on its diagonal.