ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 15 Solution of Systems of...

Post on 21-Dec-2015

224 views 0 download

Tags:

transcript

ECIV 301

Programming & Graphics

Numerical Methods for Engineers

Lecture 15

Solution of Systems of Equations

Objectives

• Introduction to Matrix Algebra

• Express System of Equations in Matrix Form

• Introduce Methods for Solving Systems of Equations

• Advantages and Disadvantages of each Method

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-Correction Gauss Elimination

10835 zyx

24z23y6x10

zyx 835

5

1210

5

12

6312 zyx

-

305

81

5

310 zyx 302.162.60 zyx

Last Time-Correction Gauss Elimination

10835 zyx

24z23y6x10

6312 zyx 302.162.60 zyx

Substitute 2nd eq with new

Last Time-Correction Gauss Elimination

10835 zyx

24z23y6x10

302.162.60 zyx

zyx 835

5

1010

5

10-

439120 zyx

Last Time-Correction Gauss Elimination

10835 zyx

24z23y6x10

302.162.60 zyx

Substitute 3rd eq with new

439120 zyx

Last Time-Correction Gauss Elimination

10835 zyx

302.162.60 zyx

439120 zyx

zy 2.162.6

2.6

12 30

2.6

12-

064.62645.700 zyx

Last Time-Correction Gauss Elimination

10835 zyx

30970 zyx

Substitute 3rd eq with new

439120 zyx 064.62645.700 zyx

Last Time-Correction Gauss Elimination

064.62

30

10

645.700

2.162.60

835

z

y

x

Last Time Gauss Elimination

Forward Elimination

064.62

30

10

645.700

2.162.60

835

z

y

x

Last Time-Correction Gauss 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

Gauss Elimination – 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

We will work directly on the coefficient matrix