QR Decomposition Calculator
Factor a matrix into Q and R with Householder reflections, with rank, error checks and steps.
QR Decomposition Calculator
Calculations use full double precision; this only affects display.
| 0.8571 | -0.3943 | -0.3314 |
| 0.4286 | 0.9029 | 0.0343 |
| -0.2857 | 0.1714 | -0.9429 |
3 × 3
| 14 | 21 | -14 |
| 0 | 175 | -70 |
| 0 | 0 | 35 |
3 × 3
- Numerical rank
- 3 of 3
- full rank
- Reconstruction error
- 1.60e-16
- ‖A − QR‖ / ‖A‖
- Orthogonality error
- 5.71e-16
- ‖QᵀQ − I‖
- Rank tolerance
- 1.17e-13
Check: Q × R
| 12 | -51 | 4 |
| 6 | 167 | -68 |
| -4 | 24 | -41 |
3 × 3
Step by step (2 Householder reflections)
Step 1. Reflect column 1 (rows 1–3) onto the axis with H1 = I − 2vvᵀ, v = [0.9636, 0.2224, -0.1482]. This zeroes the entries below the diagonal.
After step 1 -14 -21 14 0 173.9231 -65.6923 0 19.3846 -42.5385 3 × 3
Step 2. Reflect column 2 (rows 2–3) onto the axis with H2 = I − 2vvᵀ, v = [0.9985, 0.0555]. This zeroes the entries below the diagonal.
After step 2 -14 -21 14 0 -175 70 0 0 -35 3 × 3
Finally, rows of R with a negative diagonal entry are multiplied by −1 (and the matching columns of Q), so R's diagonal is non-negative.
What A = QR means
A = QR, QᵀQ = I, R upper triangularHouseholder QR applies reflections Hk = I − 2vkvkᵀ that zero out each column below the diagonal: R = Hp…H1A and Q = H1…Hp. It is backward stable, so Q stays orthonormal to machine precision even for ill-conditioned matrices. Modified Gram–Schmidt orthogonalizes the columns one at a time and is easier to follow by hand, but loses orthogonality as the condition number grows.
Numbers are IEEE double precision (about 16 significant digits). The rank is estimated with column-pivoted QR, counting diagonal entries larger than max(m, n) × machine epsilon × the largest one.
Your data is processed locally in your browser and is not uploaded to OZVILO servers.
How to use the QR Decomposition Calculator
- 1Enter the matrix in the grid, paste it as text, or load an example (square, tall, wide or rank-deficient).
- 2Choose Householder (recommended) or modified Gram–Schmidt, and thin or full QR for tall matrices.
- 3Read Q and R, the numerical rank and the reconstruction and orthogonality errors.
- 4Open the steps to see each Householder reflection, and copy or download Q and R as CSV.
Examples
Classic 3 × 3
- Input
- [[12, −51, 4], [6, 167, −68], [−4, 24, −41]]
- Result
- R = [[14, 21, −14], [0, 175, −70], [0, 0, 35]] · Q columns orthonormal
Rank-deficient
- Input
- [[1, 2, 3], [2, 4, 6], [1, 0, 1]]
- Result
- Numerical rank 2 of 3 — flagged, with A = QR still verified
QR Decomposition Calculator features
- Householder reflections (backward stable)
- Modified Gram–Schmidt for learning
- Thin and full QR
- Rank detection, error checks, step-by-step reflections
- CSV download
Frequently asked questions
What is QR decomposition?
It writes a matrix A as Q × R, where Q has orthonormal columns (QᵀQ = I) and R is upper triangular. It's used to solve least-squares problems, compute eigenvalues and orthonormalize vectors.
Why Householder instead of Gram–Schmidt?
Householder reflections are numerically stable: Q stays orthogonal to about machine precision even for ill-conditioned matrices. Gram–Schmidt is easier to follow by hand but can lose orthogonality badly — compare the orthogonality error on a near-singular matrix.
Is the QR decomposition unique?
For a full-rank matrix it's unique once R's diagonal is required to be positive, which this tool enforces. For a rank-deficient matrix some columns of Q aren't determined by A, and the tool tells you so.
How accurate are the results?
Calculations use double-precision floating point (about 16 significant digits). Tiny values like 1e-16 are rounding noise and display as 0 at normal precision; the reconstruction error ‖A − QR‖/‖A‖ shows how close the factorization is.
Related tools
- Available
Orthogonal Projection Calculator
Project a vector onto another vector or onto the column space of a matrix, with the orthogonal component.
CalculatorsOpen tool - Available
Matrix Transpose Calculator
Transpose a matrix of any shape — rows become columns — with index-by-index working.
CalculatorsOpen tool - Available
Jacobian Matrix Calculator
Find the symbolic Jacobian of a set of functions, evaluate it at a point and get its determinant.
CalculatorsOpen tool - Available
Matrix Subtraction Calculator
Subtract two matrices of the same size, entry by entry, with the working shown.
CalculatorsOpen tool