🔨Matrix Decomposition Calculator - LU, Cholesky, QR, SVD
The four core matrix factorizations of linear algebra and numerical analysis, worked step by step and verified. LU decomposition uses Gaussian elimination with partial pivoting to produce P·A = L·U: each column picks the entry with the largest absolute value as the pivot, row swaps are recorded, every multiplier and row operation is listed, and L and U are shown after each step. Integers, fractions and decimals are all handled as exact fractions (BigInt), the final P·A and L·U are checked to be identical entry by entry, and the determinant comes for free. Cholesky first checks symmetry, then computes l_jj = √(a_jj − Σ l_jk²) column by column; if a value under the square root isn’t positive it tells you which column, proving the matrix isn’t positive definite. QR offers modified Gram–Schmidt (listing every projection r_ij and remaining length) or Householder reflections (each reflection vector and the new diagonal entry), with the orthogonality error ‖QᵀQ − I‖. The SVD uses one-sided Jacobi rotations on any shape up to 8×8 and reports U, Σ, Vᵀ, the numerical rank, the condition number and the spectral and Frobenius norms; a slider shows the rank-k approximation A_k and its error (the Eckart–Young theorem), and an image demo compresses a grayscale picture — or one you upload — by keeping only k singular values. Every factorization shows its reconstruction residual, and the eigendecomposition tab links to the eigenvalue tool. LU, Cholesky and QR go up to 6×6, and you can paste straight from Excel.
Free · No sign-up · Runs in your browserLast updated:
How to use Matrix Decomposition Calculator
- 1Choose a factorization: LU, Cholesky, QR, SVD or eigen
- 2Set the matrix size and enter numbers (paste from Excel, use fractions like 3/4, or click Random)
- 3Read the steps, the factor matrices, rank and condition number, and the reconstruction check
FAQ
- Why does LU need pivoting and a permutation matrix P?
- Without row swaps, LU fails as soon as a pivot is zero (try A = [[0,1],[1,0]]), and a tiny pivot produces huge multipliers that blow up rounding errors. Partial pivoting takes the largest entry in each column as the pivot, so every |l_ij| ≤ 1 and the factorization is numerically stable. The row swaps are collected in P, which is why the result reads P·A = L·U.
- What is the Cholesky decomposition used for?
- A symmetric positive definite matrix — a covariance matrix, or the normal equations AᵀA in least squares — factors as L·Lᵀ in about half the work of LU, with no pivoting. It’s also the quickest test for positive definiteness: if a zero or negative value appears under a square root, the matrix isn’t positive definite. Monte Carlo simulations use it to generate correlated random variables.
- How do Gram–Schmidt and Householder QR differ?
- In exact arithmetic they give the same Q and R, up to signs. Gram–Schmidt is intuitive — subtract projections column by column and normalize — but loses orthogonality when columns are nearly dependent. Householder zeroes everything below the diagonal with a sequence of reflections, keeps the orthogonality error near machine precision, and yields a full m×m orthogonal Q; it’s what libraries like LAPACK use.
- How are singular values, rank and condition number related?
- The number of nonzero singular values is the rank (numerically, those above max(m,n)·σ₁·ε). The condition number κ₂ = σ_max / σ_min measures how much errors can be amplified when solving linear systems; it’s infinite for a singular matrix. Keeping the first k singular values gives A_k, the closest rank-k matrix to A, and the 2-norm error is exactly σ_{k+1}.