# QR Decomposition Calculator

URL: https://speedycalculator.com/calculators/math/qr-decomposition/
Last updated: 2026-10-30

> The QR decomposition calculator factors a square matrix with independent columns into Q (orthogonal) times R (upper triangular) with the Gram–Schmidt process.

## Inputs

- Matrix size
- a₁
- b₁
- c₁
- d₁
- a₂
- b₂
- c₂
- d₂
- a₃
- b₃
- c₃
- d₃
- a₄
- b₄
- c₄
- d₄

## Results

- Result
- Q (orthogonal)
- R (upper triangular)

## Formula

```
A = Q·R,  QᵀQ = I,  rᵢⱼ = qᵢ · aⱼ
```

## Explanation

QR decomposition solves least squares problems stably and is the engine of the QR algorithm for eigenvalues. Q holds an orthonormal basis of the column space and R records how to rebuild A from it.

### How to use the QR Decomposition Calculator

- Choose the **matrix size** – the matching grid of fields appears.
- Enter the entries **row by row** (a₁ b₁ c₁ is the first row, a₂ b₂ c₂ the second, and so on).
- Read the result; integer matrices give exact fractions.

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

Each column is orthogonalised against the previous ones (modified Gram–Schmidt); the projection coefficients fill R and the normalised vectors form Q.

## Worked example

Inputs — Matrix size: 3 × 3; a₁: 4; b₁: 1; c₁: 2; a₂: 1; b₂: 3; c₂: 0; a₃: 2; b₃: 0; c₃: 5.

Results — **Result = A = Q·R (Q orthogonal, R upper triangular)**; Q (orthogonal) = ⎡ 0.872872 −0.120386 −0.472866 ⎤
⎢ 0.218218 0.963087 0.157622 ⎥
⎣ 0.436436 −0.240772 0.866921 ⎦; R (upper triangular) = ⎡ 4.58258 1.52753 3.92792 ⎤
⎢ 0 2.76887 −1.44463 ⎥
⎣ 0 0 3.38887 ⎦.

## Key terms

- **Orthogonal matrix**: Columns are orthonormal.

## FAQ

**What does QR decomposition need?**
Linearly independent columns (for a unique R with positive diagonal).

**How is it used for least squares?**
Solve Rx = Qᵀb instead of the normal equations.

**Is Gram–Schmidt the only way?**
Householder reflections and Givens rotations are more stable alternatives.

**Is Q square?**
For a square A, yes; for tall A, the thin Q has the same shape as A.


## Sources

- [Wolfram MathWorld – QR decomposition](https://mathworld.wolfram.com/QRDecomposition.html)
- [MIT OpenCourseWare – 18.06 Linear Algebra (Gilbert Strang)](https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/)
- [Jim Hefferon – Linear Algebra (free textbook)](https://hefferon.net/linearalgebra/)
