Two measurements lead to the equations and . Elimination subtracts twice the first equation from the second, which leaves and then . When new measurements arrive, say and , only the right side is new, so every elimination step on the coefficients stays the same. This lesson stores the elimination in two triangular matrices so that each new right side costs only two quick substitutions, and it shows how to keep track of row swaps along the way. Tuples such as stand for column vectors.
Key terms
Lower and upper triangular matrices
Definition A square matrix is lower triangular if whenever , so every entry above the main diagonal is zero. It is unit lower triangular if, in addition, every diagonal entry equals . A square matrix is upper triangular if whenever , so every entry below the main diagonal is zero. A triangular matrix is invertible exactly when all of its diagonal entries are nonzero. A product of lower triangular matrices of the same size is lower triangular, and the same holds for upper triangular and for unit lower triangular matrices.
In plain words A triangular matrix keeps all of its nonzero entries on the diagonal or on one side of it. A system whose coefficient matrix is triangular with nonzero diagonal entries can be solved one unknown at a time.
Example The matrices
are unit lower triangular and upper triangular. Every echelon form of a square matrix is upper triangular, because the leading entry of row lies in column or further right.
LU factorization
Definition Let be an matrix, and suppose Gaussian elimination reduces to an upper triangular matrix without swapping rows. It works through the columns from left to right, and in column it applies to each row . The numbers are the elimination multipliers. Each one is the entry being cleared divided by the pivot in position , so every pivot used as a divisor must be nonzero. Then
where is the unit lower triangular matrix whose entry in position below the diagonal is . This is an LU factorization of . The reason is that elimination multiplies on the left by elementary matrices, giving , and adds back every row multiple that elimination subtracted. That is why the multipliers enter with a plus sign.
In plain words Elimination subtracts multiples of higher rows from lower rows. The matrix remembers those multiples, and multiplying by adds them back, which rebuilds from .
Example For
the multiplier is , and leaves the matrix from the previous example. Then
The second row of is twice the first row of plus the second row of ,
Storing instead, copied from the sign of the row operation, would give the second row , which does not rebuild .
Forward substitution
Definition Let be an lower triangular matrix with nonzero diagonal entries. Forward substitution solves from the top down, computing for in turn
Each row finds one new unknown from the ones above it, and for a unit lower triangular there is no division at all. Back-substitution solves for an upper triangular with nonzero diagonal entries in the same way from the bottom up. If , the system reads , so it is solved in two triangular steps,
The back-substitution needs every diagonal entry of to be nonzero, which holds exactly when is invertible.
In plain words Forward substitution replays the stored elimination on a new right side. Back-substitution then solves the triangular system from the bottom. The vector in the middle is the right side after elimination, not the answer.
Example With and from above and , forward substitution gives and , so . Back-substitution in , gives and . For the new data the same factors give and , so . Then and , so . The original equations check, since and .
Permutation matrix
Definition An permutation matrix is a matrix obtained by reordering the rows of . Each of its rows and each of its columns contains exactly one entry , and all other entries are . If row of is row of , then row of is row of . So multiplying on the left by reorders the rows of , and reorders the entries of in the same way. Every permutation matrix is invertible, with .
In plain words A permutation matrix is the identity with its rows shuffled. Multiplying by it shuffles the rows of whatever comes next in the same way.
Example The matrix
consists of rows 3, 1 and 2 of . So lists the rows of in the order 3, 1, 2, and . Its transpose puts everything back, since .
Pivoted LU factorization
Definition A pivoted LU factorization of an matrix is
where is an permutation matrix, is unit lower triangular and is upper triangular. Every square matrix has one, produced by elimination with row swaps, and records the final order of the rows. Since is invertible, is equivalent to , that is, to . When is invertible, so is , and its diagonal entries are nonzero. Then solve by forward substitution and by back-substitution. The permutation reorders the equations, never the unknowns, so needs no reordering at the end.
In plain words When a pivot position holds a zero, swap in a lower row with a nonzero entry there, if there is one. Factor the reordered matrix, and reorder the right side in the same way before solving.
Example The matrix
has a zero in its first pivot position, yet it is invertible. Swapping its rows with the permutation matrix that has rows and gives
which is already upper triangular, so and . For the permuted right side is . The second row gives , so , and the first gives , so . In the original order the equations are and , and both hold.
Partial pivoting
Definition Partial pivoting is a rule for choosing row swaps during elimination. At step , look at the entries in column in rows through of the current matrix, choose one of largest absolute value, and swap its row with row . If all of these entries are zero, position of stays zero, so is singular, and elimination moves on to the next column. Each swap exchanges three things, the two whole rows of the current matrix, the multipliers already stored in columns through of for those two rows, and the two positions in the record of row order that builds . Every multiplier then has absolute value at most . In floating point arithmetic this tends to limit the growth of rounding errors, though it cannot remove the sensitivity of a badly conditioned system.
In plain words Before clearing a column, bring up the row whose entry there is largest in absolute value. When rows move, the multipliers already written in move with them, because each multiplier belongs to its row.
Example Factor
In column 1 the candidates are , and , so swap rows 1 and 3, and the row order becomes 3, 2, 1. The multipliers are and , and gives
In column 2 the candidates are and , so swap rows 2 and 3, and the row order becomes 3, 1, 2. The stored multipliers in column 1 of swap as well, so now and . The new multiplier is , and finishes the elimination. The factors are
The first two rows of are the first two rows of , which are rows 3 and 1 of . The third row of is
which is row 2 of , so . Had the multiplier stayed in row 2 of , this check would fail. For we get , forward substitution gives , and back-substitution gives . In the original order, .
Check yourself
- Find the LU factorization of the matrix below and use it to solve .
Show the answer
The multiplier is , and leaves the upper triangular matrix, so
Forward substitution gives and , so . Back-substitution gives , so , and , so . The original equations check, since and .
- Show that the matrix below has no LU factorization without row swaps, even though it is invertible. Then find and solve .
Show the answer
Suppose with unit lower triangular and upper triangular. The top left entries give , and the bottom left entries give , which is impossible. Swapping the rows gives
which is upper triangular, so and . It has two pivots, so is invertible. The right side becomes . Back-substitution gives and , so . In the original order, and .
- Use partial pivoting to factor the matrix below as , then solve . What goes wrong if you forget to permute the right side?
Show the answer
In column 1 the candidates are and , so swap the rows. The multiplier is , and turns the second row into . So
The right side becomes . Forward substitution gives and . Back-substitution gives , so , and , so . The original equations check, since and .
Forgetting the permutation means solving , which gives . That vector solves , so it satisfies , the system with its two right sides exchanged.