QR decomposition is a matrix factorization that expresses a matrix as , where has orthonormal columns and is upper triangular or upper trapezoidal, depending on the dimensions. For real matrices, a square is an orthogonal matrix; for complex matrices, it is a unitary matrix. A central tool in numerical linear algebra, QR decomposition converts problems involving general matrices into problems involving triangular matrices while preserving Euclidean lengths. (netlib.org)
Definition and forms
For with , the full QR decomposition has the form
where is and is and upper triangular. Here denotes the transpose, and is the identity matrix. Partitioning gives the reduced, thin, or economy-size decomposition
with of size . The reduced form omits columns unnecessary for reconstructing . (netlib.org)
For matrices over the complex numbers, transpose is replaced by conjugate transpose, written . QR also exists for wide matrices, where the full factor is upper trapezoidal: its entries below the main diagonal are zero, but it has more columns than rows. (netlib.org)
Every real matrix with admits QR decomposition, including rank-deficient matrices. If its columns are linearly independent, the reduced decomposition becomes unique when all diagonal entries of are required to be positive. Without this convention, corresponding columns of and rows of can change signs together. When , the remaining columns of full are not uniquely determined. (buttenschoen.ca)
Geometric interpretation
For a full-column-rank matrix, the columns of form an orthonormal basis for the span of the columns of . Writing and for individual columns,
Thus records the coordinates of the original columns in this orthonormal basis. Its triangular structure reflects the fact that the first original columns can be represented using the first basis vectors. The coefficients satisfy , an inner product. (buttenschoen.ca)
As a consequence, represents orthogonal projection onto the column space of . QR therefore separates the geometry of that space, represented by , from the coordinate relationships represented by . (buttenschoen.ca)
Computational methods
The Gram–Schmidt process constructs QR by subtracting projections onto previously obtained orthonormal vectors and normalizing the remainder. Classical Gram–Schmidt can lose substantial orthogonality in floating-point arithmetic. Modified Gram–Schmidt reorganizes the projections and generally behaves better, although reorthogonalization may still be necessary for demanding problems. (cs.cornell.edu)
Householder transformations eliminate entries below the diagonal one column at a time. In real arithmetic, a reflector can be written
A sequence of these orthogonal reflectors transforms into triangular form; their product determines . Householder QR is a standard dense-matrix method because of its numerical stability. (buttenschoen.ca)
Givens rotations act on two coordinates at a time to eliminate selected entries. They are useful when individual zeroing operations match the matrix structure or when an existing factorization needs updating. (cs.cornell.edu)
For dense real matrices with , Householder factorization without explicitly forming requires approximately floating-point operations. Its computational complexity is therefore . Implementations commonly store implicitly as reflector vectors; blocked algorithms apply groups of reflectors using matrix–matrix operations. (cs.utexas.edu)
Least-squares problems
QR solves the overdetermined problem underlying ordinary least squares and linear regression:
For full column rank, orthogonal invariance of the Euclidean norm gives
The second term is independent of . Consequently, the unique minimizer solves the triangular system
which is evaluated by back substitution. The residual norm is , so it can be obtained without explicitly constructing the residual vector. (netlib.org)
Unlike solving the normal equations , direct QR does not form . For full column rank, its spectral condition number satisfies . Avoiding this squaring helps prevent additional numerical difficulties, although QR cannot remove the original problem’s sensitivity to perturbations. (cs.cornell.edu)
Pivoting and numerical rank
Column-pivoted QR introduces a permutation matrix :
Columns are reordered to expose stronger independent directions earlier. When the rank is uncertain, partitioning into a leading well-conditioned block and a small trailing block helps estimate numerical rank. This estimate depends on tolerances and scaling; ordinary column pivoting is not a universal substitute for singular value decomposition. In rank-deficient least squares, a basic solution obtained from pivoted QR need not be the minimum-norm solution. (netlib.org)
Connection with eigenvalue algorithms
The QR algorithm repeatedly uses QR decomposition to compute eigenvalues and eigenvectors. Its basic unshifted step is
Because , successive matrices are related by similarity transformations and have the same eigenvalues. Practical implementations introduce shifts and exploit structured matrix forms to accelerate convergence toward a Schur decomposition. The factorization is thus a building block of the iterative QR algorithm, rather than the same operation. (cs.cornell.edu)