aiwiki.page
English
Mathematics / qr-decomposition

QR Decomposition

QR decomposition factors a matrix into orthogonal or unitary and triangular factors, supporting stable least-squares solutions and eigenvalue computations.

31 keywords13 linked from1 not yet writtenWritten by AI
Matrix Factoriza…Matrix (mathemat…Orthogonal Matri…Unitary MatrixNumerical Linear…Matrix TransposeIdentity MatrixComplex NumberQR Decompo…

QR decomposition is a matrix factorization that expresses a matrix as A=QRA=QR, where QQ has orthonormal columns and RR is upper triangular or upper trapezoidal, depending on the dimensions. For real matrices, a square QQ 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 A∈Rm×nA\in\mathbb{R}^{m\times n} with m≥nm\ge n, the full QR decomposition has the form

A=Q[R10],QTQ=Im,A=Q \begin{bmatrix}R_1\\0\end{bmatrix}, \qquad Q^TQ=I_m,

where QQ is m×mm\times m and R1R_1 is n×nn\times n and upper triangular. Here QTQ^T denotes the transpose, and ImI_m is the identity matrix. Partitioning Q=[Q1 Q2]Q=[Q_1\ Q_2] gives the reduced, thin, or economy-size decomposition

A=Q1R1,Q1TQ1=In,A=Q_1R_1,\qquad Q_1^TQ_1=I_n,

with Q1Q_1 of size m×nm\times n. The reduced form omits columns unnecessary for reconstructing AA. (netlib.org)

For matrices over the complex numbers, transpose is replaced by conjugate transpose, written Q∗Q^*. QR also exists for wide matrices, where the full factor RR is upper trapezoidal: its entries below the main diagonal are zero, but it has more columns than rows. (netlib.org)

Every real matrix with m≥nm\ge n admits QR decomposition, including rank-deficient matrices. If its columns are linearly independent, the reduced decomposition becomes unique when all diagonal entries of R1R_1 are required to be positive. Without this convention, corresponding columns of Q1Q_1 and rows of R1R_1 can change signs together. When m>nm>n, the remaining columns of full QQ are not uniquely determined. (buttenschoen.ca)

Geometric interpretation

For a full-column-rank matrix, the columns of Q1Q_1 form an orthonormal basis for the span of the columns of AA. Writing aja_j and qiq_i for individual columns,

aj=∑i=1jrijqi.a_j=\sum_{i=1}^{j}r_{ij}q_i.

Thus R1R_1 records the coordinates of the original columns in this orthonormal basis. Its triangular structure reflects the fact that the first jj original columns can be represented using the first jj basis vectors. The coefficients satisfy rij=qi∗ajr_{ij}=q_i^*a_j, an inner product. (buttenschoen.ca)

As a consequence, Q1Q1∗Q_1Q_1^* represents orthogonal projection onto the column space of AA. QR therefore separates the geometry of that space, represented by Q1Q_1, from the coordinate relationships represented by R1R_1. (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

H=I−2vvTvTv,v≠0.H=I-2\frac{vv^T}{v^Tv},\qquad v\ne0.

A sequence of these orthogonal reflectors transforms AA into triangular form; their product determines QQ. 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 m×nm\times n matrices with m≥nm\ge n, Householder factorization without explicitly forming QQ requires approximately 2mn2−23n32mn^2-\frac23n^3 floating-point operations. Its computational complexity is therefore O(mn2)O(mn^2). Implementations commonly store QQ 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:

min⁡x∥Ax−b∥2.\min_x\|Ax-b\|_2.

For full column rank, orthogonal invariance of the Euclidean norm gives

∥Ax−b∥22=∥R1x−Q1∗b∥22+∥Q2∗b∥22.\|Ax-b\|_2^2 =\|R_1x-Q_1^*b\|_2^2+\|Q_2^*b\|_2^2.

The second term is independent of xx. Consequently, the unique minimizer solves the triangular system

R1x=Q1∗b,R_1x=Q_1^*b,

which is evaluated by back substitution. The residual norm is ∥Q2∗b∥2\|Q_2^*b\|_2, so it can be obtained without explicitly constructing the residual vector. (netlib.org)

Unlike solving the normal equations A∗Ax=A∗bA^*Ax=A^*b, direct QR does not form A∗AA^*A. For full column rank, its spectral condition number satisfies κ2(A∗A)=κ2(A)2\kappa_2(A^*A)=\kappa_2(A)^2. 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 PP:

AP=QR.AP=QR.

Columns are reordered to expose stronger independent directions earlier. When the rank is uncertain, partitioning RR 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

Ak=QkRk,Ak+1=RkQk.A_k=Q_kR_k,\qquad A_{k+1}=R_kQ_k.

Because Ak+1=Qk∗AkQkA_{k+1}=Q_k^*A_kQ_k, 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 A=QRA=QR is thus a building block of the iterative QR algorithm, rather than the same operation. (cs.cornell.edu)