QR Decomposition Calculator

Factor a matrix into Q R (orthogonal × upper-triangular).

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter a matrix to factor it into an orthogonal Q and an upper triangular R. For [3 4; 4 −3], Q is [0.6 0.8; 0.8 −0.6] and R is [5 0; 0 5].

How to use

1
Step 1
Type the matrix, one row per line.
2
Step 2
Choose qr.
3
Step 3
Press Calculate to see Q and R.

How it works

The columns of Q are orthonormal, built from the columns of A, and R holds the coefficients that rebuild A from them, so A = QR. QR is the standard route to least squares fits and to the QR algorithm for eigenvalues.

A = QR      QᵀQ = I      R is upper triangular

Worked example

Column lengths of 5

Input
[3 4; 4 −3]
Output
Q = [0.6 0.8; 0.8 −0.6], R = [5 0; 0 5]
Walkthrough
Column 1 is (3, 4) with length 5, so the first Q column is (0.6, 0.8) and R₁₁ = 5. Column 2 (4, −3) is perpendicular to it and also has length 5.

Limitations

  • Entries must be real numbers; complex entries are refused.
  • For a tall m×n matrix the Q returned is the full m×m orthogonal matrix and R is m×n, so the extra rows of R are zero.
  • Signs of Q and R columns can differ between software packages.

Questions

What is the QR decomposition of [3 4; 4 −3]?
Q = [0.6 0.8; 0.8 −0.6] and R = [5 0; 0 5].
What is R for [1 1; 1 2; 1 3]?
[1.73205 3.4641; 0 1.41421; 0 0].
What does orthogonal mean for Q?
Its columns are perpendicular unit vectors, so QᵀQ is the identity.

Features

  • Orthonormal Q
  • Tall matrices
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • Rectangle area as product of dimensions

    Khan Academy

    Foundational area thinking across math tools.

    Watch on YouTube
  • Derivative as a concept

    Khan Academy

    When general calculators hand off to calculus tools.

    Watch on YouTube