QR Decomposition Calculator
Decompose a matrix into an orthogonal Q and upper-triangular R via Gram-Schmidt.
About QR Decomposition Calculator
QR decomposition expresses a matrix A as Q·R where Q has orthonormal columns and R is upper triangular. This implementation uses the modified Gram-Schmidt process. The matrix must have at least as many rows as columns (m ≥ n), and its columns must be linearly independent.
Formulas
QR Factorisation
A = Q·R, where QᵀQ = I
- Q
- Orthogonal matrix (m×n)
- R
- Upper triangular (n×n)
Gram-Schmidt
qⱼ = (aⱼ − Σᵢ₌₁ʲ⁻¹ ⟨qᵢ,aⱼ⟩qᵢ) / ||...||
- aⱼ
- j-th column of A
- qⱼ
- j-th orthonormal vector
Worked example
With the default values below, QR Decomposition Calculator returns Q (Orthogonal) of 0.707107 0.408248 -0.57735 0.707107 -0.408248 0.57735 0 0.816497 0.57735. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Matrix A (rows separated by newlines or semicolons; values by commas or spaces)
- 1 1 0 1 0 1 0 1 1
Results
- Q (Orthogonal)
- 0.707107 0.408248 -0.57735 0.707107 -0.408248 0.57735 0 0.816497 0.57735
- R (Upper Triangular)
- 1.414214 0.707107 0.707107 0 1.224745 0.408248 0 0 1.154701
- ||Q·R − A|| (should be ≈ 0)
- 0.000000000000
Step by step
- 1Matrix A= 1 1 0 1 0 1 0 1 1
- 2Q (columns are orthonormal)= 0.707107 0.408248 -0.57735 0.707107 -0.408248 0.57735 0 0.816497 0.57735
- 3R (upper triangular)= 1.414214 0.707107 0.707107 0 1.224745 0.408248 0 0 1.154701
- 4Residual ||QR−A||= 1.1102e-16
Assumptions and limits
- The result is derived only from the single input listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 12 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
What is QR decomposition used for?
It is used for solving least-squares problems, computing eigenvalues (QR algorithm), and as a numerically stable alternative to Gaussian elimination for overdetermined systems.
Does this work for non-square matrices?
Yes, as long as the matrix has more rows than columns (m ≥ n) and the columns are linearly independent.
