QR decomposition solves least squares problems stably and is the engine of the QR algorithm for eigenvalues. Q holds an orthonormal basis of the column space and R records how to rebuild A from it.
How to use the QR Decomposition Calculator
- Choose the matrix size – the matching grid of fields appears.
- Enter the entries row by row (a₁ b₁ c₁ is the first row, a₂ b₂ c₂ the second, and so on).
- Read the result; integer matrices give exact fractions.
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Each column is orthogonalised against the previous ones (modified Gram–Schmidt); the projection coefficients fill R and the normalised vectors form Q.
Formula
A = Q·R, QᵀQ = I, rᵢⱼ = qᵢ · aⱼ
Worked example
Inputs — Matrix size: 3 × 3; a₁: 4; b₁: 1; c₁: 2; a₂: 1; b₂: 3; c₂: 0; a₃: 2; b₃: 0; c₃: 5.
Results — Result = A = Q·R (Q orthogonal, R upper triangular); Q (orthogonal) = ⎡ 0.872872 −0.120386 −0.472866 ⎤
⎢ 0.218218 0.963087 0.157622 ⎥
⎣ 0.436436 −0.240772 0.866921 ⎦; R (upper triangular) = ⎡ 4.58258 1.52753 3.92792 ⎤
⎢ 0 2.76887 −1.44463 ⎥
⎣ 0 0 3.38887 ⎦.
Key terms
- Orthogonal matrix
- Columns are orthonormal.
Frequently asked questions
What does QR decomposition need?
Linearly independent columns (for a unique R with positive diagonal).
How is it used for least squares?
Solve Rx = Qᵀb instead of the normal equations.
Is Gram–Schmidt the only way?
Householder reflections and Givens rotations are more stable alternatives.
Is Q square?
For a square A, yes; for tall A, the thin Q has the same shape as A.