LU Decomposition Calculator (A = LU and PA = LU)
Factor a square matrix into a lower triangular L and an upper triangular U with exact fractions — Doolittle A = LU or partial pivoting PA = LU — plus the permutation matrix and determinant.
How it works
A = LU (or PA = LU) · uᵢⱼ: Gaussian elimination result · lᵢₖ = (entry being eliminated) ÷ (pivot uₖₖ), lᵢᵢ = 1 · det(A) = (−1)^(row swaps) × u₁₁·u₂₂·…·uₙₙ
LU decomposition records Gaussian elimination: U is the upper triangular matrix you end with, and L stores the multipliers you used below a diagonal of ones (Doolittle form). Once A = LU is known, Ax = b is solved by forward substitution (Ly = b) and back substitution (Ux = y). If a zero pivot appears, rows must be swapped: partial pivoting picks the largest available pivot and gives PA = LU, which always exists.
Worked example
A = [2 1 1; 4 −6 0; −2 7 2]: the multipliers are l₂₁ = 4/2 = 2 and l₃₁ = −2/2 = −1, giving rows [0 −8 −2] and [0 8 3]; then l₃₂ = 8/(−8) = −1 gives [0 0 1]. So L = [1 0 0; 2 1 0; −1 −1 1] and U = [2 1 1; 0 −8 −2; 0 0 1], and det(A) = 2·(−8)·1 = −16.
Sources: MIT OpenCourseWare 18.06 (Strang) — Factorization into A = LU · Wolfram MathWorld — LU Decomposition
Frequently asked questions
What is LU decomposition used for?
Solving many systems Ax = b with the same A quickly, computing determinants and inverses. Factoring costs about n³/3 operations once; each new right-hand side then costs only about n² operations.
Does every matrix have an LU decomposition?
Not without row swaps — [0 1; 1 0] has none. With partial pivoting every square matrix has a factorization PA = LU.
What is the difference between Doolittle and Crout?
Doolittle puts the ones on the diagonal of L; Crout puts them on the diagonal of U. Both describe the same elimination.
How do I get the determinant from LU?
Multiply the diagonal of U, and change the sign once for every row swap. Here 2 × (−8) × 1 = −16.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.