LU Decomposition Calculator
Factorize a square matrix into lower and upper triangular factors, commonly expressed as A = LU. LU decomposition is useful for solving systems of linear equations efficiently, particularly when working with multiple right-hand sides.
A
Learn About LU Decomposition
In numerical linear algebra, LU decomposition factorizes a square matrix $\mathbf{A} \in \mathbb{R}^{n \times n}$ into the product of two triangular matrices:
where $\mathbf{L}$ is a unit lower triangular matrix (diagonal entries equal $1$, upper entries equal $0$), and $\mathbf{U}$ is an upper triangular matrix (lower entries equal $0$).
LU factorization represents Gaussian elimination in matrix form. It decouples the coefficient matrix from the right-hand side vector $\mathbf{b}$, enabling rapid solutions to $\mathbf{A}\mathbf{x} = \mathbf{b}$ via forward substitution ($\mathbf{L}\mathbf{y} = \mathbf{b}$) followed by back-substitution ($\mathbf{U}\mathbf{x} = \mathbf{y}$).
Doolittle's Factorization Algorithm
GammaCalculator implements Doolittle's algorithm using exact rational arithmetic:
For each pivot column $j \in \{1, \dots, n\}$ with pivot $u_{jj} \ne 0$:
- Multipliers: For each row $i > j$, compute the row multiplier:
- Row Elimination: Eliminate the sub-diagonal entry in row $i$:
- Storage: The multiplier $l_{ij}$ forms entry $(i, j)$ in $\mathbf{L}$.
Existence Condition
An unpivoted Doolittle LU decomposition exists if and only if all of the first $n-1$ leading principal minors of $\mathbf{A}$ are non-zero. If a zero pivot ($u_{jj} = 0$) occurs during elimination, the standard factorization $\mathbf{A} = \mathbf{L}\mathbf{U}$ does not exist, requiring row permutations ($\mathbf{P}\mathbf{A} = \mathbf{L}\mathbf{U}$).
Worked Numerical Example
Consider the $3 \times 3$ matrix:
- Column 1 ($j=1$): Pivot $u_{11} = 2$.
- $l_{21} = \frac{4}{2} = 2 \implies R_2 \leftarrow R_2 - 2R_1 = [0, -8, -2]$.
- $l_{31} = \frac{-2}{2} = -1 \implies R_3 \leftarrow R_3 + 1R_1 = [0, 8, 3]$.
- Column 2 ($j=2$): Pivot $u_{22} = -8$.
- $l_{32} = \frac{8}{-8} = -1 \implies R_3 \leftarrow R_3 + 1R_2 = [0, 0, 1]$.
- Resulting Factors:
- Verification:
What is the computational advantage of LU decomposition over computing the matrix inverse?
Solving $\mathbf{A}\mathbf{x} = \mathbf{b}$ via LU decomposition requires $\frac{2}{3}n^3$ operations for factorization and $2n^2$ operations for triangular substitutions. Explicitly computing $\mathbf{A}^{-1}$ requires $2n^3$ operations—three times as much work—and introduces greater roundoff error.
Why does the calculator stop if a zero pivot is encountered?
The Doolittle algorithm factorizes $\mathbf{A} = \mathbf{L}\mathbf{U}$ without permuting rows. If a diagonal entry becomes zero during elimination ($u_{jj} = 0$), division by the pivot is undefined. While the matrix may still be invertible, it requires row swaps, producing a permuted factorization $\mathbf{P}\mathbf{A} = \mathbf{L}\mathbf{U}$.
How does LU decomposition simplify finding the determinant?
Because $\mathbf{L}$ is unit lower triangular, its determinant is $1$. By the multiplicative property of determinants:
The determinant equals the product of the diagonal pivots of $\mathbf{U}$.
What is the difference between Doolittle's, Crout's, and Cholesky's algorithms?
Doolittle's algorithm sets the diagonal of $\mathbf{L}$ to ones ($l_{ii} = 1$). Crout's algorithm sets the diagonal of $\mathbf{U}$ to ones ($u_{ii} = 1$). Cholesky decomposition applies specifically to symmetric positive-definite matrices, setting $\mathbf{U} = \mathbf{L}^T$ with matching square roots on both diagonals.
- Turing's Pivoting Breakthrough: In 1948, Alan Turing analyzed error propagation in Gaussian elimination and LU decomposition, formally proving why partial pivoting ($\mathbf{P}\mathbf{A} = \mathbf{L}\mathbf{U}$) prevents exponential error growth in numerical computations.
- Compact In-Place Storage: In numerical linear algebra libraries like LAPACK, $\mathbf{L}$ and $\mathbf{U}$ are stored in the memory space of $\mathbf{A}$. Because the diagonal of $\mathbf{L}$ consists entirely of known ones, the strictly lower triangle stores $\mathbf{L}$ while the upper triangle stores $\mathbf{U}$ without allocating extra memory.