LU Decomposition Calculator

Factor a square matrix into lower and upper triangular matrices with Doolittle elimination.

Decompose a matrix
Separate columns with commas or spaces and separate matrix rows with semicolons.

About LU decomposition

LU decomposition expresses a square matrix A as the product L times U. The matrix L is lower triangular, meaning every entry above its main diagonal is zero. The matrix U is upper triangular, meaning every entry below its main diagonal is zero. In the Doolittle convention used here, every diagonal entry of L equals one. Multiplying the two displayed factors reconstructs the original input matrix, subject only to ordinary floating-point rounding. The factorization is built from Gaussian elimination. Each elimination multiplier that would normally be used to clear an entry below a pivot is stored in L. The evolving row-echelon matrix becomes U. This organization is valuable because it records the elimination work instead of discarding it. Once L and U are available, the same coefficient matrix can be reused to solve systems with many different right-hand sides much more efficiently than repeating elimination from the beginning. To solve A times x equals b, first solve L times y equals b by forward substitution. Then solve U times x equals y by backward substitution. Triangular systems are straightforward because each successive equation introduces only one new unknown. LU factors are also useful for computing determinants: with unit diagonal L, the determinant is the product of the diagonal entries of U. Matrix inversion and numerical simulations likewise use this structure as a basic building block. This calculator accepts compact matrix notation. Type values in each row separated by commas or spaces, and place a semicolon between rows. Every row must contain the same number of entries as the number of rows, because LU decomposition in this form requires a square matrix. Negative values and decimals are supported. Results are rounded only for display, while the elimination itself uses JavaScript double-precision arithmetic. The implementation uses unpivoted Doolittle decomposition, so each pivot encountered during elimination must be nonzero. Some perfectly invertible matrices begin with a zero pivot and require row permutation before factorization. In a full numerical library that operation is represented by a permutation matrix P in the relation P times A equals L times U. If this calculator reports a pivot error, reorder suitable rows before entering the matrix or use a pivoted solver. For well-conditioned classroom examples and matrices with usable diagonal pivots, the displayed factorization provides a clear and immediately checkable result.

LU decomposition examples

Matrix AFactorsCheck
4,3;6,3L: 1,0;1.5,1 and U: 4,3;0,-1.5Multiplying L by U returns the original two-row matrix.
2,0;0,5L: identity and U: 2,0;0,5A diagonal matrix is already upper triangular.
2,1,1;4,-6,0;-2,7,2L: 1,0,0;2,1,0;-1,-1,1The corresponding U rows are 2,1,1;0,-8,-2;0,0,1.

How to calculate LU decomposition

  1. Write each matrix row as comma-separated or space-separated numbers.
  2. Join the rows with semicolons and confirm the matrix is square.
  3. Select Decompose Matrix to run Doolittle Gaussian elimination.
  4. Read L and U, then multiply them to verify that their product equals the input.

LU decomposition FAQ

What is an LU decomposition?

It factors a square matrix into a lower triangular matrix and an upper triangular matrix. Their product reproduces the original matrix when no row permutation is required.

Why is LU factorization useful?

It lets you reuse elimination work when solving several systems with the same coefficient matrix. It also simplifies determinant, inverse, and numerical-analysis calculations.

What matrix format should I enter?

Separate entries in a row with commas or spaces and separate rows with semicolons. Enter the same number of entries in every row as there are rows.

Why can a matrix produce a pivot error?

Unpivoted Doolittle elimination cannot divide by a zero pivot. Reordering rows may resolve the issue, while general-purpose software uses a permutation matrix and partial pivoting.

Can I enter decimal and negative values?

Yes, finite decimal and negative entries are accepted. Displayed values are rounded to eight decimal places to keep the factors readable.