87. QR Decomposition

Every matrix with can be factored as:

where:

If is full column rank, the decomposition is unique up to signs on the diagonal of .

For square (full rank), is a full orthogonal matrix and is square upper triangular.

87.1. Construction via Gram–Schmidt

The columns of are the result of applying Gram–Schmidt orthogonalization to the columns of :

Explicitly, for and for .

Example

Apply Gram–Schmidt to columns:

  • Project off :
  • that, normalized:

87.2. Why it matters

QR is the workhorse for least-squares problems:

Given overdetermined (more equations than unknowns), the least-squares solution

solves the normal equations . Using :

Then back-substitute on the upper-triangular — much more numerically stable than forming directly.

Other uses:

87.3. Computation methods

87.4. See also