Skip to content
Calcrivo

QR Decomposition Calculator

Decompose a matrix into an orthogonal Q and upper-triangular R via Gram-Schmidt.

Inputs

Q (Orthogonal)

0.707107 0.408248 -0.57735 0.707107 -0.408248 0.57735 0 0.816497 0.57735

R (Upper Triangular)

1.414214 0.707107 0.707107 0 1.224745 0.408248 0 0 1.154701

||Q·R − A|| (should be ≈ 0)

0.000000000000

Step by step

  1. Matrix A

    = 1 1 0 1 0 1 0 1 1

  2. Q (columns are orthonormal)

    = 0.707107 0.408248 -0.57735 0.707107 -0.408248 0.57735 0 0.816497 0.57735

  3. R (upper triangular)

    = 1.414214 0.707107 0.707107 0 1.224745 0.408248 0 0 1.154701

  4. Residual ||QR−A||

    = 1.1102e-16

How it works

QR decomposition expresses a matrix A as Q·R where Q has orthonormal columns and R is upper triangular. This implementation uses the modified Gram-Schmidt process. The matrix must have at least as many rows as columns (m ≥ n), and its columns must be linearly independent.

Formulas

QR Factorisation

A = Q·R, where QᵀQ = I

Q
Orthogonal matrix (m×n)
R
Upper triangular (n×n)

Gram-Schmidt

qⱼ = (aⱼ − Σᵢ₌₁ʲ⁻¹ ⟨qᵢ,aⱼ⟩qᵢ) / ||...||

aⱼ
j-th column of A
qⱼ
j-th orthonormal vector

Frequently Asked Questions

What is QR decomposition used for?

It is used for solving least-squares problems, computing eigenvalues (QR algorithm), and as a numerically stable alternative to Gaussian elimination for overdetermined systems.

Does this work for non-square matrices?

Yes, as long as the matrix has more rows than columns (m ≥ n) and the columns are linearly independent.

You might also need