partial pivoting example on numerical analysis, Exercises of Mathematical Methods for Numerical Analysis and Optimization

partial pivoting example on numerical analysis

Typology: Exercises

2016/2017

Uploaded on 12/16/2017

bado-odab
bado-odab 🇪🇬

2 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Gaussian Elimination with Partial Pivoting Example
Apply Gaussian elimination with partial pivoting to A=
1 2 4 3
2 5 6 10
27 3 21
2 8 15 38
and solve Ax =b
for b=
0
9
28
42
.
Solution:
Apply Gaussian elimination with partial pivoting to Ausing the compact storage mode where the
multipliers (= elements of L) are stored in Ain the locations of Athat are to be made zero.The elements
of Lare 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 A2and L2. No row interchanges are required for A3, so we have skipped pivoting for A3.
λ A1
1|1 2 4 3
2|2 5 6 10
3| 27 3 21
4|2 8 5 38
λ P1A1
2|2 5 6 10
1|1 2 4 3
3| 27 3 21
4|2 8 5 38
λL2and A2
2|2 5 6 10
1|1/21/212
3|12311
4|13 1 28
λP2L2and P2A2
2|2 5 6 10
4|13 1 28
3|12311
1|1/21/212
λL3and A3
2|2 5 6 10
4|13 1 28
3|12/37/3 23/3
1|1/21/65/6 8/3
λL4and A4
2|2 5 6 10
4|13 1 28
3|12/37/3 23/3
1|1/21/6 5/14 1/14
So U=A4=
2 5 6 10
0 3 1 28
0 0 7/3 23/3
0 0 0 1/14
and L=L4=
1 0 0 0
1 1 0 0
12/3 1 0
1/21/6 5/14 1
.
P will have a one in columns 2, 4 , 3 and 1, in that order, (see λ) so P=
0100
0001
0010
1000
. The per-
mutation vector, p, describing the matrix P is p = [2 4 3 1]. P A =A(p, :) =
2 5 6 10
2 8 15 38
27 3 21
1 2 4 3
.
Here A(p, :) uses Matlab notation. LU =P A can be checked.
To solve Ax =bnote that P Ax =Pb =b
bor LUx =b
b. Therefore we can solve Ax =bin three steps:
(1) Let b
b=P b =
9
42
28
0
.
(2) Solve Lw =b
busing forward substitution. We get w=
9
33
3
1/14
.
(3) Solve Ux =wusing back substitution. We get x=
3
1
2
1
.
1

Partial preview of the text

Download partial pivoting example on numerical analysis and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Gaussian Elimination with Partial Pivoting Example

Apply Gaussian elimination with partial pivoting to A =

 and solve^ Ax^ =^ b

for b =

Solution:

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.

λ A 1 1 | 1 2 − 4 3 2 | 2 5 − 6 10 3 | − 2 − 7 3 − 21 4 | 2 8 − 5 38

λ P 1 A 1 2 | 2 5 − 6 10 1 | 1 2 − 4 3 3 | − 2 − 7 3 − 21 4 | 2 8 − 5 38

λ L 2 and A 2 2 | 2 5 − 6 10 1 | 1 / 2 − 1 / 2 − 1 − 2 3 | − 1 − 2 − 3 − 11 4 | 1 3 1 28

λ P 2 L 2 and P 2 A 2 2 | 2 5 − 6 10 4 | 1 3 1 28 3 | − 1 − 2 − 3 − 11 1 | 1 / 2 − 1 / 2 − 1 − 2

λ L 3 and A 3 2 | 2 5 − 6 10 4 | 1 3 1 28 3 | − 1 − 2 / 3 − 7 / 3 23 / 3 1 | 1 / 2 − 1 / 6 − 5 / 6 8 / 3

λ L 4 and A 4 2 | 2 5 − 6 10 4 | 1 3 1 28 3 | − 1 − 2 / 3 − 7 / 3 23 / 3 1 | 1 / 2 − 1 / 6 5 / 14 − 1 / 14

So U = A 4 =

 and^ L^ =^ L^4 =

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

. The per-

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

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

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

(1) Let ̂b = P b =

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

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