{
  "id": "qr-decomposition",
  "title": "QR Decomposition",
  "lang": "en",
  "source_lang": "en",
  "summary": "QR decomposition factors a matrix into orthogonal or unitary and triangular factors, supporting stable least-squares solutions and eigenvalue computations.",
  "category": "mathematics",
  "subcategory": "applied",
  "type": "concept",
  "aliases": [
    "QR factorization",
    "Orthogonal–triangular factorization"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/qr-decomposition/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/qr-decomposition/",
      "json": "https://aiwiki.page/zh/qr-decomposition.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "QR decomposition is a matrix factorization that expresses a matrix as \\(A=QR\\), where \\(Q\\) has orthonormal columns and \\(R\\) is upper triangular or upper trapezoidal, depending on the dimensions. For real matrices, a square \\(Q\\) 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)"
    },
    {
      "heading": "Definition and forms",
      "text": "For \\(A\\in\\mathbb{R}^{m\\times n}\\) with \\(m\\ge n\\), the full QR decomposition has the form\n\n\\[A=Q \\begin{bmatrix}R_1\\\\0\\end{bmatrix}, \\qquad Q^TQ=I_m,\\]\n\nwhere \\(Q\\) is \\(m\\times m\\) and \\(R_1\\) is \\(n\\times n\\) and upper triangular. Here \\(Q^T\\) denotes the transpose, and \\(I_m\\) is the identity matrix. Partitioning \\(Q=[Q_1\\ Q_2]\\) gives the reduced, thin, or economy-size decomposition\n\n\\[A=Q_1R_1,\\qquad Q_1^TQ_1=I_n,\\]\n\nwith \\(Q_1\\) of size \\(m\\times n\\). The reduced form omits columns unnecessary for reconstructing \\(A\\). (netlib.org)\n\nFor matrices over the complex numbers, transpose is replaced by conjugate transpose, written \\(Q^*\\). QR also exists for wide matrices, where the full factor \\(R\\) is upper trapezoidal: its entries below the main diagonal are zero, but it has more columns than rows. (netlib.org)\n\nEvery real matrix with \\(m\\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 \\(R_1\\) are required to be positive. Without this convention, corresponding columns of \\(Q_1\\) and rows of \\(R_1\\) can change signs together. When \\(m>n\\), the remaining columns of full \\(Q\\) are not uniquely determined. (buttenschoen.ca)"
    },
    {
      "heading": "Geometric interpretation",
      "text": "For a full-column-rank matrix, the columns of \\(Q_1\\) form an orthonormal basis for the span of the columns of \\(A\\). Writing \\(a_j\\) and \\(q_i\\) for individual columns,\n\n\\[a_j=\\sum_{i=1}^{j}r_{ij}q_i.\\]\n\nThus \\(R_1\\) records the coordinates of the original columns in this orthonormal basis. Its triangular structure reflects the fact that the first \\(j\\) original columns can be represented using the first \\(j\\) basis vectors. The coefficients satisfy \\(r_{ij}=q_i^*a_j\\), an inner product. (buttenschoen.ca)\n\nAs a consequence, \\(Q_1Q_1^*\\) represents orthogonal projection onto the column space of \\(A\\). QR therefore separates the geometry of that space, represented by \\(Q_1\\), from the coordinate relationships represented by \\(R_1\\). (buttenschoen.ca)"
    },
    {
      "heading": "Computational methods",
      "text": "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)\n\nHouseholder transformations eliminate entries below the diagonal one column at a time. In real arithmetic, a reflector can be written\n\n\\[H=I-2\\frac{vv^T}{v^Tv},\\qquad v\\ne0.\\]\n\nA sequence of these orthogonal reflectors transforms \\(A\\) into triangular form; their product determines \\(Q\\). Householder QR is a standard dense-matrix method because of its numerical stability. (buttenschoen.ca)\n\nGivens 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)\n\nFor dense real \\(m\\times n\\) matrices with \\(m\\ge n\\), Householder factorization without explicitly forming \\(Q\\) requires approximately \\(2mn^2-\\frac23n^3\\) floating-point operations. Its computational complexity is therefore \\(O(mn^2)\\). Implementations commonly store \\(Q\\) implicitly as reflector vectors; blocked algorithms apply groups of reflectors using matrix–matrix operations. (cs.utexas.edu)"
    },
    {
      "heading": "Least-squares problems",
      "text": "QR solves the overdetermined problem underlying ordinary least squares and linear regression:\n\n\\[\\min_x\\|Ax-b\\|_2.\\]\n\nFor full column rank, orthogonal invariance of the Euclidean norm gives\n\n\\[\\|Ax-b\\|_2^2 =\\|R_1x-Q_1^*b\\|_2^2+\\|Q_2^*b\\|_2^2.\\]\n\nThe second term is independent of \\(x\\). Consequently, the unique minimizer solves the triangular system\n\n\\[R_1x=Q_1^*b,\\]\n\nwhich is evaluated by back substitution. The residual norm is \\(\\|Q_2^*b\\|_2\\), so it can be obtained without explicitly constructing the residual vector. (netlib.org)\n\nUnlike solving the normal equations \\(A^*Ax=A^*b\\), direct QR does not form \\(A^*A\\). For full column rank, its spectral condition number satisfies \\(\\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)"
    },
    {
      "heading": "Pivoting and numerical rank",
      "text": "Column-pivoted QR introduces a permutation matrix \\(P\\):\n\n\\[AP=QR.\\]\n\nColumns are reordered to expose stronger independent directions earlier. When the rank is uncertain, partitioning \\(R\\) 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)"
    },
    {
      "heading": "Connection with eigenvalue algorithms",
      "text": "The QR algorithm repeatedly uses QR decomposition to compute eigenvalues and eigenvectors. Its basic unshifted step is\n\n\\[A_k=Q_kR_k,\\qquad A_{k+1}=R_kQ_k.\\]\n\nBecause \\(A_{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=QR\\) is thus a building block of the iterative QR algorithm, rather than the same operation. (cs.cornell.edu)"
    }
  ],
  "links": [
    "matrix-factorization",
    "matrix",
    "orthogonal-matrix",
    "unitary-matrix",
    "numerical-linear-algebra",
    "matrix-transpose",
    "identity-matrix",
    "complex-number",
    "conjugate-transpose",
    "linear-independence",
    "orthonormal-basis",
    "linear-span",
    "inner-product",
    "orthogonal-projection",
    "gram-schmidt-process",
    "floating-point-arithmetic",
    "householder-transformation",
    "numerical-stability",
    "computational-complexity",
    "ordinary-least-squares",
    "linear-regression",
    "norm-mathematics",
    "system-of-linear-equations",
    "condition-number",
    "matrix-rank",
    "singular-value-decomposition",
    "qr-algorithm",
    "eigenvalues-and-eigenvectors",
    "matrix-similarity",
    "schur-decomposition"
  ],
  "sources": [
    {
      "title": "netlib.org/lapack/lug/node39.html",
      "url": "https://www.netlib.org/lapack/lug/node39.html"
    },
    {
      "title": "netlib.org/lapack/lug/node40.html",
      "url": "https://netlib.org/lapack/lug/node40.html"
    },
    {
      "title": "buttenschoen.ca/MATH551/qr-factorization/",
      "url": "https://www.buttenschoen.ca/MATH551/qr-factorization/"
    },
    {
      "title": "cs.cornell.edu/courses/cs6210/2025fa/lec/2025-09-29.html",
      "url": "https://www.cs.cornell.edu/courses/cs6210/2025fa/lec/2025-09-29.html"
    },
    {
      "title": "cs.utexas.edu/~flame/laff/alaff-beta/chapter04-via-hqr.html",
      "url": "https://www.cs.utexas.edu/~flame/laff/alaff-beta/chapter04-via-hqr.html"
    },
    {
      "title": "cs.cornell.edu/courses/cs6210/2025fa/lec/2025-09-24-slides.html",
      "url": "https://www.cs.cornell.edu/courses/cs6210/2025fa/lec/2025-09-24-slides.html"
    },
    {
      "title": "netlib.org/lapack/lug/node42.html",
      "url": "https://www.netlib.org/lapack/lug/node42.html"
    },
    {
      "title": "cs.cornell.edu/courses/cs4220/2026sp/lec/2026-03-06.html",
      "url": "https://www.cs.cornell.edu/courses/cs4220/2026sp/lec/2026-03-06.html"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}