QR QR Decomposition Calculator

QR Decomposition Calculator

QR decomposition factors a matrix into an orthogonal matrix Q and an upper triangular matrix R such that A = QR, and this calculator computes both via Gram-Schmidt. Q is orthogonal (Qᵀ Q = I), R is upper triangular. Verification included.

QR

QR Decomposition

Gram-Schmidt method: A = QR

✓ Step-by-Step✓ Verified✓ Free⚡ Loading precision engine…
Matrix A (must have ≥ rows than cols for full QR)
Quick Examples

QR Decomposition

QR decomposition breaks a matrix A into two simpler matrices: Q, an orthogonal matrix (its columns are perpendicular unit vectors), and R, an upper triangular matrix. Together, A = QR.

$$A = QR, \quad Q^TQ = I, \quad R \text{ is upper triangular}$$

How It's Calculated

This calculator uses the Gram-Schmidt process: it takes the columns of A one at a time and turns them into a set of perpendicular unit-length vectors — these become the columns of Q. R is then found from how the original columns relate to these new perpendicular ones.

Worked Example (2×2)

For A = [[1,1],[0,1]]: the first column becomes the unit vector (1,0) for Q. The second column, made perpendicular to the first, becomes (0,1). So Q = [[1,0],[0,1]] and R = [[1,1],[0,1]], and multiplying Q by R gives back the original A.

Applications

  • Solving least-squares problems (finding the best-fit line or curve through data)
  • Computing eigenvalues numerically (the QR algorithm)
  • Signal processing and computer graphics

Frequently Asked Questions

Yes — QR decomposition works for any matrix with linearly independent columns, not just square ones. This calculator supports rectangular matrices where rows ≥ columns.
Yes, if you require the diagonal entries of R to be positive, the decomposition is unique for a matrix with linearly independent columns.
LU decomposition is faster but can be numerically unstable for some matrices. QR is more stable and works even when a matrix doesn't have an LU decomposition, but requires more computation.

Related Calculators