QR Decomposition Calculator
Decompose matrix A into A = QR where Q has orthonormal columns and R is upper triangular. Uses Gram-Schmidt orthogonalization. Requires m ≥ n.
Notes
What is QR Decomposition?
QR decomposition factors A = QR where Q has orthonormal columns (Q^T Q = I) and R is upper triangular. Computed via Gram-Schmidt orthogonalization.
Gram-Schmidt in Brief
For each column aᵢ of A: subtract its projections onto all previous orthonormal columns q₁, ..., qᵢ₋₁, then normalize. The result qᵢ is the next column of Q; the projection coefficients fill column i of R.
Example: for A = [[1,1],[1,0],[0,1]], the decomposition gives Q (3×2) and R (2×2) upper triangular:
| 1/√2 | 1/√6 |
| 1/√2 | -1/√6 |
| 0 | 2/√6 |
| √2 | 1/√2 |
| 0 | √(3/2) |
- Matrix Calculations Guide — QR Decomposition — In-depth notes on QR Decomposition with worked examples
Frequently Asked Questions
When is QR decomposition used?
Primarily for solving least-squares problems (Ax ≈ b with m > n), computing eigenvalues via the QR algorithm, and orthogonalizing a set of vectors.
Why must m ≥ n?
Q has orthonormal columns, so you need at least n rows to have n linearly independent columns.
How does QR solve least-squares?
Given A = QR, the least-squares solution is x = R⁻¹ Q^T b. Since R is upper triangular and small (n×n), solving Rx = Q^T b via back-substitution is fast.