50 likes | 71 Views
Gaussian elimination with partial pivoting & row interchange with multipliers for PA=LU decomposition. 1 -1 2 -1 1 2 2 -1 1 1
E N D
Gaussian elimination with partial pivoting & row interchange with multipliers for PA=LU decomposition 1 -1 2 -1 1 2 2 -1 1 1 3 -1 1 -2 1 4 2 1 -2 2 2 2 -1 1 1 1 -1/2 3/2 -1/2 3/2 3 -1/2 1/2 -3/2 3/2 4 1 2 -3 1 We interchange rows with multipliers as needed in partial pivoting. At the end we have LU as giving A with the rows interchanged according to the index array p at the left. In MATLAB we have: A(p,:)=L*U where p=[2 4 1 3] . In matrix algebra we have PA=LU where P is a permutation matrix with P(i,j)=1 for j=p(i), and otherwise zero entries. 2 2 -1 1 1 4 1 2 -3 1 3 -1/2 1/4 -3/4 5/4 1 -1/2 3/4 7/4 3/4 2 2 -1 1 1 4 1 2 -3 1 1 -1/2 3/4 7/4 3/4 3 -1/2 1/4 -3/7 11/7
“Floating equations/floating rows” . For each column in turn, we pick the row with the largest absolute entry that has not already been used as a pivot row Largest entry in first column is in row 2 use that row to eliminate entries in other rows in first column, replacing those entries by the multiplier used, shown below in red. 1 2 3 4 [-1 1 -2 1] (3) [2 1 -2 2] (4) [2 -1 1 1] (2) [-1 2 -1 1] (1) Now in column 2 we pick the largest entry from rows 1,3,4 found in row 4 [ -1/2 1/2 -3/2 3/2] (3) 2 1 3 4 [2 -1 1 1] (2) [1 2 -3 1] (4) [-1/2 3/2 -1/2 3/2] (1)
Our row selections are recorded in order in the index vector p at the left. We are up to column 3; of the two rows left, 3 and 1, row 1 has the largest value in column 3. [ -1/21/4 -3/4 5/4] (3) 2 4 3 1 [12 -3 1] (4) [2 -1 1 1] (2) [-1/23/4 7/4 3/4] (1) We are done. If the original rows in A were placed in a matrix in the order shown in p, there would be no interchanges and we would have A(p,:)=L*U or PA=LU. [ -1/21/4 -3/711/7] (3) 2 4 1 3 [12 -3 1] (4) [2 -1 1 1] (2) [-1/23/47/4 3/4] (1)
The above argument shows how we can do LU decomposition with no row interchanges during elimination – just keep track of the index vector, and rearrange the rows only at the end. Now we use PA=LU to solve the system Ax=b. First PAx=LUx=Pb so our system is Lux=Pb. We don’t evaluate Pb by matrix multiplication, we just rearrange the entries of b to correspond to the ordering of the index vector p. In Matlab, it’s as simple as bb=b(p). Then we solve L(Ux)=bb by first solving Ly=bb and then Ux=y. In our example, suppose our system is -1 2 -1 1 2 -1 1 1 -1 1 -2 1 2 1 -2 2 5 -2 3 -1 x = 2 4 1 3 Rearranging on both sides via the final index vector: p= 2 -1 1 1 2 1 -2 2 -1 2 -1 1 -1 1 -2 1 -2 -1 5 3 x = Now solve Ly=bb
1 0 0 0 1 1 0 0 -1/2 3/4 1 0 -1/2 1/4 -3/7 1 -2 -1 5 3 y = There are two ways to consider solving this – first by elimination. Because the lower triangle contains the multipliers, you can easily see that your operations on the vector on the right (the only operations you need to perform) are precisely the same row operations used previously in Gaussian elimination, now applied to b! You can also solve by “front substitution”, i.e. y(1)=-2, y(2)=-1-y(1)=1, etc. Both methods involve the exact same calculations, only in a different order, and are exactly equivalent. We obtain: y=[-2 1 13/4 22/7]’ . Next we solve Ux=y This can be solved by backward elimination or by back substitution – the calculations are identical either way. We obtain the solution 2 -1 1 1 0 2 -3 1 0 0 7/4 3/4 0 0 0 11/7 -2 1 13/4 22/7 x = -2 1 1 2 x =