QR Decomposition Calculator

Solve matrix factorization using stable orthogonal projections. Test reconstruction quality across square and tall systems. Compare outputs visually and export reports without extra steps.

Calculator

Use the responsive controls below. Large screens show three columns, smaller screens show two, and mobile shows one.

Matrix dimensions

Reduced QR on this page expects m ≥ n.

Numerical settings

Optional least-squares mode

When enabled, the calculator solves Rx = Qᵀb and reports the least-squares residual.

Matrix A input

Enter values directly into the generated grid.

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.

A = QR
vj = aj - Σi=1j-1 rij qi
rij = qiT aj for i < j
rjj = ‖vj2, qj = vj / rjj
QTQ ≈ I, reconstruction error = ‖A - QR‖F

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

  1. Choose the number of rows and columns. Keep rows greater than or equal to columns.
  2. Enter the matrix values into the generated input grid.
  3. Select display decimals and set the numerical tolerance you want.
  4. Enable the right-hand-side vector if you also want a least-squares solution.
  5. Click Compute QR decomposition to show Q, R, QR, errors, and graph output above the form.
  6. 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.

Related Calculators

beta distribution calculatormatrix determinant calculatorlu decomposition calculatorgamma distribution calculatorsimpson rule calculatorgaussian elimination calculatorlagrange interpolation calculatorexponential distribution calculatorbisection method calculatortrapezoidal rule calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.