30
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 17 Solution of Systems of Equations

ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 17 Solution of Systems of Equations

  • View
    218

  • Download
    1

Embed Size (px)

Citation preview

ECIV 301

Programming & Graphics

Numerical Methods for Engineers

Lecture 17

Solution of Systems of Equations

Last Time Linear Equations in Matrix Form

10z8y3x5

6z3yx12

24z23y6x10

23610

3112

835

z

y

x

24

6

10 10

z

y

x

835

6

z

y

x

3112

24

z

y

x

23610

# Equations = # Unknowns = n

Square Matrix n x n

Last Time Solution of Linear Equations

10

7

9

500

310

835

z

y

x

Express In Matrix Form

Upper Triangular

What is the characteristic?

Solution by Back Substitution

Last Time Solution of Linear Equations

Objective

Can we express any system of equations in a form

nnnn

n

n

n

b

b

b

b

x

x

x

x

a

aa

aaa

aaaa

3

2

1

3

2

1

333

22322

1131211

000

00

0

0

Last Time Background

Consider

1035 yx(Eq 1)

5810 yx(Eq 2)

Solution

5.7

5.6

y

x

20610 yx2*(Eq 1)

5810 yx(Eq 2)

Solution

5.7

5.6

y

x!!!!!!

Scaling Does Not Change the SolutionScaling Does Not Change the Solution

Last Time Background

Consider

20610 yx(Eq 1)

152 y(Eq 2)-(Eq 1)

Solution

5.7

5.6

y

x!!!!!!

20610 yx(Eq 1)

5810 yx(Eq 2)

Solution

5.7

5.6

y

x

Operations Do Not Change the SolutionOperations Do Not Change the Solution

Last Time Gauss Elimination

10835 zyx

2423610 zyx

6312 zyx

Example

Forward Elimination

Last Time Gauss Elimination

Forward Elimination

064.62

30

10

645.700

2.162.60

835

z

y

x

Last TimeGauss Elimination

Back Substitution

118.8645.7/064.62 z

0502.26

2.6

118.82.1630

y

6413.0

5

118.880502.26310

x

064.62

30

10

645.700

2.162.60

835

z

y

x

Last Time GE – Potential Problem

10830 zyx

2423610 zyx

6312 zyx

Forward Elimination

Gauss Elimination – Potential Problem

10830 zyx

2423610 zyx

6312 zyx

0

12 Division By Zero!!Operation Failed

Gauss Elimination – Potential Problem

10830 zyx

2423610 zyx

6312 zyx

12

0OK!!

Gauss Elimination – Potential Problem

10830 zyx

2423610 zyx

6312 zyx

Pivoting

6312 zyx

10830 zyx

Partial Pivoting

nn

nnnnn

lll

n

n

n

b

b

b

b

x

x

x

x

aaaa

aaaa

aaaaaaaa

aaaa

3

2

1

3

2

1

321

ln321

3333231

2232221

1131211

a32>a22

al2>a22

NO

YES

Partial Pivoting

nn

nnnnn

n

n

lll

n

b

b

b

b

x

x

x

x

aaaa

aaaa

aaaaaaaa

aaaa

3

2

1

3

2

1

321

2232221

3333231

ln321

1131211

Full Pivoting

• In addition to row swaping

• Search columns for max elements

• Swap Columns

• Change the order of xi

• Most cases not necessary

EXAMPLE

4.71

3.19

85.7

102.03.0

3.071.0

2.01.03

3

2

1

x

x

x

Eliminate Column 1

3

1.0

PIVOTS

4.71

3.19

85.7

102.03.0

3.071.0

2.01.03

3

3.0

Eliminate Column 1

6150.70

5617.19

85.7

0200.1019000.00

29333.000333.70

2.01.03

Eliminate Column 2

00333.7

19000.0

PIVOTS

6150.70

5617.19

85.7

0200.1019000.00

29333.000333.70

2.01.03

Eliminate Column 2

0843.70

5617.19

85.7

01200.1000

29333.000333.70

2.01.03

LU DecompositionPIVOTS

Column 1PIVOTS

Column 2

03333.0

1.0 02713.0

LU Decomposition

As many as, and in the location of, zeros

UpperTriangular

MatrixU

01200.1000

29333.000333.70

2.01.03

LU DecompositionPIVOTS

Column 1

PIVOTSColumn 2

LowerTriangular

Matrix

1

1

1

0

0

0

L

03333.0

1.0 02713.0

LU Decomposition

102713.01.0

0103333.0

001

=

This is the original matrix!!!!!!!!!!

01200.1000

29333.000333.70

2.01.03

102.03.0

3.071.0

2.01.03

LU Decomposition

4.71

3.19

85.7

102713.01.0

0103333.0

001

3

2

1

y

y

y

4.71

3.19

85.7

102.03.0

3.071.0

2.01.03

3

2

1

x

x

x

L y b

LU Decomposition

4.71

3.19

85.7

102713.01.0

0103333.0

001

3

2

1

y

y

y

L y b

85.71 y

5617.190333.03.19 12 yy

0843.70)02713.0(1.04.71 213 yyy

LU Decomposition85.71 y

5617.190333.03.19 12 yy

0843.70)02713.0(1.04.71 213 yyy

0843.70

5617.19

85.7

01200.1000

29333.000333.70

2.01.03

LU Decomposition

• Ax=b

• A=LU - LU Decomposition

• Ly=b- Solve for y

• Ux=y - Solve for x