Qr Decomposition Calculator

By: Calculator Grid

QR Decomposition Calculator

Factor a real square matrix into an orthonormal matrix Q and an upper-triangular matrix R, then verify the identity A = QR.

Size3 × 3 Rank3 Residual7.11e – 15 MethodModified Gram – Schmidt
The startup example is valid and ready to export.

Matrix A

Choose a square matrix from 2 × 2 through 4 × 4.

Enter finite real numbers using a period as the decimal separator. Scientific notation is accepted.

Factorization status

Valid QR factorization

A and QR agree to floating-point precision.

Maximum |A – QR|

7.11e – 15

Maximum |QᵀQ – I|

1.11e – 16

Minimum |diag(R)|

14

Orthonormal matrix Q

Upper-triangular matrix R

Identity checks

A=QRandQᵀQ=I
Columns in Q3 orthonormal columns
R structureUpper triangular
Diagonal conventionNonnegative diagonal

Reconstruction detail

Entry Original A Reconstructed QR Signed difference Absolute difference
The detail table uses unrounded model values for the comparison, while the displayed cells are rounded for readability. Small residuals near machine precision are normal.

How to use this QR decomposition calculator

What this calculator does

This calculator takes a real square matrix A and computes a QR factorization A = QR. The columns of Q are orthonormal, so QᵀQ = I, and R is upper triangular. The tool also reconstructs A from the factors and reports numerical errors. It is designed for small educational matrices and verification work; it is not a substitute for a production numerical linear algebra library when matrices are large, complex-valued, sparse, or extremely ill-conditioned.

When to use it

  • Check a hand-worked QR decomposition from a linear algebra course.
  • Prepare a small matrix for least-squares or orthogonal-basis calculations.
  • Compare how changing one matrix entry affects Q, R, and numerical residuals.
  • Export a reproducible workbook containing the inputs, factors, and verification table.

How to calculate

  1. The calculator opens with a complete 3 × 3 demonstration matrix and an immediately available Excel workbook. Review the displayed Q and R matrices to see a valid result before editing.
  2. Choose Matrix size as 2 × 2, 3 × 3, or 4 × 4. Changing the size preserves overlapping entries and creates or removes the remaining matrix cells.
  3. Replace each Matrix A entry labeled aᵢⱼ. Results update live. Use a period for decimals; values such as -2.5 and 1e-3 are accepted.
  4. Read the factorization status, Q, R, rank, residual, orthogonality error, and the reconstruction table. Then select Download Excel to create a validated OOXML workbook from the current canonical values.
  5. Reset clears the demonstration and all matrix entries. Download Excel is then disabled until every required matrix cell contains a valid number and the matrix has linearly independent columns.

Input guide

Matrix size is required and determines the number of rows and columns. It accepts 2, 3, or 4. A 3 × 3 matrix is a realistic default for classroom work. Increasing the size introduces more columns that must remain linearly independent. A common mistake is to change the size and leave a new cell blank.

Matrix A entries are required finite real numbers. They are unitless unless your application assigns units consistently. Each field accepts ordinary decimal or scientific notation, for example 12, -51, or 4.2e2. Commas, currency symbols, percent signs, and nonnumeric text are rejected rather than silently altered. Changing any entry can modify every later column of Q and much of R. Duplicate or proportional columns make the matrix rank-deficient, so a full QR factorization with a positive diagonal in R cannot be produced.

Output guide

Factorization status states whether the current matrix has a valid full-rank QR decomposition. Orthonormal matrix Q contains normalized mutually perpendicular columns. Upper-triangular matrix R contains the projection coefficients and column norms; entries below its diagonal are zero by construction. The sign convention used here makes the diagonal of R nonnegative, which removes the usual sign ambiguity for full-rank matrices.

Rank is the number of independent columns detected by the factorization. Maximum |A – QR| is the largest absolute reconstruction difference across all entries. Maximum |QᵀQ – I| measures the largest departure from orthonormality. Values close to zero are desirable; tiny nonzero values are expected because JavaScript uses floating-point arithmetic. Minimum |diag(R)| is the smallest absolute diagonal entry in R and helps reveal a nearly dependent column. The Reconstruction detail table lists the original value, reconstructed value, signed difference, and absolute difference for every matrix position. These checks are numerical estimates, while the identity A = QR is exact in ideal arithmetic.

Worked example

The startup matrix is A = [12, – 51, 4], [6, 167, – 68], [ – 4, 24, – 41][6/7, 3/7, – 2/7] and r₁₁ = 14. Orthogonalizing the next two columns produces R = [14, 21, – 14], [0, 175, – 70], [0, 0, 35]