An LU decomposition writes a square matrix as , with a lower triangular matrix and an upper triangular matrix. We use a unit triangular matrix , meaning . The factors record Gaussian elimination: contains the reduced equations, while stores the elimination multipliers needed to reconstruct the original equations. This makes Reusing LU factors for multiple right-hand sides inexpensive.[ref]
For an invertible matrix, unpivoted LU decomposition requires nonzero pivot elements at every elimination step; invertibility alone does not guarantee this. In general use Pivoted LU decomposition, with the explicit convention and a permutation matrix . Once the factors exist, solving a linear system needs forward substitution followed by back substitution, rather than forming a matrix inverse.
Here is an original example of Gaussian elimination that can be checked entirely with integers. Start withThe first pivot element is . The elimination multipliers are and . Apply the elementary row operations and to obtainNow the second pivot element is , and . The elementary row operation givesImportantly, comes from the current reduced matrix, not the original entry . To reconstruct from , its second row is twice the first row of plus the second; its third row is minus the first row of plus three times the second plus the third. These are exactly the coefficients in the lower triangular matrix .
Gaussian elimination turns a three-by-three matrix into an upper triangular matrix, while elimination multipliers are stored in a lower triangular matrix
. Details. The unpivoted calculation here illustrates the structure of LU decomposition; applying partial pivoting to this particular would choose a different first row and different factors. Both procedures can represent the same linear system when their permutation matrices are handled consistently.
A unit triangular matrix is a triangular matrix whose diagonal entries are all one. It is an invertible matrix with determinant one. In the convention used for LU decomposition, is a unit lower triangular matrix, so forward substitution needs no division by its diagonal entries.
Given Pivoted LU decomposition , the linear system is equivalent to . Introduce the intermediate vector : first use forward substitution to solve , then back substitution to solve . With unpivoted LU decomposition, is the identity matrix, so the first right-hand side is simply .[ref]
For the factors in Computed three-by-three LU decomposition and , forward substitution givesThen back substitution givesDirect matrix multiplication verifies . More generally, the back substitution recurrence isThe direction matters: the last row contains only , whereas the first row generally involves every unknown. No dense matrix inverse is needed for either triangular solve.
Forward substitution solves a linear system with a lower triangular matrix and nonzero diagonal, from the first row downward:The first sum is empty, so . Each subsequent row uses only components already found. For a unit triangular matrix , omit the division because . The complementary procedure, back substitution, solves an upper triangular matrix system from the last row upward.[ref]
We fix the convention : the permutation matrix acts on the rows of , and the same row ordering must be applied to before the Triangular solves for LU decomposition. Equivalently, , since . LAPACK documents its factors as instead, so check the defining equation rather than just the letter .[ref] Partial pivoting selects the largest absolute candidate in the current column, among rows , before forming elimination multipliers.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.6.1, Definition 2.6.1; §2.6.2, Definition 2.6.2 and equation (2.6.1): pivot selection and reordered-row factorization
A zero first pivot element does not imply a singular matrix. For example,Unpivoted Gaussian elimination would divide by zero. Indeed, no with a unit lower triangular matrix exists: would force , contradicting . One row interchange resolves the obstruction. For , use ; back substitution then gives . Using the original with these factors would solve a different linear system.
Partial pivoting bounds each elimination multiplier by one in absolute value in exact arithmetic. This helps control roundoff error, but intermediate entries can still grow; it is not an unconditional guarantee of numerical stability for every matrix.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.6.4, Example 2.6.6 and the concluding discussion: stability of unpivoted and pivoted factorization
It also does not remove the original problem's condition number. For the diagonal matrix with , the condition number in the Euclidean norm is . Row permutations preserve this condition number, because they preserve Euclidean norms. Even an exact solve changes from to when the right-hand side changes from to . This sensitivity is a property of the linear system, not a zero-pivot element failure.[ref]For a permutation matrix and elimination matrices , put . Cancellation of adjacent gives . If the and their inverses are lower triangular, then with and . Lower triangularity needs checking: an arbitrary permutation does not preserve it.
When a fixed matrix is used with several forcing or measurement vectors, compute its Pivoted LU decomposition once. Collect right-hand sides into the columns of , and the corresponding solutions into . ThenEach column undergoes the same row permutation, forward substitution and back substitution. Neither , nor depends on . This is the useful separation between preparing a linear system and applying its solution procedure repeatedly. LAPACK implements it by taking previously computed factors, permuting all right-hand sides, and performing the two triangular solves.[ref]
For the unpivoted factors in Computed three-by-three LU decomposition, takeDirect matrix multiplication checks all three identities , and . The first column reproduces the previous solve; the other two use exactly the same factors. New right-hand sides can also arrive one at a time. If changes, these stored factors generally need to be recomputed.
One row permutation fixes a zero pivot element; each new right-hand side reuses the same LU decomposition and two triangular solves
. Details. For classical dense Gaussian elimination over the real numbers, count each scalar addition, subtraction, multiplication or division as one arithmetic operation. At step , there are elimination multipliers to divide out and remaining entries, each requiring one multiplication and one subtraction. Thus this implementation's unpivoted factorization count isHere uses Big O notation. Partial pivoting adds comparisons and row movement, leaving the leading arithmetic count unchanged. The leading count agrees with the standard dense LU decomposition analysis.[ref]
With unit , forward substitution uses arithmetic operations. Back substitution uses another plus diagonal divisions. Together these cost per right-hand side; applying a stored row permutation moves entries and requires no scalar arithmetic. In Big O notation, Reusing LU factors for multiple right-hand sides therefore costswhereas refactorizing for each of the right-hand sides costs . For and , the leading counts are about versus arithmetic operations, nearly a tenfold saving. These are operation counts, not measured runtimes: memory access and optimized matrix multiplication also affect speed.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.5.2, Important note after Definition 2.5.2: flop counts are a rough runtime model; the numerical comparison here is an original calculation
Articles by others on the same topic
LU decomposition is a matrix factorization technique used in numerical linear algebra. It involves breaking down a square matrix \( A \) into the product of two matrices: a lower triangular matrix \( L \) and an upper triangular matrix \( U \).

