LU Decomposition Calculator
Decompose a 2x2 or 3x3 matrix into a lower triangular matrix (L) and an upper triangular matrix (U) using Doolittle's method. The calculator also computes the determinant from the U diagonal.
LU decomposition factors a square matrix A into the product of a lower triangular matrix L and an upper triangular matrix U, so that A = L × U.
Why LU Decomposition?
Once you have L and U, solving a system Ax = b becomes two easy steps:
- Solve Ly = b (forward substitution)
- Solve Ux = y (back substitution)
This is much faster than Gaussian elimination when you need to solve the same system with many different right-hand sides.
Doolittle's Method:
In Doolittle's version, L has 1s on its diagonal. The algorithm fills in U row by row and L column by column:
- Row i of U: u_ij = a_ij - sum(l_ik × u_kj) for k = 1 to i-1
- Column j of L: l_ij = (a_ij - sum(l_ik × u_kj)) / u_jj for k = 1 to j-1
2x2 Example:
For A = [[4, 3], [6, 3]]:
- U: u11 = 4, u12 = 3
- L: l21 = 6/4 = 1.5
- U: u22 = 3 - 1.5 × 3 = -1.5
Result: L = [[1, 0], [1.5, 1]], U = [[4, 3], [0, -1.5]]
Determinant Shortcut:
Since det(A) = det(L) × det(U), and det(L) = 1 (all 1s on diagonal), the determinant is simply the product of U's diagonal entries.