QR Decomposition Calculator
Test cases replayed : 2 of 2 match · Methodology · No outside source listed
Enter a 3×3 matrix with independent columns to get its QR factorization (R with a positive diagonal).
Result
R row 1, column 1
Q row 1, column 1
- Q row 2, column 1
- Q row 3, column 1
- R row 1, column 2
- R row 2, column 2
- Q row 1, column 2
- Q row 2, column 2
- Q row 3, column 2
- R row 1, column 3
- R row 2, column 3
- R row 3, column 3
- Q row 1, column 3
- Q row 2, column 3
- Q row 3, column 3
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- A row 1, column 1: enter a number.
- A row 1, column 2: enter a number.
- A row 1, column 3: enter a number.
- A row 2, column 1: enter a number.
- A row 2, column 2: enter a number.
- A row 2, column 3: enter a number.
- A row 3, column 1: enter a number.
- A row 3, column 2: enter a number.
- A row 3, column 3: enter a number.
- Read the result: R row 1, column 1; the panel also shows Q row 1, column 1, Q row 2, column 1, Q row 3, column 1, R row 1, column 2, R row 2, column 2, Q row 1, column 2, Q row 2, column 2, Q row 3, column 2, R row 1, column 3, R row 2, column 3, R row 3, column 3, Q row 1, column 3, Q row 2, column 3 and Q row 3, column 3.
How this calculator works
QR decomposition writes A = QR, where Q has orthonormal columns (QᵀQ = I) and R is upper triangular. This calculator uses the classical Gram-Schmidt process on the columns a₁, a₂, a₃ of A.
r₁₁ = ‖a₁‖ and q₁ = a₁ ÷ r₁₁. Then r₁₂ = q₁·a₂, u₂ = a₂ − r₁₂q₁, r₂₂ = ‖u₂‖, q₂ = u₂ ÷ r₂₂. Finally r₁₃ = q₁·a₃, r₂₃ = q₂·a₃, u₃ = a₃ − r₁₃q₁ − r₂₃q₂, r₃₃ = ‖u₃‖, q₃ = u₃ ÷ r₃₃. With this choice the diagonal of R is positive, which makes the factorization unique for an invertible A.
If the columns are dependent a diagonal entry of R is 0 and the following entries of Q are shown as —.
The formula
| Symbol | Meaning |
|---|---|
| A row 1, column 1 | |
| A row 2, column 1 | |
| A row 3, column 1 | |
| R row 1, column 1 |
Worked example
| A row 1, column 1 | 12 |
|---|---|
| A row 1, column 2 | -51 |
| A row 1, column 3 | 4 |
| A row 2, column 1 | 6 |
| A row 2, column 2 | 167 |
| A row 2, column 3 | -68 |
| A row 3, column 1 | -4 |
| A row 3, column 2 | 24 |
| A row 3, column 3 | -41 |
| Q row 1, column 1 | 0.8571 |
|---|---|
| Q row 1, column 2 | -0.3943 |
| R row 1, column 2 | 21 |
| Q row 1, column 3 | -0.3314 |
| R row 1, column 3 | -14 |
| Q row 2, column 1 | 0.4286 |
| Q row 2, column 2 | 0.9029 |
| R row 2, column 2 | 175 |
| Q row 2, column 3 | 0.0343 |
| R row 2, column 3 | -70 |
| Q row 3, column 1 | -0.2857 |
| Q row 3, column 2 | 0.1714 |
| Q row 3, column 3 | -0.9429 |
| R row 3, column 3 | 35 |
R row 1, column 1 14
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
What is QR decomposition used for?
Solving least-squares problems (Rx = Qᵀb) and computing eigenvalues with the QR algorithm.
Why can other software show different signs?
Householder-based routines may return a column of Q and the matching row of R multiplied by −1. Both are valid factorizations; this one keeps the diagonal of R positive.