QR factorization
A reduced QR factorization expresses a real matrix with independent columns as an orthonormal-column matrix times an invertible upper-triangular matrix.
On this page 8 sections
01Understand the idea#
QR factorization rewrites a matrix using perpendicular unit patterns in and a triangular mixing rule in . It helps solve least-squares problems by separating “find the target’s pattern coordinates” from “recover the original feature weights.”
You already know dot products, orthonormal columns, and back substitution. QR connects them: use dot products with to find desired pattern coordinates, then solve the upper-triangular system involving . The supplied factors save you from constructing an orthonormal basis in this lesson.
A reduced QR factorization writes A=QR. For a matrix with independent columns, Q has orthonormal columns and R is square, upper triangular, with nonzero diagonal entries. The factors are supplied here; use them to fit a target b.
Let Q have columns (1,0,0) and (0,1,0), with target b=(5,3,2). Dot each column with b. The orthonormal-pattern coordinates are 5 and 3.
Q’s columns span the attainable outputs. Their dot products with b are the coordinates of its projection. Since Ax=Q(Rx), the input must satisfy this triangular system:
Reduced QR: , , . Find the scalar .
Show answer and explanation
; .
02In Rx=Q^Tb, the right side is known but x is still unknown#
In , the right side is known but is still unknown. For rows of equal to and and right side , the bottom row gives . Set , substitute it into , and solve . Pattern coordinates and feature weights differ.
Suppose Qᵀb=(5,3) and R has rows (2,1), (0,3). Solve from the bottom: 3x₂=3 gives x₂=1. Then 2x₁+1=5 gives x₁=2.
, . Claim: . Correct .
Show answer and explanation
; .
03For A with m rows and n independent columns, Qᵀ takes b to n pattern coordinates#
For A with m rows and n independent columns, Qᵀ takes b to n pattern coordinates. R mixes the input weights into those coordinates. Back substitution recovers the weights.
Q can be rectangular, so no square inverse of Q is needed. Its transpose extracts coordinates. A least-squares input still may leave a nonzero residual: the chosen output is the closest one the matrix can produce.
Fit with . The pattern is , , . Find input .
Show answer and explanation
; divide by 3.
04A closer look#
In a regression fit with independent feature columns, QR lets software find coefficients without explicitly forming an inverse of . A residual can remain because the target may have a component outside the columns’ span. A solvable triangular system does not imply an exact fit to every measurement.
Compute Qᵀb, then solve the triangular system Rx=Qᵀb by back substitution. The result gives input weights for the closest attainable output.
- Use supplied QR factors to find least-squares input weights.
Sources & further reading
- [1]TU Delft Linear Algebra, 7.4: QR and least squares ↗TU Delft · Book