matrix methods systems of linear equations student notes

117
MATRIX METHODS SYSTEMS OF LINEAR EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier

Upload: duscha

Post on 24-Feb-2016

36 views

Category:

Documents


1 download

DESCRIPTION

MATRIX METHODS SYSTEMS OF LINEAR EQUATIONS Student Notes. ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier. Specific Study Objectives. Review basic definitions Review basic matrix operations - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

MATRIX METHODSSYSTEMS OF LINEAR EQUATIONSStudent NotesENGR 351 Numerical Methods for EngineersSouthern Illinois University CarbondaleCollege of EngineeringDr. L.R. ChevalierDr. B.A. DeVantier

Page 2: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes
Page 3: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• Review basic definitions • Review basic matrix operations

• Addition/subtraction• Multiplication• Determinant

• Understand the graphic interpretation of ill-conditioned systems and how it relates to the determinant

• Be familiar with terminology: forward elimination, back substitution, pivot equations and pivot coefficient

Specific Study Objectives

Page 4: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• Apply matrix inversion • Understand that the Gauss-Seidel method is

particularly well-suited for large sparse systems of equations

• Know how to assess diagonal dominance of a system of equations and how it relates to whether the system can be solved with the Gauss-Seidel method

• Understand the rationale behind relaxation and how to apply this technique

Specific Study Objectives

Page 5: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

How to represent a system of linear equations as a matrix

[A]{x} = {c}

where {x} and {c} are both column vectors

Page 6: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

44.067.001.0

5.03.01.09.115.0

152.03.0

}{}{

44.05.03.01.067.09.15.0

01.052.03.0

3

2

1

321

321

321

xxx

cxA

xxxxxx

xxx

How to represent a system of linear equations as a matrix

Page 7: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Practical application• Consider a problem in structural

engineering• Find the forces and reactions associated

with a statically determinant truss

hinge: transmits bothvertical and horizontalforces at the surface

roller: transmitsvertical forces

30

90

60

Page 8: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

1000 kg

30

90

60

F1

H2

V2 V3

2

3

1

FREE BODY DIAGRAM F

FH

v

0

0

F2

F3

Page 9: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Node 1 F1,V

F1,H

F3F1

6030

F F F F

F F F F

F F

F F

H H

V V

0 30 60

0 30 60

30 60 0

30 60 1000

1 3 1

1 3 1

1 3

1 3

cos cos

sin sin

cos cos

sin sin

,

,

Page 10: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

F H F F

F V FH

V

0 30

0 302 2 1

2 1

cos

sin

Node 2

F2

F1

30

H2V2

Page 11: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

F F F

F F VH

V

0 60

0 603 2

3 3

cos

sin

Node 3

F2

F3

60

V3

Page 12: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

060sin

060cos

030sin

030cos

100060sin30sin

060cos30cos

33

23

12

122

31

31

VF

FF

FV

FFH

FF

FF

SIX EQUATIONSSIX UNKNOWNS

Page 13: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

F1 F2 F3 H2 V2 V3

1

2

3

4

5

6

-cos30 0 cos60 0 0 0

-sin30 0 -sin60 0 0 0 cos30 1 0 1 0 0

sin30 0 0 0 1 0

0 -1 -cos60 0 0 0

0 0 sin60 0 0 1

0

-1000

0

0

0

0

Do some book keeping

Page 14: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

This is the basis for your matrices and the equation[A]{x}={c}

0 866 0 0 5 0 0 00 5 0 0 866 0 0 0

0 866 1 0 1 0 00 5 0 0 0 1 00 1 0 5 0 0 00 0 0 866 0 0 1

010000000

1

2

3

2

2

3

. .. .

..

..

FFFHVV

Page 15: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

System of Linear Equations• We have focused our last lectures

on finding a value of x that satisfied a single equation• f(x) = 0

• Now we will deal with the case of determining the values of x1, x2, .....xn, that simultaneously satisfy a set of equations

Page 16: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

System of Linear Equations• Simultaneous equations

• f1(x1, x2, .....xn) = 0• f2(x1, x2, .....xn) = 0 • .............• fn(x1, x2, .....xn) = 0

• Methods will be for linear equations• a11x1 + a12x2 +...... a1nxn =c1

• a21x1 + a22x2 +...... a2nxn =c2

• ..........

• an1x1 + an2x2 +...... annxn =cn

Page 17: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Mathematical BackgroundMatrix Notation

• a horizontal set of elements is called a row

• a vertical set is called a column• first subscript refers to the row number• second subscript refers to column

number

A

a a a aa a a a

a a a a

n

n

m m m mn

11 12 13 1

21 22 23 2

1 2 3

...

.... . . .

...

Page 18: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

mnmmm

n

n

aaaa

aaaaaaaa

A

.......

...

...

321

2232221

1131211

This matrix has m rows and n column.

It has the dimensions m by n (m x n)

notesubscript

Page 19: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

A

a a a aa a a a

a a a a

n

n

m m m mn

11 12 13 1

21 22 23 2

1 2 3

...

.... . . .

...

row 2

column 3Note the consistentscheme with subscriptsdenoting row,column

Page 20: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Row vector: m=1

Column vector: n=1 Square matrix: m = n

B b b bn 1 2 .......

C

cc

cm

1

2

.

.

Aa a aa a aa a a

11 12 13

21 22 23

31 32 33

Types of Matrices

Page 21: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• Symmetric matrix• Diagonal matrix• Identity matrix• Inverse of a matrix• Transpose of a matrix• Upper triangular matrix• Lower triangular matrix• Banded matrix

Definitions

Page 22: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Symmetric Matrix

aij = aji for all i’s and j’s

A

5 1 21 3 72 7 8

Does a23 = a32 ?

Yes. Check the other elementson your own.

Page 23: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Diagonal Matrix

A square matrix where all elements off the main diagonal are zero

A

aa

aa

11

22

33

44

0 0 00 0 00 0 00 0 0

Page 24: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Identity Matrix

A diagonal matrix where all elements on the main diagonal are equal to 1

A

1 0 0 00 1 0 00 0 1 00 0 0 1

The symbol [I] is used to denote the identify matrix.

Page 25: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Inverse of [A]

IAAAA 11

Page 26: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Transpose of [A]

A

a a aa a a

a a a

t

m

m

n n mn

11 21 1

12 22 2

1 2

. . .

. . .. . . . . .. . . . . .. . . . . .

. . .

Page 27: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Upper Triangle Matrix

Elements below the main diagonal are zero

Aa a a

a aa

11 12 13

22 23

33

00 0

Page 28: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Lower Triangular Matrix

All elements above the main diagonal are zero

A

5 0 01 3 02 7 8

Page 29: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Banded Matrix

All elements are zero with the exception of a band centered on the main diagonal

A

a aa a a

a a aa a

11 12

21 22 23

32 33 34

43 44

0 00

00 0

Page 30: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix Operating Rules

• Addition/subtraction• add/subtract corresponding terms• aij + bij = cij

• Addition/subtraction are commutative• [A] + [B] = [B] + [A]

• Addition/subtraction are associative• [A] + ([B]+[C]) = ([A] +[B]) + [C]

Page 31: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix Operating Rules• Multiplication of a matrix [A] by a

scalar g is obtained by multiplying every element of [A] by g

B g A

ga ga gaga ga ga

ga ga ga

n

n

m m mn

11 12 1

21 22 2

1 2

. . .

. . .. . . . . .. . . . . .. . . . . .

. . .

Page 32: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix Operating Rules• The product of two matrices is

represented as [C] = [A][B]• Basic algorithm

c a bij ik kjk

N

1

Page 33: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

[A] m x n [B] n x k = [C] m x k

interior dimensionsmust be equal

exterior dimensions conform to dimension of resulting matrix

Simple way to check whether matrix multiplication is possible

Page 34: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Recall the equation presented for matrix multiplication• The product of two matrices is

represented as [C] = [A][B]

• n = column dimensions of [A]• n = row dimensions of [B]

c a bij ik kjk

N

1

Page 35: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

ExampleDetermine [C] given [A][B] = [C]

203123

142

320241231

B

A

Strategy

Page 36: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy• A 3x3 times a 3x3 is a 3x3• For c11=(-1)(-2)+(3)(3)+(2)(3)

203123

142

320241231

BA

Page 37: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy• c12

• c13

203123

142

320241231

BA

Page 38: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix multiplication• If the dimensions are suitable,

matrix multiplication is associative• ([A][B])[C] = [A]([B][C])

• If the dimensions are suitable, matrix multiplication is distributive• ([A] + [B])[C] = [A][C] + [B][C]

• Multiplication is generally not commutative• [A][B] is not equal to [B][A]

Page 39: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Determinants

Denoted as det A or lAl

for a 2 x 2 matrix

bcaddcba

bcaddcba

Page 40: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Determinants

254329132

For a 3 x 3

254329132

254329132

+ - +

Page 41: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

516234971

A

Problem

Determine the determinant of the matrix.

Strategy

Page 42: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy

516234971

516234971

A

516234971

516234971

Page 43: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Properties of Determinants

• det A = det AT

• If all entries of any row or column is zero, then det A = 0

• If two rows or two columns are identical, then det A = 0

• Note: determinants can be calculated using mdeterm function in Excel

Page 44: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix Methods• Graphical• Cramer’s Rule• Gauss elimination• Matrix inversion • Gauss Seidel/Jacobi

Page 45: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Graphical Method2 equations, 2 unknowns

a x a x ca x a x c

xaa

xca

xaa

xca

11 1 12 2 1

21 1 22 2 2

211

121

1

12

221

221

2

22

x2

x1

( x1, x2 )

Page 46: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

3 2 182 2

32

9

12

1

1 2

1 2

2 1

2 1

x xx x

x x

x x

x2

x1

( 4 , 3 )

3

2

2

1

9

1

Check: 3(4) + 2(3) = 12 + 6 = 18

Page 47: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

When does this not work?• No solution• Infinite solution• Ill-conditioned

x2

x1

( x1, x2 )

Page 48: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

a) No solution - same slope f(x)

xb) infinite solution f(x)

x

-1/2 x1 + x2 = 1-x1 +2x2 = 2

c) ill conditionedso close that the points ofintersection are difficult todetect visually

f(x)

x

Page 49: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Ill Conditioned: What do I mean?• The equations are not independent• The equations are not unique• The solution isn’t worth 2¢

Page 50: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• If the determinant is zero, the slopes are identical

a x a x ca x a x c

11 1 12 2 1

21 1 22 2 2

Rearrange these equations so that we have an alternative version in the form of a straight line:

i.e. x2 = (slope) x1 + intercept

The Determinant as a Tool

Page 51: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

x aa

x ca

x aa

x ca

211

121

1

12

221

221

2

22

If the slopes are nearly equal (ill-conditioned)

aa

aa

a a a aa a a a

11

12

21

22

11 22 21 12

11 22 21 12 0

a aa a

A11 12

21 22

det

Isn’t this the determinant?

The Determinant as a Tool

Page 52: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

If the determinant is zero the slopes are equal.This can mean:

- no solution- infinite number of solutions

If the determinant is close to zero, the system is illconditioned.

So it seems that we should use check the determinant of a system before any further calculations are done.

Let’s try an example.

The Determinant as a Tool

Page 53: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

ExampleDetermine whether the following matrix is ill-conditioned.

12

225.22.197.42.37

2

1

xx

Strategy Take the determinant or graph the equations

Page 54: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Another Check• Scale the matrix of coefficients, [A], so that the

largest element in each row is 1. If there are elements of [A]-1 that are several orders of magnitude greater than one, it is likely that the system is ill-conditioned.

• Multiply the inverse by the original coefficient matrix. If the results are not close to the identity matrix, the system is ill-conditioned.

• Invert the inverted matrix. If it is not close to the original coefficient matrix, the system is ill-conditioned.

We will consider how to obtain an inverted matrix later.

Page 55: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Cramer’s Rule• Not efficient for solving large

numbers of linear equations• Useful for explaining some

inherent problems associated with solving linear equations.

bxAbbb

xxx

aaaaaaaaa

3

2

1

3

2

1

333231

232221

131211

Page 56: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Cramer’s Rule

xA

b a ab a ab a a

1

1 12 13

2 22 23

3 32 33

1

to solve forxi - place {b} inthe ith column

Page 57: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Cramer’s Rule

to solve forxi - place {b} inthe ith column

33231

22221

11211

3

33331

23221

13111

2

33323

23222

13121

1

1

11

baabaabaa

Ax

abaabaaba

Ax

aabaabaab

Ax

Page 58: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

EXAMPLE

2 3 55

2 31 1

55

1 2

1 2

1

2

x xx x

xx

Strategy

Use Cramer’s rule to solve

Page 59: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy• Put in matrix form Ax=b• Calculate |A|

33231

22221

11211

3

33331

23221

13111

2

33323

23222

13121

1

1

11

baabaabaa

Ax

abaabaaba

Ax

aabaabaab

Ax

Page 60: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Elimination of Unknowns( algebraic approach)

2112221111121

1212122111121

112222121

211212111

2222121

1212111

caxaaxaaSUBTRACTcaxaaxaa

acxaxaacxaxa

cxaxacxaxa

Page 61: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

21122211

2121221

11222112

2111212

1122112112222111

2112221111121

1212122111121

aaaacacax

aaaacacax

acacxaaxaa

caxaaxaaSUBTRACTcaxaaxaa

NOTE: same result asCramer’s Rule

Elimination of Unknowns( algebraic approach)

Page 62: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss Elimination• One of the earliest methods

developed for solving simultaneous equations

• Important algorithm in use today• Involves combining equations in

order to eliminate unknowns and create an upper triangular matrix

• Progressively back substitute to find each unknown

Page 63: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Two Phases of Gauss Elimination

a a a ca a a ca a a c

a a a ca a c

a c

11 12 13 1

21 22 23 2

31 32 33 3

11 12 13 1

22 23 2

33 3

00 0

|||

|||

' ' '

' ' ' '

ForwardElimination

Note: the prime indicatesthe number of times the element has changed from the original value.

Page 64: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Two Phases of Gauss Elimination

11

31321211

'22

3123

'2

2

''33

''3

3

''3

''33

'2

'23

'22

1131211

|00|0|

axaxacx

axacx

acx

cacaacaaa

Back substitution

Page 65: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Rules• Any equation can be multiplied (or

divided) by a nonzero scalar• Any equation can be added to (or

subtracted from) another equation• The positions of any two equations

in the set can be interchanged.

Page 66: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Example

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

Perform Gauss Elimination of the following matrix.

Work with class

Page 67: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Solution2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

Multiply the first equation by a21/ a11 = 4/2 = 2

Note: a11 is called the pivot element

2624 321 xxx

Page 68: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

2624 321 xxx

a21 / a11 = 4/2 = 2

Page 69: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

3952

17442624

321

321

321

xxxxxxxxx

a21 / a11 = 4/2 = 2

Page 70: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Subtract the revised first equation from the second equation

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

a21 / a11 = 4/2 = 2

395217442624

321

321

321

xxxxxxxxx

Page 71: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

4 4 4 2 7 6 1 20 2 1

1 2 3

1 2 3

x x xx x x

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

a21 / a11 = 4/2 = 2

Subtract the revised first equation from the second equation

395217442624

321

321

321

xxxxxxxxx

Page 72: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

4 4 4 2 7 6 1 20 2 1

1 2 3

1 2 3

x x xx x x

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

a21 / a11 = 4/2 = 2

Subtract the revised first equation from the second equation

395217442624

321

321

321

xxxxxxxxx

3952120

132

321

321

321

xxxxxxxxx

NEWMATRIX

Page 73: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

4 4 4 2 7 6 1 20 2 1

1 2 3

1 2 3

x x xx x x

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

a21 / a11 = 4/2 = 2

Subtract the revised first equation from the second equation

395217442624

321

321

321

xxxxxxxxx

3952120

132

321

321

321

xxxxxxxxx

NOW LET’SGET A ZEROHERE

Page 74: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Multiply equation 1 by a31/a11 = 2/2 = 1and subtract from equation 3

2 2 5 1 9 3 3 10 4 6 2

1 2 3

1 2 3

x x xx x x

2 3 14 4 7 12 5 9 3

1 2 3

1 2 3

1 2 3

x x xx x xx x x

Solution

Page 75: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

2 3 14 4 7 12 5 9 3

2 3 12 14 6 2

1 2 3

1 2 3

1 2 3

1 2 3

2 3

2 3

x x xx x xx x x

x x xx xx x

Following the same rationale, subtract the 3rd equation from the first equation

Continue thecomputation by multiplying the second equationby a32’/a22’ = 4/2 =2

Subtract the third equation of the newmatrix

Solution

Page 76: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

2 3 12 14 6 2

2 3 12 1

4 4

1 2 3

2 3

2 3

1 2 3

2 3

3

x x xx xx x

x x xx x

x

THIS DERIVATION OFAN UPPER TRIANGULAR MATRIXIS CALLED THE FORWARDELIMINATION PROCESS

Solution

Page 77: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

From the system we immediately calculate:

x344

1

Continue to back substitute

2 3 12 1

4 4

1 2 3

2 3

3

x x xx x

x

x

x

2

1

1 12

1

1 3 12

12

THIS SERIES OFSTEPS IS THEBACK SUBSTITUTION

Solution

Page 78: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Pitfalls of the Elimination Method• Division by zero• Round off errors

• magnitude of the pivot element is small compared to other elements

• Ill conditioned systems

Page 79: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Pivoting• Partial pivoting

• rows are switched so that the pivot element is not zero

• rows are switched so that the largest element is the pivot element

• Complete pivoting• columns as well as rows are searched for

the largest element and switched• rarely used because switching columns

changes the order of the x’s adding unjustified complexity to the computer program

Page 80: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

For example

Pivoting is used here to avoid division by zero

2 3 84 6 7 32 6 5

2 3

1 2 3

1 2 3

x xx x xx x x

4 6 7 32 3 8

2 6 5

1 2 3

2 3

1 2 3

x x xx x

x x x

Page 81: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Another Improvement: Scaling

• Minimizes round-off errors for cases where some of the equations in a system have much larger coefficients than others

• In engineering practice, this is often due to the widely different units used in the development of the simultaneous equations

• As long as each equation is consistent, the system will be technically correct and solvable

Page 82: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Use Gauss Elimination to solve the following setof linear equations. Employ partial pivoting when necessary.3 13 502 6 454 8 4

2 3

1 2 3

1 3

x xx x xx x

Example

Work with class

Page 83: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

3 13 502 6 454 8 4

2 3

1 2 3

1 3

x xx x xx x

First write in matrix form, employing short hand presented in class.

0 3 13 502 6 1 454 0 8 4

We will clearly run intoproblems of divisionby zero.

Use partial pivoting

Solution

Page 84: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

0 3 13 502 6 1 454 0 8 4

Pivot with equationwith largest an1

Page 85: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

501330451624804

480445162501330

Page 86: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

501330433604804

501330451624804

480445162501330

Begin developingupper triangular matrix

Page 87: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

4 0 8 40 6 3 430 3 13 50

4 0 8 40 6 3 430 0 14 5 28 5

28 514 5

1 96643 3 1 966

68149

4 8 1 9664

2 931

3 8149 13 1 966 50

3 2

1

. .

.

..

..

..

. .

x x

x

CHECKokay

...end ofproblem

Page 88: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss-Jordan• Variation of Gauss elimination• Primary motive for introducing this

method is that it provides a simple and convenient method for computing the matrix inverse.

• When an unknown is eliminated, it is eliminated from all other equations, rather than just the subsequent one

Page 89: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Graphical Depiction of the Gauss-Jordan Method with Matrix Inversion

A Ia a aa a aa a a

a a aa a aa a a

I A

11 12 13

21 22 23

31 32 33

111

121

131

211

221

231

311

321

331

1

1 0 00 1 00 0 1

1 0 00 1 00 0 1

Note: the superscript“-1” denotes thatthe original valueshave been convertedto the matrix inverse,not 1/aij

Page 90: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• All rows are normalized by dividing them by their pivot elements

• Elimination step results in an identity matrix rather than an UT matrix

Gauss-Jordan

1 0 00 1 00 0 1

1

1

2

3

1

2 2

3 3

|||

ccc

x c

x c

x c

n

n

n

n

n

n

a a a ca a a ca a a c

ccc

n

n

n

11 12 13 1

21 22 23 2

31 32 33 3

2

3

1 0 00 1 00 0 1

1

|||

|||

' ' '

' ' ' '

Page 91: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Matrix Inversion• [A] [A] -1 = [A]-1 [A] = I• One application of the inverse is to

solve several systems differing only by {c}• [A]{x} = {c}• [A]-1[A] {x} = [A]-1{c}• [I]{x}={x}= [A]-1{c}

• One quick method to compute the inverse is to augment [A] with [I] instead of {c}

Page 92: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

WHEN IS THE INVERSE MATRIX USEFUL?

CONSIDER STIMULUS-RESPONSE CALCULATIONS THAT ARE SO COMMON IN ENGINEERING.

Page 93: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Stimulus-Response Computations• Conservation Laws

massforceheatmomentum

• We considered the conservation of force in the earlier example of a truss

Page 94: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• [A]{x}={c}• [interactions]{response}={stimuli}• Superposition

• if a system subject to several different stimuli, the response can be computed individually and the results summed to obtain a total response

• Proportionality• multiplying the stimuli by a quantity results

in the response to those stimuli being multiplied by the same quantity

• These concepts are inherent in the scaling of terms during the inversion of the matrix

Stimulus-Response Computations

Page 95: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

ExampleGiven the following, determine {x} for the two different loads {c}

174

321

413362112

1

T

T

c

c

A

cAx

Strategy

Page 96: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy• Ax=c can be solved as A-1c=x• Note that c is given as cT.

[ 1.29 0.14 0.430.81 0.24 0.38

−0.76 − 0.05 −0.48 ]{𝑥1

𝑥2

𝑥3}={123 }

321

413362112

1

Tc

A

[ 2 −1 1−2 6 3−3 1 − 4]{

123 }={𝑥1

𝑥2

𝑥3}

Page 97: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Excel Demonstration• Excel treats matrices as arrays• To obtain the results of

multiplication, addition, and inverse operations, you hit control-shift-enter as opposed to enter.

• The resulting matrix cannot be altered…let’s see an example using Excel in class

Example Spreadsheet

Page 98: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss Seidel Method• An iterative approach• Continue until we converge within some

pre-specified tolerance of error• Round off is no longer an issue, since you

control the level of error that is acceptable• Fundamentally different from Gauss

elimination. This is an approximate, iterative method particularly good for large number of equations

Page 99: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss-Seidel Method• If the diagonal elements are all nonzero,

the first equation can be solved for x1

• Solve the second equation for x2, etc.

x c a x a x a xa

n n1

1 12 2 13 3 1

11

To assure that you understand this, write the equation for x2

Page 100: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

x c a x a x a xa

x c a x a x a xa

x c a x a x a xa

x c a x a x a xa

n n

n n

n n

nn n n nn n

nn

11 12 2 13 3 1

11

22 21 1 23 3 2

22

33 31 1 32 2 3

33

1 1 3 2 1 1

Page 101: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss-Seidel Method• Start the solution process by

guessing values of x• A simple way to obtain initial

guesses is to assume that they are all zero

• Calculate new values of xi starting with• x1 = c1/a11

• Progressively substitute through the equations

• Repeat until tolerance is reached

Page 102: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

x c a x a x ax c a x a x ax c a x a x a

x c a a a ca x

x c a x a a xx c a x a x a x

1 1 12 2 13 3 11

2 2 21 1 23 3 22

3 3 31 1 32 2 33

1 1 12 13 111

111

2 2 21 1 23 22 2

3 3 31 1 32 2 33 3

0 0

0

///

/ '

' / '' ' / '

Gauss-Seidel Method

Page 103: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Example

2 3 1 24 1 2 23 2 1 1

Given the following augmented matrix, complete one iteration of the Gauss Seidel method. Start with an initial estimate of xT={0,0,0}

Strategy

Page 104: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy

33323213133

2222312122

22232312122

111

111131211

111

11131321211

'/''

'/0''/'

'/00

'/

xaxaxacx

xaaxacxxaxaxacx

xacaaacx

xacaxaxacx

Page 105: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Jacobi Method

• Iterative like Gauss Seidel• Gauss-Seidel immediately uses the

value of xi in the next equation to predict x i+1

• Jacobi calculates all new values of xi’s to calculate a set of new xi values

Page 106: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

FIRST ITERATION

x c a x a x a x c a x a x a

x c a x a x a x c a x a x a

x c a x a x a x c a x a x a

SECOND ITERATION

x c a x a x a x c a x a x a

x c a x a x a x c a x

1 1 12 2 13 3 11 1 1 12 2 13 3 11

2 2 21 1 23 3 22 2 2 21 1 23 3 22

3 3 31 1 32 2 33 3 3 31 1 32 2 33

1 1 12 2 13 3 11 1 1 12 2 13 3 11

2 2 21 1 23 3 22 2 2 21 1

/ /

/ /

/ /

/ /

/

a x a

x c a x a x a x c a x a x a

23 3 22

3 3 31 1 32 2 33 3 3 31 1 32 2 33

/

/ /

Graphical depiction of difference between Gauss-Seidel and Jacobi

Page 107: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

2 3 1 24 1 2 23 2 1 1

Note: We worked the Gauss Seidel method earlier

Given the following augmented matrix, complete one iteration of the Gauss Seidel method and the Jacobi method. Start with an initial estimate of xT={0,0,0}

Example

Strategy

Page 108: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Strategy

333323133

33323213133

222232122

22222312122

111

111131211

111

11131321211

'/00'/

'/00'/

'/00

'/

xaaacxxaxaxacx

xaaacxxaxaxacx

xacaaacx

xacaxaxacx

Page 109: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Gauss-Seidel Methodconvergence criterion

a iij

ij

ij s

x xx,

1

100

as in previous iterative procedures in finding the roots,we consider the present and previous estimates.

As with the open methods we studied previously with onepoint iterations

1. The method can diverge2. May converge very slowly

Page 110: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Convergence criteria

a a where j n excluding j iii ij 1,

This condition is sufficient but not necessary; for convergence.

When met, the matrix is said to be diagonally dominant.

Page 111: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Diagonal Dominance

Now, check to see if these numbers satisfy the following rule for each row (note: each row represents a unique equation).a a where j n excluding j iii ij 1,

439

xxx

9.05.01.04.08.02.04.02.01

3

2

1

Page 112: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

x1

Note: we are convergingon the solution

v x xu x x::

11 9 9911 13 286

1 2

1 2

CONVERGENCE

x2

Page 113: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

x1

Change the order ofthe equations: i.e. changedirection of initial estimates

u x xv x x::

11 13 28611 9 99

1 2

1 2

DIVERGENCE

x2

Page 114: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Improvement of Convergence Using Relaxation

This is a modification that will enhance slow convergence.

After each new value of x is computed, calculate a new valuebased on a weighted average of the present and previousiteration.

x x xinew

inew

iold 1

Page 115: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

Improvement of Convergence Using Relaxation

• if = 1 unmodified• if 0 < < 1 underrelaxation

• nonconvergent systems may converge• hasten convergence by dampening out

oscillations• if 1< < 2 overrelaxation

• extra weight is placed on the present value• assumption that new value is moving to the

correct solution by too slowly

x x xinew

inew

iold 1

Page 116: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• Review basic definitions • Review basic matrix operations

• Addition/subtraction• Multiplication• Determinant

• Understand the graphic interpretation of ill-conditioned systems and how it relates to the determinant

• Be familiar with terminology: forward elimination, back substitution, pivot equations and pivot coefficient

Specific Study Objectives

Page 117: MATRIX METHODS SYSTEMS OF LINEAR  EQUATIONS Student Notes

• Apply matrix inversion • Understand that the Gauss-Seidel method is

particularly well-suited for large sparse systems of equations

• Know how to assess diagonal dominance of a system of equations and how it relates to whether the system can be solved with the Gauss-Seidel method

• Understand the rationale behind relaxation and how to apply this technique

Specific Study Objectives