Sunteți pe pagina 1din 1

Gaussian Elimination with Partial Pivoting Example

Apply Gaussian elimination with partial pivoting to A =

for b =

0

9

28

42

Solution:

.

1

2

2

2

2

5

7

8

4

6

3

15

3

10

21

38

and solve Ax = b

Apply Gaussian elimination with partial pivoting to A using the compact storage mode where the multipliers (= elements of L) are stored in A in the locations of A that are to be made zero.The elements

of

L are in red. Note that when one interchanges rows of the current A, one must also interchange rows

of

the current L. For example, in the step at the third arrow, below, we switch the second and fourth

rows of A 2 and L 2 . No row interchanges are required for A 3 , so we have skipped pivoting for A 3 .

λ

1

2

3

4

|

|

|

|

1

2

2

2

A 1

2

5

7

8

4

6

3

5

3

10

21

38

λ

2

1

3

4

|

|

|

|

2

1

2

2

P 1

5

2

7

8

A 1

6

4

3

5

10

3

21

38

λ

2

1

3

4

|

|

|

|

L 2

2

1/2

1

1

and

5

1/2

2

3

λ

2

4

3

1

|

|

|

|

P 2 L 2

2

1

1

1/2

and

5

3

2

1/2

P 2

6

1

3

1

A 2

10

28

11

2

λ

2

4

3

1

|

|

|

|

L 3

2

1

1

1/2

and

5

3

2/3

1/6

A 3

6

1

7/3

5/6

10

28

23/3

8/3

λ

2

4

3

1

|

|

|

|

L 4

2

1

1

1/2

So U = A 4 =

2

0

0

0

5

3

0

0

6

1

7/3

0

10

28

23/3

1/14

and L = L 4 =

1

1

1

1/2

0

1

2/3

1/6

0

0

1

5/14

0

0

0

1

P will have a one in columns 2, 4 , 3 and 1, in that order, (see λ ) so P =

mutation vector, p, describing the matrix P is p = [2 4 3 1]. P A = A(p, :) =

0

0

0

1

1

0

0

0

2

2

2

1

A 2

6

1

3

1

10

2

11

28

and

5

3

2/3

1/6

A 4

6

10

1

28

7/3

23/3

5/14

1/14

.

0

0

1

0

5

8

7

2

0

1

0

0

. The per-

6

15

3

4

10

38

21

3

.

Here A(p, :) uses Matlab notation. LU = P A can be checked.

To solve Ax = b note that P Ax = P b = b or LUx = b. Therefore we can solve Ax = b in three steps:

(1) Let b = Pb =

9

42

28

0

.

(2) Solve Lw = b using forward substitution. We get w =

(3) Solve Ux = w using back substitution. We get x =

3

1

2

1

9

33

3

1/14

.

.