Gaussian Elimination with (Partial) Pivoting

advertisement
Gaussian Elimination with (Partial) Pivoting
At the kth stage of Gaussian elimination:
• Search the kth column on and below the diagonal for the
largest entry.
• Switch this row with the kth row.
1
Illustration
Suppose k − 1 steps of Gaussian elimination have been performed. Then:


a11 a12 · · ·
a1k
···
a1n


(k)
(1)
(1) 

a22 · · ·
a2k
···
a2n 



...
...
...





(k−1)
(k−1) 
Ak−1 = 

akk
· · · akn



(k−1)
(k−1) 
ak+1,k · · · ak+1,n 



...
...




a(k−1)
· · · a(k−1)
nn
nk
• Find p such that |apk | = max |aik |
k≤i≤n
• Interchange rows p and k (including multipliers).
• Now find multipliers
mk+1,k , mk+2,k , · · · mnk
to eliminate entries in the kth column.
2
What matrix factorization is computed by Gaussian elimination with partial
pivoting? In general, it is not A = LU .
We need ...
Permutation Matrix: Identity matrix with

1 0 0

 0 0 0

P =
 0 0 1

0 1 0
rows interchanged.

0

1 


0 

0
3
Properties of Permutation Matrices
Suppose P is a permutation matrix (obtained by interchanging
certain rows of the identity matrix). Then:
• The product P A interchanges (the same) rows of A.
• The product AP interchanges columns of A.
• det(P ) = ±det(I) = ±1.
• An elementary permutation only interchanges two rows.
(the determinant is -1)
4
Recall that elimination can be written as a matrix multiplication.
Therefore, using permutation and elimination matrices, Gaussian
elimination with partial pivoting can be written as:
Mn−1Pn−1 · · · M2P2M1P1A = U
Or, we could write this as:
A = (Mn−1Pn−1 · · · M2P2M1P1)−1U
5
Define the matrices:
P = Pn−1Pn−2 · · · P2P1
L = P (Mn−1Pn−1 · · · M2P2M1P1)−1
Then L is unit lower triangular (show this!), and
Mn−1Pn−1 · · · M2P2M1P1A = U
⇒
A = (Mn−1Pn−1 · · · M2P2M1P1)−1U
⇒ P A = P (Mn−1Pn−1 · · · M2P2M1P1)−1U
That is, Gaussian elimination with partial pivoting computes
the matrix factorization:
P A = LU
6
Solving Ax = b with P A = LU
Ax = b
⇒ P Ax = P b
⇒ LU x = P b
1. Compute LU , and keep track of permutations.
2. Interchange entries of b to get entries of b̂ = P b.
3. Solve Ly = b̂ by forward substitution.
4. Solve U x = y by backward substitution.
7
Matlab Comments
Suppose A is an n × n matrix.
• [L,U,P] = lu(A) computes the factors for P A = LU .
Use help lu to get more information.
• If we only need to solve one linear system, then the backslash operator
can be used to solve it without explicitly calling the lu function. That is,
x = A \ b;
will use Gaussian elimination with partial pivoting to solve Ax = b.
See help slash to get more information.
8
Download