Calculator
Use the responsive controls below. Large screens show three columns, smaller screens show two, and mobile shows one.
Example data table
This example uses the well-known 3 × 3 matrix often used to verify QR decomposition manually.
| Row | c1 | c2 | c3 | b |
|---|---|---|---|---|
| r1 | 12 | -51 | 4 | 1 |
| r2 | 6 | 167 | -68 | 2 |
| r3 | -4 | 24 | -41 | 3 |
Expected structure: Q contains orthonormal columns, R is upper triangular, and QR reconstructs the original matrix with a near-zero residual.
Formula used
The calculator applies the Modified Gram-Schmidt process to compute a reduced QR factorization for a matrix A ∈ ℝm×n with m ≥ n.
If vector b is included, the page also solves the least-squares system by computing QTb first and then solving the upper triangular system Rx = QTb.
How to use this calculator
- Choose the number of rows and columns. Keep rows greater than or equal to columns.
- Enter the matrix values into the generated input grid.
- Select display decimals and set the numerical tolerance you want.
- Enable the right-hand-side vector if you also want a least-squares solution.
- Click Compute QR decomposition to show Q, R, QR, errors, and graph output above the form.
- Download the result as CSV or PDF when you need to save or share the computation.
FAQs
1) What does QR decomposition do?
It factors a matrix A into Q and R, where Q has orthonormal columns and R is upper triangular. This helps with least-squares solving, matrix analysis, and stable numerical workflows.
2) Why does this page require rows to be at least columns?
This implementation is designed for reduced QR on square or tall matrices. That setup is common in least-squares problems and keeps the generated Q and R dimensions easy to interpret.
3) Why is Modified Gram-Schmidt used here?
Modified Gram-Schmidt is usually more numerically stable than the classical version. It reduces loss of orthogonality when columns are nearly dependent or matrix entries vary widely in magnitude.
4) What does the orthogonality error mean?
It measures how close QᵀQ is to the identity matrix. Smaller values mean the computed Q columns behave more like perfectly orthonormal basis vectors.
5) What does the reconstruction error show?
It computes the Frobenius norm of A − QR. A very small value means the factorization reconstructs the original matrix accurately within floating-point precision.
6) Can this calculator solve least-squares problems?
Yes. Enable the right-hand-side vector b, then the page computes Qᵀb and solves Rx = Qᵀb when the matrix has full column rank.
7) What happens if the matrix is rank deficient?
The calculator warns you when a column is nearly dependent. In that case, diagonal entries in R may approach zero, and the least-squares solution may no longer be unique.
8) What is the diagonal ratio proxy used for?
It compares the largest and smallest nonzero diagonal entries of R. It is not a full condition number, but it offers a quick sense of scaling and possible sensitivity.