Top Banner
Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng
46

Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Dec 18, 2015

Download

Documents

Jeffrey Murphy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Lecture 6Matrix Operations

and Gaussian Elimination for Solving Linear Systems

Shang-Hua Teng

Page 2: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Matrix (Uniform Representation for Any Dimension)

• An m by n matrix is a rectangular table of mn numbers

ji

nmmm

n

n

ajiA

aaa

aaa

aaa

A

,

,2,1,

,22,21,2

,12,11,1

),( write weSometime

...

...

...

...

Page 3: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Matrix (Uniform Representation for Any Dimension)

• Can be viewed as m row vectors in n dimensions

nmmm

n

n

aaa

aaa

aaa

A

,2,1,

,22,21,2

,12,11,1

...

...

...

...

Page 4: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Matrix (Uniform Representation for Any Dimension)

• Or can be viewed as n column vectors in m dimensions

nmmm

n

n

aaa

aaa

aaa

A

,2,1,

,22,21,2

,12,11,1

...

...

...

...

Page 5: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Squared Matrix

• An n by n matrix is a squared table of n2 numbers

nnnn

n

n

aaa

aaa

aaa

A

,2,1,

,22,21,2

,12,11,1

...

...

...

...

Page 6: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Some Special Squared Matrices

• All zeros matrix

0...00

...

0...00

0...00

),(0

mn

• Identity matrix

1...00

...

0...10

0...01

),(

nnII

Page 7: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Matrix Operations

• Addition

• Scalar multiplication

• Multiplication

Page 8: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

1. Matrix Addition:

mnmnmm

nn

nn

mnmm

n

n

mnmm

n

n

baba

bababa

bababa

BA

bbb

bbb

bbb

B

a aa

a aa

a aa

A

,

,

11

2222222121

1112121111

21

22221

11211

21

22221

11211

Matrices have to have the same dimensionsWhat is the complexity?

Page 9: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

2. Scalar Multiplication:

mnmm

n

n

mnmm

n

n

aaa

aaa

aaa

aaa

aaa

aaa

A

21

2 2221

11211

21

22221

11211

What is the complexity?

Page 10: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

3. Matrix Multiplication

n

i ipmiimi

n

i ipi

n

i ii

n

i ii

n

i ipi

n

i ii

n

i ii

npnn

p

p

mnmm

n

n

baba

bababa

bababa

BA

bbb

bbb

bbb

B

aaa

aaa

aaa

A

1

n

1=i 1

1 21 221 12

1 11 211 11

21

22221

11211

21

22221

11211

,

,

Two matrices have to be conformalWhat is the complexity?

Page 11: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Matrix Multiplication

B) of j(column A) of i row(

,

,

21

22221

11211

21

22221

11211

BA

bbb

bbb

bbb

B

aaa

aaa

aaa

A

npnn

p

p

mnmm

n

n

Two matrices have to be conformal

Page 12: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

The Laws of Matrix Operations

• A + B = B + A (commutative)

• c(A+B) = cA + c+B (distributive)

• A + (B + C) = (A + B) + C (associative)

• C(A+B) = CA + CB (distributive from left)

• (A+B)C = AC+BC (distributive from right)

• A(BC) = (AB)C (associative)

• But in general: BAAB

Page 13: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Counter Example

00

01

01

00

00

10

10

00

00

10

01

00

BA

but

AB

Page 14: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Special Matrices

• Identity matrix I– IA = AI = A

• Square Matrix A

pqqp

qpqp

p

p

AA

AAA

AAAAA

Page 15: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Elimination: Method for Solving Linear Systems

• Linear Systems == System of Linear Equations

• Elimination: – Multiply the LHS and RHS of an equation by a

nonzero constant results the same equations

– Adding the LHSs and RHSs of two equations does not change the solution

0),()(:)()(: xgxfxxgxfx

)()()()();()(:)()();()(: 2121112211 xgxgxfxfxgxfxxgxfxgxfx

Page 16: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Elimination in 2D

• Multiply the first equation by 3 and subtracts from the second equation (to eliminate x)

1123

12

yx

yx

880

12

y

yx

• The two systems have the same solution

• The second system is easy to solve

Page 17: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Geometry of Elimination

1123

12

yx

yx

1123 yx

12 yx

(3,1)8y = 8

880

12

y

yxReduce to a 1-dimensional problem.

Page 18: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Upper Triangular Systems and Back Substitution

• Back substitution– From the second equation y = 1– Substitute the value of y to the first equation to obtain

x-2=1– Solve it we have: x = 3

880

12

y

yx

• So the solution is (3,1)

Page 19: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

How Much to Multiply before Subtracting

• Pivot: first nonzero in the row that does the elimination

• Multiplier: (entry to eliminate) divided by (pivot)

1123

12

yx

yx

Multiply: = 3/1

Page 20: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

How Much to Multiply before Subtracting

• Pivot: first nonzero in the row that does the elimination

• Multiplier: (entry to eliminate) divided by (pivot)

1123

242

yx

yx

Multiply: = 3/2

880

242

y

yx

The pivots are on the diagonal of the triangle after the elimination

Page 21: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Breakdown of Elimination

• What is the pivot is zero == one can’t divide by zero!!!!

1163

12

yx

yx

Eliminate x:

80

12

y

yx

No Solution!!!!: this system has no second pivot

Page 22: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Geometric Intuition(Row Pictures)

• Two parallel lines never intersect

1163 yx

12 yx

(3,1)8y = 8

Page 23: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Geometric Intuition(Column Picture)

11

1

3

1

6

2

Two column vectors are co-linear!!!!

1163

12

yx

yx

Page 24: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Geometric Intuition

Geometric degeneracy cause failure in elimination!

Page 25: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Failure in Elimination May Indicate Infinitely Many Solutions

• y is free, can be number!

• Geometric Intuition (row picture): The two line are the same

• Geometric Intuition (column picture): all three column vectors are co-linear

363

12

yx

yx00

12

y

yx

Page 26: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Failure in Elimination(Temporary and can be Fixed)

• First pivot position contains zero• Exchange with the second equation

523

420

yx

yx

42

522

y

yx

Can be solved by backward substitution!

Page 27: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Singular Systems versus Non-Singular Systems

• A singular system has no solution or infinitely many solution– Row Picture: two line are parallel or the same– Column Picture: Two column vectors are co-

linear

• A non-singular system has a unique solution– Row Picture: two non-parallel lines– Column Picture: two non-colinear column

vectors

Page 28: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Gaussian Elimination in 3D

• Using the first pivot to eliminate x from the next two equations

10732

8394

2242

zyx

zyx

zyx

Page 29: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Gaussian Elimination in 3D

• Using the second pivot to eliminate y from the third equation

125

4

2242

zy

zy

zyx

Page 30: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Gaussian Elimination in 3D

• Using the second pivot to eliminate y from the third equation

84

4

2242

z

zy

zyx

Page 31: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Now We Have a Triangular System

• From the last equation, we have

84

4

2242

z

zy

zyx

Page 32: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution

• And substitute z to the first two equations

2

4

2242

z

zy

zyx

Page 33: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution

• We can solve y

2

42

2442

z

y

yx

Page 34: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution

• Substitute to the first equation

2

2

2442

z

y

yx

Page 35: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution

• We can solve the first equation

2

2

2482

z

y

x

Page 36: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution

• We can solve the first equation

2

2

1

z

y

x

Page 37: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Generalization

• How to generalize to higher dimensions?

• What is the complexity of the algorithm?

• Answer:

• Express Elimination with Matrices

Page 38: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Step 1Build Augmented Matrix

10732

8394

2242

zyx

zyx

zyx

Ax = b

10732

8394

2242

bA[A b]

Page 39: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Pivot 1: The elimination of column 1

1

2

10732

8394

2242

10732

4110

2242

12510

4110

2242

Page 40: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Pivot 2: The elimination of column 2

1

12510

4110

2242

8400

4110

2242

Upper triangular matrix

Page 41: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Backward Substitution 1: from the last column to the first

8400

4110

2242

Upper triangular matrix

2100

4110

2242

2100

2010

2242

2100

2010

6042

2100

2010

2002

2100

2010

1001

Page 42: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Expressing Elimination by Matrix Multiplication

Page 43: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Elementary or Elimination Matrix

• The elementary or elimination matrix

That subtracts a multiple l of row j from row i can be obtained from the identity entry by adding (-l) in the i,j position

jiE ,

jiE ,

10

010

001

1,3

l

E

Page 44: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Elementary or Elimination Matrix

3,33,12,32,11,31,1

3,22,21,2

3,12,11,1

3,32,31,3

3,22,21,2

3,12,11,1

3,32,31,3

3,22,21,2

3,12,11,1

1,3

10

010

001

alaalaala

aaa

aaa

aaa

aaa

aaa

laaa

aaa

aaa

E

Page 45: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

Pivot 1: The elimination of column 1

12510

4110

2242

1

2

Elimination matrix

10732

8394

2242

10732

4110

2242

10732

8394

2242

100

012

001

12510

4110

2242

10732

4110

2242

101

010

001

Page 46: Lecture 6 Matrix Operations and Gaussian Elimination for Solving Linear Systems Shang-Hua Teng.

The Product of Elimination Matrices

101

012

001

100

012

001

101

010

001

111

012

001

101

012

001

110

010

001