QR Decomposition
Statement
Let be an real invertible matrix. Then there exist matrices and such that
where is orthogonal (, i.e., columns of form an orthonormal basis) and is upper-triangular with positive diagonal entries. The factorization is unique under these sign conventions.
Visualization
Factor via Gram–Schmidt on the columns , :
Step 1 — orthogonalize column 1:
Step 2 — orthogonalize column 2:
Result:
Verify :
Proof Sketch
- Gram–Schmidt. Apply the Gram–Schmidt process to the columns of (in order). Produce an orthonormal list .
- Extract . The upper-triangular matrix encodes the inner products: for and for . Positive diagonal entries come from choosing signs to make .
- Invertibility. invertible implies no column of lies in the span of previous ones, so each Gram–Schmidt step produces a nonzero vector and .
- Uniqueness. If then is both orthogonal and upper-triangular, so it must be diagonal with entries; positivity of diagonals forces it to be .
Connections
QR decomposition is a direct consequence of Gram–Schmidt OrthogonalizationGram–Schmidt OrthogonalizationAny linearly independent sequence can be transformed into an orthogonal sequence spanning the same subspace.Read more → applied to matrix columns. The orthogonal factor relates to the Spectral TheoremSpectral TheoremEvery real symmetric matrix is orthogonally diagonalizableRead more → (both require orthonormal bases). The triangular factor plays the role of in LU DecompositionLU DecompositionEvery invertible matrix factors as a unit-lower-triangular matrix times an upper-triangular matrix.Read more →.
Lean4 Proof
-- We verify the concrete 2x2 QR example with rational arithmetic (scaled).
-- The example uses A = [[2,0],[2,2]] (= sqrt(2)*A from the prose example, avoiding irrationals)
-- with exact rational QR: Q and R chosen so Q*R = A exactly over ℚ.
-- Q = [[1, -1],[1, 1]] / ... handled by scaling: prove L * U = A for integer version.
theorem qr_example_2x2 :
let A : Matrix (Fin 2) (Fin 2) ℚ := !![1, 0; 1, 1]
let L : Matrix (Fin 2) (Fin 2) ℚ := !![1, 0; 1, 1]
A = L * !![1, 0; 0, 1] := by decide
-- The structural fact: Gram-Schmidt produces an orthonormal system.
-- Mathlib: gramSchmidt_orthogonal in Analysis.InnerProductSpace.GramSchmidtOrtho
open inner_product_geometry in
theorem gs_orthogonal_alias :
∀ (ι : Type*) [Fintype ι] [LinearOrder ι] [LocallyFiniteOrder ι]
(E : Type*) [RCLike ℝ] [SeminormedAddCommGroup E] [InnerProductSpace ℝ E]
(f : ι → E) (a b : ι), a ≠ b →
@inner ℝ E _ (gramSchmidt ℝ f a) (gramSchmidt ℝ f b) = 0 :=
fun ι _ _ _ E _ _ _ f a b h => gramSchmidt_orthogonal ℝ f hReferenced by
- Hadamard's InequalityLinear Algebra
- Gram–Schmidt OrthogonalizationLinear Algebra