QR Decomposition Calculator — 2×2 Matrix
Decompose a 2×2 matrix A = QR where Q is orthogonal (Q^T Q = I) and R is upper triangular. Enter the four matrix elements and the calculator applies Gram-Schmidt to the columns to produce Q and R instantly.
Determinant of A = R[1,1] × R[2,2] | non-zero confirms full rank
- 1
A[1,1] × A[2,2]
3 × 2 = 6 - 2
A[1,2] × A[2,1]
1 × 4 = 4 - 3
det(A) = A[1,1]·A[2,2] − A[1,2]·A[2,1]
6 − 4 = 2A non-zero determinant confirms that the columns are linearly independent and QR decomposition exists.
How does this calculator work?
QR decomposition factors A = QR using Gram-Schmidt: normalise column 1 to get ê₁; subtract its projection from column 2 and normalise to get ê₂. Q = [ê₁|ê₂] (orthogonal) and R = [[‖v₁‖, v₂·ê₁],[0,‖u₂‖]] (upper triangular). Requires linearly independent columns (det ≠ 0). Used in least-squares, eigenvalue algorithms, and regression.
Formula
How this is calculated
QR decomposition factors a matrix A into a product QR where Q is orthogonal (Q^T Q = I, so Q^(−1) = Q^T) and R is upper triangular with non-negative diagonal entries. This is computed here using Gram-Schmidt orthogonalisation applied to the columns of A.
Let v₁ and v₂ be the columns of A. Step 1: normalise v₁ to get the unit vector ê₁ = v₁/‖v₁‖ (this becomes column 1 of Q, and ‖v₁‖ becomes R[1,1]). Step 2: subtract the projection of v₂ onto ê₁ to get u₂ = v₂ − (v₂·ê₁)ê₁; normalise to ê₂ = u₂/‖u₂‖ (column 2 of Q; ‖u₂‖ = R[2,2]; the projection v₂·ê₁ = R[1,2]). The lower-left entry R[2,1] = 0 by construction.
QR decomposition exists and is unique (with positive diagonal of R) whenever A has linearly independent columns. It is numerically stable and widely used: solving least-squares problems (Ax ≈ b) via back-substitution on Rx = Q^T b, computing eigenvalues via QR iteration, and regression. The determinant of A equals det(Q) × det(R) = ±1 × R[1,1] × R[2,2].
Frequently asked questions
QR decomposition is used to solve least-squares problems (Ax ≈ b), compute eigenvalues via the QR algorithm, and perform numerically stable Gaussian elimination. It is preferred over LU decomposition when numerical stability matters, because Q is orthogonal and does not amplify rounding errors.
Multiply Q × R and check that it equals the original matrix A. Also verify Q is orthogonal: Q^T Q should equal the identity matrix (off-diagonal entries ≈ 0, diagonal ≈ 1). The calculator shows the off-diagonal element of Q^T Q — any value well above floating-point precision suggests an error.
If the columns of A are linearly dependent, the second Gram-Schmidt step produces a zero vector u₂, making ê₂ and R[2,2] undefined. Geometrically the matrix projects 2-D space onto a line rather than a plane, so no orthonormal basis for the column space exists in 2-D. The decomposition fails, and the matrix is singular (det = 0).
Also known as
TG we-Calculate Editorial Team. (2026). QR Decomposition Calculator — 2×2 Matrix [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/qr-decomposition-calculator
TG we-Calculate Editorial Team. "QR Decomposition Calculator — 2×2 Matrix." TG we-Calculate. 2026. https://we-calculate.com/calculator/qr-decomposition-calculator.
TG we-Calculate Editorial Team, "QR Decomposition Calculator — 2×2 Matrix," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/qr-decomposition-calculator
@misc{wecalculate_qr_decomposition_calculator, title = {QR Decomposition Calculator — 2×2 Matrix}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/qr-decomposition-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
