Lu Decomposition Calculator - L and U Factor Output

Use this LU decomposition calculator to factor a 2x2 or 3x3 matrix into the lower L and upper U triangular factors with det(A) and a verification step.

Updated: June 16, 2026 • Free Tool

Lu Decomposition Calculator

Pick 2x2 for a 2x2 square matrix or 3x3 for a 3x3 square matrix. The unused 3x3 cells are treated as zero in 2x2 mode.

Top-left entry of A.

First row, second column entry of A.

First row, third column entry of A. Leave at 0 in 2x2 mode.

Second row, first column entry of A.

Second row, second column entry of A. This is the lower-right entry in 2x2 mode.

Second row, third column entry of A. Leave at 0 in 2x2 mode.

Third row, first column entry of A. Leave at 0 in 2x2 mode.

Third row, second column entry of A. Leave at 0 in 2x2 mode.

Bottom-right entry of A. Leave at 0 in 2x2 mode.

Results

Lower factor L
0
Upper factor U 0
L[2,1] 0
L[3,1] 0
L[3,2] 0
U[1,1] 0
U[1,2] 0
U[1,3] 0
U[2,2] 0
U[2,3] 0
U[3,3] 0
det(A) 0
L U verification error 0

What Is Lu Decomposition Calculator?

The LU decomposition calculator factors a 2x2 or 3x3 square matrix A into a lower triangular L and an upper triangular U whose product equals A, and reports the L and U bracket matrices, det(A), and a L U verification error. Use it to solve a linear system, to compute det(A), to verify a Gaussian elimination routine, or to audit factors from a numerical library.

  • Solve a small linear system: Replace a direct solve against A with forward and back substitution through L and U. The same factors handle many right-hand sides at almost no extra cost.
  • Compute a determinant without cofactors: Take the product of the diagonal entries of U as det(A), avoiding a 3x3 expansion by hand.
  • Verify a Gaussian elimination routine: Run the calculator on a known matrix and compare L and U against your own code. The L U verification error catches rounding bugs.

The Doolittle convention sets the diagonal of L to 1 and lets U carry the pivots, so each L[i][k] entry is the row operation that zeroed the matching entry of A. The product L U is recomputed and compared entry by entry with the original A, so the L U verification error exposes any rounding noise.

When the input matrix is symmetric and positive definite, the Cholesky Decomposition Calculator computes the same triangular factorization twice as fast and returns a single L with A = L L^T, which is the natural next step for covariance and kernel matrices.

How Lu Decomposition Calculator Works

The calculator uses the Doolittle algorithm, walking the matrix column by column, dividing entries below the diagonal by the current pivot to fill L, and updating the submatrix to fill U.

A = L U; U[k][j] = A[k][j] - sum_{s<k} L[k][s] U[s][j] for j >= k; L[i][k] = (A[i][k] - sum_{s<k} L[i][s] U[s][k]) / U[k][k] for i > k; L[k][k] = 1
  • A: The square input matrix whose entries the user enters in row-major order.
  • L: The lower triangular factor with 1s on the diagonal. The off-diagonal entries L[i][k] are the multipliers used to zero the entries below the diagonal of A.
  • U: The upper triangular factor whose diagonal entries are the pivots. The first row of U equals the first row of A, and each subsequent row of U is the result of subtracting L[i][k] U[k][*] from A[i][*].
  • k: The current elimination step. Each step fixes one pivot U[k][k], one row of U, and one column of L.

Each step k takes A[k][k] as the pivot, divides entries below it by that pivot to form the column of L, and sweeps those multipliers across the remaining rows of U. After the loops finish, the calculator rebuilds L U row by row and reports the largest absolute difference from the original A. A clean factorization lands at 1e-15.

Worked example: 2x2 matrix [[4, 3], [6, 3]]

A = [[4, 3], [6, 3]]

A = [[4, 3], [6, 3]]. L[1,0] = 6 / 4 = 1.5. U[0,0] = 4, U[0,1] = 3. U[1,1] = 3 - 1.5 * 3 = -1.5.

L = [[1, 0], [1.5, 1]], U = [[4, 3], [0, -1.5]], det(A) = -6, L U verification error = 0.

The pivot U[2,2] is negative, which is normal for indefinite matrices. The determinant 4 * -1.5 = -6 matches the 2x2 formula.

According to Wikipedia LU decomposition, any square matrix A with non-zero leading principal minors can be written as A = L U, where L is lower triangular with a unit diagonal and U is upper triangular in the Doolittle variant.

Once L and U are in hand, the inverse of A equals U^{-1} L^{-1}, and the Adjoint Matrix Calculator shows the same adjugate-of-A formula that backs the cofactor expansion of det(A) when you want a hand cross-check.

Key Concepts Explained

These four ideas show up in every LU decomposition.

Doolittle convention

The Doolittle variant of LU decomposition sets the diagonal of L to 1 and lets U carry the pivots. The off-diagonal entries of L are the multipliers used to zero entries below the diagonal of A.

Pivots and the diagonal of U

The diagonal of U is the sequence of pivots. Their product equals det(A) in the Doolittle variant. A zero pivot means the algorithm cannot continue without a row swap.

Partial pivoting

Numerical LU factorizations swap rows so that the largest entry in absolute value sits on the diagonal before each elimination step. The basic Doolittle algorithm used here does not perform those swaps.

LU decomposition versus Cholesky

Cholesky decomposition is the lower triangular square root of a symmetric positive definite matrix, written A = L L^T. LU decomposition works on any square matrix with non-zero pivots. Cholesky is twice as fast on a symmetric positive definite matrix, but LU is the right tool for the general case.

The multiplier L[i][k] is the same number that you would write on the left of a Gaussian elimination row operation. Partial pivoting matters when the input is nearly singular, and the basic Doolittle algorithm used here surfaces a clear error when a pivot becomes too small.

The reason LU decomposition matters is that it turns a single expensive solve against A into a forward substitution against L and a back substitution against U, which is exactly the workflow the System of Equations Calculator runs in the background for a small linear system.

How to Use This Calculator

Enter the matrix entries in row-major order, pick the matrix size, and read the L and U bracket matrices, det(A), and the L U verification error on the right.

  1. 1 Choose the matrix size: Pick 2x2 for a 2x2 square matrix or 3x3 for a 3x3 square matrix. In 2x2 mode the calculator only reads a, b, d, and e.
  2. 2 Fill the matrix in row-major order: Type a11 through a33 into the matching cells, which are labeled with subscripts.
  3. 3 Read the L and U bracket matrices: The first two result lines are the L and U factors in bracket-matrix form, ready to copy.
  4. 4 Read det(A) and the verification error: The det(A) row is the product of the pivots. The L U verification error is the largest difference between A and L U.
  5. 5 Handle a zero-pivot error: If the calculator reports a zero pivot, swap two rows of the input and re-run.

For A = [[4, 3], [6, 3]], the calculator reports L = [[1, 0], [1.5, 1]], U = [[4, 3], [0, -1.5]], det(A) = -6, and a L U verification error of 0. Copy L and U into a notebook to solve a small linear system with forward and back substitution.

The L and U factors feed directly into ordinary least squares through the normal equations X^T X, and the Linear Regression Calculator uses the same triangular solve pattern to invert X^T X without a cofactor expansion.

Benefits of Using This Calculator

The main benefit is replacing a hand-written Doolittle routine with a tool that returns both factors and a verification step in the same pass.

  • Returns both factors in one pass: The calculator outputs L and U as bracket matrices and as individual L[i,k] and U[k,j] entries in a single panel.
  • Surfaces pivot problems before a solve: A zero pivot stops the algorithm with a clear error message that names the failing step, instead of silently producing NaNs.
  • Pivots and the determinant in the same view: det(A) is the product of the U pivots, so the calculator surfaces the determinant next to the pivots themselves.
  • Built-in L U verification step: The L U verification error catches numerical roundoff, mis-typed cells, and any sign error in the elimination loop.

The L and U bracket matrices paste into a Python or Julia notebook without manual translation, and the L U verification error is a teaching aid because watching the error shrink is a fast way to feel how pivoting stabilizes a factorization.

The L[i][k] multipliers and the columns of U have a clean geometric interpretation as projections, and the Vector Magnitude Calculator is the right tool to double-check the dot product and length that show up when you read L and U as a change of basis.

Factors That Affect Your Results

Three factors decide whether the Doolittle algorithm in this LU decomposition calculator succeeds and how clean the factors are.

Non-zero leading pivots

Each diagonal entry of U must be strictly non-zero. A zero pivot is a true singularity in this variant.

Magnitude of the pivots

Pivots that are very small relative to the off-diagonal entries of A can lose precision during the L[i][k] division.

Symmetry and positive definiteness

A general LU factorization works on any square matrix, but for a symmetric positive definite A, the Cholesky decomposition is twice as fast.

  • The calculator only handles 2x2 and 3x3 matrices. For larger problems a library routine such as LAPACK GETRF or numpy.linalg.lu is the right next step.
  • The output assumes the input is real-valued. A complex matrix needs a different factorization that uses the conjugate transpose.

When the matrix is not strictly diagonally dominant, the basic Doolittle algorithm can still succeed, but the multipliers L[i][k] can be larger than one and the L U verification error can climb above 1e-12, which is the signal to switch on partial pivoting.

According to Wolfram MathWorld LU decomposition, the entries of L and U in the Doolittle decomposition satisfy L[i][j] = (A[i][j] - sum_{k<j} L[i][k] U[k][j]) / U[j][j] for i > j and U[i][j] = A[i][j] - sum_{k<i} L[i][k] U[k][j] for j >= i.

According to LAPACK GETRF documentation, the production LU factorization is computed with partial pivoting and returns a permutation matrix P along with L and U, while a basic textbook Doolittle decomposition assumes pivots are non-zero and produces L and U without P.

The product of the pivots equals det(A), and the determinant is also the constant term of the characteristic polynomial of A, so the Characteristic Polynomial Calculator is the natural follow-up to confirm the pivot product against the polynomial expansion.

LU decomposition calculator showing the lower triangular L and upper triangular U factorization of a 2x2 or 3x3 matrix with det(A) and verification
LU decomposition calculator showing the lower triangular L and upper triangular U factorization of a 2x2 or 3x3 matrix with det(A) and verification

Frequently Asked Questions

Q: What is an LU decomposition calculator used for?

A: An LU decomposition calculator factors a square matrix A into a lower triangular matrix L and an upper triangular matrix U whose product equals A. It is used to solve a small linear system Ax = b efficiently, to compute det(A) from the product of the pivots, to verify a Gaussian elimination routine, and to audit the L and U factors returned by a numerical library.

Q: How does the LU decomposition calculator work on a 2x2 matrix?

A: For a 2x2 matrix, the calculator takes a11 as the first pivot, divides a21 by a11 to form the multiplier L21, and then subtracts L21 times the first row from the second row to produce U22. The output is L = [[1, 0], [L21, 1]] and U = [[a11, a12], [0, U22]], with det(A) equal to a11 times U22.

Q: Can the calculator handle 3x3 matrices?

A: Yes. The calculator supports 2x2 and 3x3 square matrices. In 3x3 mode it runs the same Doolittle algorithm over three steps, producing six L entries (three multipliers and three diagonal ones), nine U entries, and det(A) equal to u11 times u22 times u33.

Q: What is the difference between Doolittle and Crout LU decomposition?

A: The Doolittle variant fixes the diagonal of L at 1 and lets U carry the pivots, while the Crout variant fixes the diagonal of U at 1 and lets L carry the pivots. Both factor the same A, but the multipliers land in opposite triangular factors, so the resulting L and U are not the same and are not transposes of each other in general.

Q: What happens when a pivot becomes zero in LU decomposition?

A: The basic Doolittle algorithm cannot divide by a zero pivot, so the calculator stops at the failing step and reports which pivot became zero. The standard numerical fix is partial pivoting, which swaps rows so that the largest entry in absolute value sits on the diagonal before each elimination step.

Q: Is LU decomposition the same as Gaussian elimination?

A: Gaussian elimination reduces A to an upper triangular echelon form using row operations, and LU decomposition records those same row operations in a lower triangular L. The product L U equals the original A, so LU is the matrix form of Gaussian elimination, with L carrying the multipliers and U carrying the upper triangular echelon form, not the reduced row echelon form.