Connect via MCP →

Enter Calculation

[
     
     
     
]

Formula

Advertisement

Results

QR factorization decomposes a matrix A into a product Q * R, where Q is an orthogonal matrix and R is an upper triangular matrix.

Input Matrix (A):

1 2 3
4 5 6
7 8 9

Q Matrix:

-0.1231 0.9045 -0.4082
-0.4924 0.3015 0.8165
-0.8616 -0.3015 -0.4082

R Matrix:

-8.124 -9.6011 -11.0782
0 0.9045 1.8091
0 0 0

What Is QR Factorization?

QR factorization (also called QR decomposition) is a fundamental technique in linear algebra that expresses a matrix A as the product of two matrices: \(\mathbf{A} = \mathbf{Q}\,\mathbf{R}\). Here, Q is an orthogonal matrix (its columns are perpendicular unit vectors, so \(\mathbf{Q}^{\mathsf{T}}\mathbf{Q} = \mathbf{I}\)) and R is an upper-triangular matrix. This decomposition is used worldwide in numerical computing and applies to any real matrix regardless of country or convention.

QR factorization is widely used to solve linear systems, compute least-squares regression fits, and find eigenvalues through the QR algorithm. It is numerically more stable than directly inverting a matrix, which is why it appears in many scientific and engineering software packages.

Matrix A factored into orthogonal Q and upper-triangular R
QR factorization splits matrix A into an orthogonal matrix Q and an upper-triangular matrix R.

How to Use This Calculator

Entering your matrix is simple:

  • Separate the values in a row using commas.
  • Separate each row using a pipe ( | ) symbol.
  • For example, the matrix with rows (1, 2) and (3, 4) is typed as 1,2|3,4.

Once you submit, the calculator returns the orthogonal matrix Q and the upper-triangular matrix R so you can verify that multiplying them reproduces your original matrix.

The Formula Explained

The most common method is the Gram–Schmidt process. Given the columns a₁, a₂, … of A, the algorithm builds an orthonormal set of vectors:

$$\mathbf{A} = \mathbf{Q}\,\mathbf{R}, \quad \mathbf{Q}^{\mathsf{T}}\mathbf{Q} = \mathbf{I},\ \ \mathbf{R}\ \text{upper triangular}$$
  • Take the first column and normalize it to get \(q_1\).
  • For each later column, subtract its projections onto the already-computed q vectors, then normalize the remainder.
  • The entries of R are the dot products \(r_{ij} = q_i \cdot a_j\), with R being upper-triangular because earlier q vectors don't depend on later columns.
Advertisement
Gram-Schmidt orthogonalization of vectors into perpendicular axes
Gram–Schmidt turns the matrix columns into orthonormal vectors forming the columns of Q.

Worked Example

Consider A = 1,1|0,1|1,0 (a 3×2 matrix). Normalizing the first column gives \(q_1 = (0.707,\ 0,\ 0.707)\). Subtracting its projection from the second column and normalizing yields \(q_2\). The result is an orthogonal Q whose columns are unit length and perpendicular, with R holding the projection coefficients. Multiplying \(\mathbf{Q} \times \mathbf{R}\) returns the original A, confirming the decomposition.

Frequently Asked Questions

Does the matrix need to be square? No. QR factorization works for any m×n matrix where m ≥ n, which is exactly why it is so useful for least-squares problems with more equations than unknowns.

Is the QR decomposition unique? It is unique up to the signs of the diagonal entries of R. Conventionally, R's diagonal is made positive to fix a single answer.

Why use QR instead of inverting the matrix? QR is more numerically stable and avoids the rounding errors that come from computing matrix inverses directly, making your results more reliable.

Last updated: