QR Decomposition Calculator with Steps

Factor a real square or tall matrix into an orthonormal matrix Q and upper-triangular matrix R. Everything runs locally in your browser.

Enter Matrix A

Choose rows ≥ columns. Enter decimals or scientific notation; display rounding never changes the calculation.

Separate entries with spaces, commas, or tabs and rows with new lines. Paste 2–8 rows and no more columns than rows.

QR Factors

Enter a valid matrix to calculate A = Q·R.

Q — orthonormal columns

R — upper triangular

Estimated rank
Max |QᵀQ − I|
Relative |A − QR|

Advertisement

Step-by-Step Householder Reflections

At step k, a reflector Hₖ = I − 2vₖvₖᵀ zeros the entries below position (k,k). Multiplying the reflectors produces Q.

Calculate a matrix to see each reflector and intermediate R matrix.

QR Decomposition Formulas

For an m × n input with m ≥ n, this calculator returns the thin QR decomposition: Q is m × n, R is n × n, and A = QR.

Householder reflector

Hₖ = I − 2vₖvₖᵀ

The unit vector vₖ is chosen so the reflector maps the active column onto a coordinate axis.

Orthogonality

QᵀQ = I

Each reflector is symmetric and orthogonal, so their product is orthogonal too.

Factorization

R = Hₚ⋯H₂H₁A

Because every Hₖ⁻¹ = Hₖ, the corresponding columns of Q = H₁H₂⋯Hₚ reconstruct A.

Convention: Q and R are not unique because matching signs may be moved between a column of Q and a row of R. This page keeps the natural signs produced by stable Householder reflectors.

How to Use the QR Calculator

  1. Select the row and column counts. Use at least as many rows as columns.
  2. Enter matrix A in the grid, or paste the matrix one row per line.
  3. Select Calculate QR. Read Q, R, the estimated rank, and each reflection below.
  4. Use the error checks to assess floating-point accuracy, then copy or download the result if needed.

Worked QR Example

The loaded example is A = [[12, −51, 4], [6, 167, −68], [−4, 24, −41]]. Its factors are approximately:

Q

[[−0.85714, 0.39429, −0.33143], [−0.42857, −0.90286, 0.03429], [0.28571, −0.17143, −0.94286]]

R

[[−14, −21, 14], [0, −175, 70], [0, 0, 35]]

Multiplying these rounded displays gives approximately A; the calculator verifies the full-precision factors before display rounding.

When QR Decomposition Is Useful

Least-squares problems

For a full-rank tall matrix, solve Rx = Qᵀb without forming the less stable normal-equation matrix AᵀA.

Orthonormal bases

The columns of Q give orthonormal directions spanning the column space when A has full column rank.

Eigenvalue algorithms

Repeated QR factorizations are a foundation of the QR algorithm for approximating eigenvalues.

QR Decomposition FAQs

What is QR decomposition?

It factors A into Q, whose columns are mutually orthogonal unit vectors, and an upper-triangular R such that A = QR.

Can I enter a rectangular matrix?

Yes. This calculator accepts tall matrices and square matrices, from 2 through 8 rows, as long as the number of columns does not exceed the rows.

What happens when the matrix is rank deficient?

The decomposition still exists. The calculator reports a lower estimated rank and one or more diagonal entries of R will be zero or numerically small. Some columns of thin Q then complete an orthonormal set rather than uniquely describing the column space.

Why are my Q or R signs different from another answer?

Both answers may be correct. Negating one column of Q and the corresponding row of R does not change their product.

Why does the calculator use Householder reflections?

They zero a complete column segment at each step and generally maintain orthogonality better in floating-point arithmetic than classical Gram–Schmidt.

What size are Q and R?

This page shows a thin factorization. For an m × n matrix, Q is m × n and R is n × n.

Are my matrix values private?

Yes. The calculations, clipboard text, and downloaded file are created in your browser. This page does not send or save your entries.

Calculation Notes

Last reviewed: August 5, 2026 by the Starlight Tools editorial team.

Inputs use JavaScript double-precision arithmetic and must be zero or have magnitude from 10⁻¹⁰⁰ through 10¹⁰⁰. Rank is estimated from the diagonal of R relative to the input scale. Severely ill-conditioned matrices may need higher-precision numerical software.

Explore more tools