The LUP decomposition of an n × n n \times n n × n matrix A A A is the triple ( L , U , P ) (L, U, P) ( L , U , P ) satisfying
Properties
P P P reorders the rows of A A A as in partial pivoting .
Exists for any nonsingular A A A .
Not unique.
More robust than LU without pivoting, at about the same cost.
Comparison with LU Decomposition
The LU decomposition factors A A A as A = L U A = LU A = LU , without row interchanges. LUP selects the pivot row by size.
Existence
A zero pivot stops the elimination. LUP always factors a nonsingular A A A .
Stability
A small pivot gives large multipliers and amplifies rounding error. Partial pivoting keeps every multiplier at most 1 1 1 in size.
Cost
Factorization costs O ( n 3 ) O(n^3) O ( n 3 ) for both. Each solve costs O ( n 2 ) O(n^2) O ( n 2 ) . LUP adds the row swaps and the permutation of b ⃗ \vec{b} b .
When to Use Which
LUP is the default for a general dense matrix. The pivot sizes are unknown in advance.
Use LU without pivoting when the pivots are safe by construction.
Diagonally dominant A A A
Every pivot is nonzero without a swap.
Symmetric positive definite A A A
Every leading principal minor is positive.
Banded or sparse A A A
Row interchanges would add fill-in.
Solving A x ⃗ = b ⃗ A\vec{x} = \vec{b} A x = b
P A x ⃗ = P b ⃗ PA\vec{x} = P\vec{b} P A x = P b becomes L U x ⃗ = P b ⃗ LU\vec{x} = P\vec{b} LU x = P b .
Solve L y ⃗ = P b ⃗ L\vec{y} = P\vec{b} L y = P b by forward substitution.
Solve U x ⃗ = y ⃗ U\vec{x} = \vec{y} U x = y by back substitution .
Recursive Leading-Row-Column Algorithm
Set A ( 0 ) = A A^{(0)} = A A ( 0 ) = A . At recursion depth k k k , factor the current ( n − k ) × ( n − k ) (n-k) \times (n-k) ( n − k ) × ( n − k ) matrix A ( k ) A^{(k)} A ( k ) .
Let S ( k ) S^{(k)} S ( k ) swap the row with the largest entry in magnitude in the first column of A ( k ) A^{(k)} A ( k ) into the first row. Partition the swapped matrix B ( k ) = S ( k ) A ( k ) B^{(k)} = S^{(k)}A^{(k)} B ( k ) = S ( k ) A ( k ) as
Schur Complement
Define the multiplier vector and the next recursive matrix as
A ( k + 1 ) A^{(k+1)} A ( k + 1 ) is the Schur complement of α ( k ) α^{(k)} α ( k ) in B ( k ) B^{(k)} B ( k ) .
Base Case
When A ( k ) A^{(k)} A ( k ) is 1 × 1 1 \times 1 1 × 1 , set
Recursive Step
For a matrix larger than 1 × 1 1 \times 1 1 × 1 :
Form B ( k ) = S ( k ) A ( k ) B^{(k)} = S^{(k)}A^{(k)} B ( k ) = S ( k ) A ( k ) and partition it.
Compute ℓ ( k ) \ell^{(k)} ℓ ( k ) and A ( k + 1 ) A^{(k+1)} A ( k + 1 ) .
Recurse on A ( k + 1 ) A^{(k+1)} A ( k + 1 ) to get P ( k + 1 ) A ( k + 1 ) = L ( k + 1 ) U ( k + 1 ) P^{(k+1)}A^{(k+1)} = L^{(k+1)}U^{(k+1)} P ( k + 1 ) A ( k + 1 ) = L ( k + 1 ) U ( k + 1 ) .
Return
The required decomposition is P = P ( 0 ) P = P^{(0)} P = P ( 0 ) , L = L ( 0 ) L = L^{(0)} L = L ( 0 ) , U = U ( 0 ) U = U^{(0)} U = U ( 0 ) .
Worked Examples
Example 1
Find L L L , U U U , P P P for
Solution Reveal Hide Set A ( 0 ) = A A^{(0)} = A A ( 0 ) = A . At depth 0 0 0 , column 1 1 1 is ( 0 , 2 , 6 ) T (0, 2, 6)^T ( 0 , 2 , 6 ) T . The pivot is 6 6 6 in row 3 3 3 . Let S ( 0 ) S^{(0)} S ( 0 ) swap rows 1 1 1 and 3 3 3 .
S ( 0 ) = ( 0 0 1 0 1 0 1 0 0 ) S^{(0)} = \begin{pmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{pmatrix} S ( 0 ) = 0 0 1 0 1 0 1 0 0 B ( 0 ) = S ( 0 ) A ( 0 ) = ( 6 8 8 2 9 0 0 5 5 ) B^{(0)} = S^{(0)}A^{(0)} = \begin{pmatrix} 6 & 8 & 8 \\ 2 & 9 & 0 \\ 0 & 5 & 5 \end{pmatrix} B ( 0 ) = S ( 0 ) A ( 0 ) = 6 2 0 8 9 5 8 0 5 α ( 0 ) = 6 , ( r ( 0 ) ) T = ( 8 8 ) , c ( 0 ) = ( 2 0 ) , C ( 0 ) = ( 9 0 5 5 ) \alpha^{(0)} = 6, \quad \left(r^{(0)}\right)^T = (8 \enspace 8), \quad c^{(0)} = \begin{pmatrix} 2 \\ 0 \end{pmatrix}, \quad C^{(0)} = \begin{pmatrix} 9 & 0 \\ 5 & 5 \end{pmatrix} α ( 0 ) = 6 , ( r ( 0 ) ) T = ( 8 8 ) , c ( 0 ) = ( 2 0 ) , C ( 0 ) = ( 9 5 0 5 ) ℓ ( 0 ) = ( 1 / 3 0 ) , A ( 1 ) = C ( 0 ) − ℓ ( 0 ) ( r ( 0 ) ) T = ( 19 / 3 − 8 / 3 5 5 ) \ell^{(0)} = \begin{pmatrix} 1/3 \\ 0 \end{pmatrix}, \quad
A^{(1)} = C^{(0)} - \ell^{(0)}\left(r^{(0)}\right)^T = \begin{pmatrix} 19/3 & -8/3 \\ 5 & 5 \end{pmatrix} ℓ ( 0 ) = ( 1/3 0 ) , A ( 1 ) = C ( 0 ) − ℓ ( 0 ) ( r ( 0 ) ) T = ( 19/3 5 − 8/3 5 ) At depth 1 1 1 , column 1 1 1 of A ( 1 ) A^{(1)} A ( 1 ) is ( 19 / 3 , 5 ) T (19/3, 5)^T ( 19/3 , 5 ) T . The pivot is already in row 1 1 1 , so S ( 1 ) = I 2 S^{(1)} = I_2 S ( 1 ) = I 2 .
B ( 1 ) = A ( 1 ) , α ( 1 ) = 19 3 , ( r ( 1 ) ) T = ( − 8 3 ) , c ( 1 ) = ( 5 ) , C ( 1 ) = ( 5 ) B^{(1)} = A^{(1)}, \quad \alpha^{(1)} = \frac{19}{3}, \quad \left(r^{(1)}\right)^T = \left(-\frac{8}{3}\right), \quad c^{(1)} = (5), \quad C^{(1)} = (5) B ( 1 ) = A ( 1 ) , α ( 1 ) = 3 19 , ( r ( 1 ) ) T = ( − 3 8 ) , c ( 1 ) = ( 5 ) , C ( 1 ) = ( 5 ) ℓ ( 1 ) = 15 19 , A ( 2 ) = C ( 1 ) − ℓ ( 1 ) ( r ( 1 ) ) T = 135 19 \ell^{(1)} = \frac{15}{19}, \quad
A^{(2)} = C^{(1)} - \ell^{(1)}\left(r^{(1)}\right)^T = \frac{135}{19} ℓ ( 1 ) = 19 15 , A ( 2 ) = C ( 1 ) − ℓ ( 1 ) ( r ( 1 ) ) T = 19 135 At depth 2 2 2 , A ( 2 ) A^{(2)} A ( 2 ) is 1 × 1 1 \times 1 1 × 1 . Therefore P ( 2 ) = L ( 2 ) = ( 1 ) P^{(2)} = L^{(2)} = (1) P ( 2 ) = L ( 2 ) = ( 1 ) and U ( 2 ) = ( 135 / 19 ) U^{(2)} = (135/19) U ( 2 ) = ( 135/19 ) .
Returning from depth 1 1 1
P ( 1 ) = I 2 , L ( 1 ) = ( 1 0 15 / 19 1 ) , U ( 1 ) = ( 19 / 3 − 8 / 3 0 135 / 19 ) P^{(1)} = I_2, \quad L^{(1)} = \begin{pmatrix} 1 & 0 \\ 15/19 & 1 \end{pmatrix}, \quad U^{(1)} = \begin{pmatrix} 19/3 & -8/3 \\ 0 & 135/19 \end{pmatrix} P ( 1 ) = I 2 , L ( 1 ) = ( 1 15/19 0 1 ) , U ( 1 ) = ( 19/3 0 − 8/3 135/19 ) Returning from depth 0 0 0
P = P ( 0 ) = ( 0 0 1 0 1 0 1 0 0 ) , L = L ( 0 ) = ( 1 0 0 1 / 3 1 0 0 15 / 19 1 ) , U = U ( 0 ) = ( 6 8 8 0 19 / 3 − 8 / 3 0 0 135 / 19 ) P = P^{(0)} = \begin{pmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{pmatrix}, \quad
L = L^{(0)} = \begin{pmatrix} 1 & 0 & 0 \\ 1/3 & 1 & 0 \\ 0 & 15/19 & 1 \end{pmatrix}, \quad
U = U^{(0)} = \begin{pmatrix} 6 & 8 & 8 \\ 0 & 19/3 & -8/3 \\ 0 & 0 & 135/19 \end{pmatrix} P = P ( 0 ) = 0 0 1 0 1 0 1 0 0 , L = L ( 0 ) = 1 1/3 0 0 1 15/19 0 0 1 , U = U ( 0 ) = 6 0 0 8 19/3 0 8 − 8/3 135/19 Check, row 3 of L U LU LU
15 19 ( 0 , 19 3 , − 8 3 ) + ( 0 , 0 , 135 19 ) = ( 0 , 5 , 5 ) \tfrac{15}{19}\left(0, \tfrac{19}{3}, -\tfrac{8}{3}\right) + \left(0, 0, \tfrac{135}{19}\right) = (0, 5, 5) 19 15 ( 0 , 3 19 , − 3 8 ) + ( 0 , 0 , 19 135 ) = ( 0 , 5 , 5 )
Example 2
Using P P P , L L L , U U U from Example 1, solve A x ⃗ = b ⃗ A\vec{x} = \vec{b} A x = b for b ⃗ = ( 10 , 11 , 22 ) T \vec{b} = (10, 11, 22)^T b = ( 10 , 11 , 22 ) T .
Solution Reveal Hide P b ⃗ = ( 22 , 11 , 10 ) T P\vec{b} = (22, 11, 10)^T P b = ( 22 , 11 , 10 ) T Forward substitution, L y ⃗ = P b ⃗ L\vec{y} = P\vec{b} L y = P b
y 1 = 22 y_1 = 22 y 1 = 22 y 2 = 11 − 1 3 ( 22 ) = 11 3 y_2 = 11 - \frac{1}{3}(22) = \frac{11}{3} y 2 = 11 − 3 1 ( 22 ) = 3 11 y 3 = 10 − 15 19 ⋅ 11 3 = 135 19 y_3 = 10 - \frac{15}{19}\cdot\frac{11}{3} = \frac{135}{19} y 3 = 10 − 19 15 ⋅ 3 11 = 19 135 Back substitution, U x ⃗ = y ⃗ U\vec{x} = \vec{y} U x = y
x 3 = 135 / 19 135 / 19 = 1 x_3 = \frac{135/19}{135/19} = 1 x 3 = 135/19 135/19 = 1 x 2 = 11 / 3 + ( 8 / 3 ) ( 1 ) 19 / 3 = 1 x_2 = \frac{11/3 + (8/3)(1)}{19/3} = 1 x 2 = 19/3 11/3 + ( 8/3 ) ( 1 ) = 1 x 1 = 22 − 8 ( 1 ) − 8 ( 1 ) 6 = 1 x_1 = \frac{22 - 8(1) - 8(1)}{6} = 1 x 1 = 6 22 − 8 ( 1 ) − 8 ( 1 ) = 1 x ⃗ = ( 1 , 1 , 1 ) T \vec{x} = (1, 1, 1)^T x = ( 1 , 1 , 1 ) T