Any real matrix A with linearly independent columns can be factored as a product QR, where the columns of Q are orthonormal (the inner product of any two different columns is 0, and the inner product of any column with itself is 1) and R is invertible and upper-right triangular. If the original matrix A is square, then so is Q. In this case, Q is an orthogonal matrix.
To obtain the QR factorization
Matrices + QR
=
![]()
The two matrices Q and A = QR have the same column spaces. Observe, in the following example, that the columns of A are linear combinations of the columns of Q. Then, since both column spaces have dimension 2 and one contains the other, it follows that they must be the same space.
This conversion of the columns of A into the orthonormal columns of Q is referred to as the Gram–Schmidt orthogonalization process. In general, since R is upper-right triangular, the subspace spanned by the first k columns of the matrix A = QR is the same as the subspace spanned by the first k columns of the matrix Q.