03.03.2014 Views

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.2. PIVOTING STRATEGIES FOR GAUSSIAN ELIMINATION 29<br />

is maximized. The algorithm pivots on row l k , producing a bunch of zeros in the k th column.<br />

The slick way to implement this is to first set l i = i for i = 1, 2, . . . , n. Then rearrange this<br />

vector in a kind of “bubble sort”: when you find the index that should be l 1 , swap them, i.e., find<br />

the j such that l j should be the first pivot and switch the values of l 1 , l j .<br />

Then at the k th step, search only those indices in the tail of this vector: i.e., only among l j for<br />

k ≤ j ≤ n, and perform a swap.<br />

3.2.2 An Example<br />

We present an example of using scaled partial pivoting with G.E. It’s hard to come up with an<br />

example where the numbers do not come out as ugly fractions. We’ll look at a homework question.<br />

⎛<br />

⎜<br />

⎝<br />

2 −1 3 7 15<br />

4 4 0 7 11<br />

2 1 1 3 7<br />

6 5 4 17 31<br />

The scales are as follows: s 1 = 7, s 2 = 7, s 3 = 3, s 4 = 17.<br />

We pick l 1 . It should be the index which maximizes |a i1 | /s i . These values are:<br />

2<br />

7 , 4 7 , 2 3 , 6 17 .<br />

⎞<br />

⎟<br />

⎠<br />

We pick l 1 = 3, and pivot:<br />

⎛<br />

⎜<br />

⎝<br />

0 −2 2 4 8<br />

0 2 −2 1 −3<br />

2 1 1 3 7<br />

0 2 1 8 10<br />

⎞<br />

⎟<br />

⎠<br />

We pick l 2 . It should not be 3, and should be the index which maximizes |a i2 | /s i . These values<br />

are:<br />

2<br />

7 , 2 7 , 2 17 .<br />

We have a tie. In this case we pick the second row, i.e., l 2 = 2. We pivot:<br />

⎛<br />

⎜<br />

⎝<br />

0 0 0 5 5<br />

0 2 −2 1 −3<br />

2 1 1 3 7<br />

0 0 3 7 13<br />

The matrix is in permuted upper triangular form. We could proceed, but would get a zero<br />

multiplier, and no changes would occur.<br />

If we did proceed we would have l 3 = 4. Then l 4 = 1. Our row permutation is 3, 2, 4, 1. When<br />

we do back substitution, we work in this order reversed on the rows, solving x 4 , then x 3 , x 2 , x 1 .<br />

We get x 4 = 1, so<br />

x 3 = 1 (13 − 7 ∗ 1) = 2<br />

3<br />

⎞<br />

⎟<br />

⎠<br />

x 2 = 1 (−3 − 1 ∗ 1 + 2 ∗ 2) = 0<br />

2<br />

x 1 = 1 (7 − 3 ∗ 1 − 1 ∗ 2 − 1 ∗ 0) = 1<br />

2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!