23
Chapter 8 Numerical Technique 大大大大 大大大大大 大大大 Linear Algebra

Chapter 8 Numerical Technique

  • Upload
    arvid

  • View
    39

  • Download
    1

Embed Size (px)

DESCRIPTION

Linear Algebra. Chapter 8 Numerical Technique. 大葉大學 資訊工程系 黃鈴玲. 8.1 Gaussian Elimination. Definition A matrix is in echelon form if Any rows consisting entirely of zeros are grouped at the bottom of the matrix. - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 8 Numerical Technique

Chapter 8Numerical Technique

大葉大學 資訊工程系黃鈴玲

Linear Algebra

Page 2: Chapter 8 Numerical Technique

Ch8_2

8.1 Gaussian EliminationDefinitionA matrix is in echelon form if

1. Any rows consisting entirely of zeros are grouped at the bottom of the matrix.

2. The first nonzero element of each row is 1. This element is called a leading 1.

3. The leading 1 of each row after the first is positioned to the right of the leading 1 of the previous row.

(This implies that all the elements below a leading 1 are zero.)

Reduced echelon form 與 echelon from 的差異: echelon form 的 leading 1 上面的數字不必為零

Page 3: Chapter 8 Numerical Technique

Ch8_3

Example 1Solving the following system of linear equations using the method of Gaussian elimination.

Solution 412842222

1232

4321

4321

4321

xxxxxxxxxxxx

Starting with the augmented matrix, create zeros below the pivot in the first column.

4128422122112321

682001310012321

1)2(312RR

RR

At this stage, we create a zero only below the pivot.

420001310012321

2)2(3 RR

210001310012321

32

1R

Echelon formWe have arrived at the echelon form.

Page 4: Chapter 8 Numerical Technique

Ch8_4

The corresponding system of equation is

213

1232

4

43

4321

xxxxxxx

We get

51)2(3

3

3

xx

Substituting x4 = 2 and x3 = 5 into the first equation,

102102

1)2(2)5(32

21

21

21

xxxx

xx

Let x2 = r. The system has many solutions. The solutions are2 ,5 , ,102 4321 xxrxrx

Page 5: Chapter 8 Numerical Technique

Ch8_5

Example 2Solving the following system of linear equations using the method of Gaussian elimination, performing back substitution using matrices.

412842222

1232

4321

4321

4321

xxxxxxxxxxxx

SolutionWe arrive at the echelon form as in the previous example.

4128422122112321

210001310012321

Echelon formThis marks the end of the forward elimination of variables from equations. We now commence the back substitution using matrices.

Page 6: Chapter 8 Numerical Technique

Ch8_6

210005010050321

3)3(2

)2(1 210001310012321

RRRR 2

2100050100

100021 )3(1 RR 3

This matrix is the reduced echelon form of the original augmented matrix. The corresponding system of equations is

25

102

4

3

21

xxxx

Let x2 = r. We get same solution as previously,2 ,5 , ,102 4321 xxrxrx

Page 7: Chapter 8 Numerical Technique

Ch8_7

Comparison of Gauss-Jordan and Gaussian Elimination

Count of Operations for n n system with Unique Solution

Number of Multiplications

Number of Additions

Gauss-Jordan

Gaussian elimination

) largefor (

323

222n

nnn 222

33 nnn

333

32

3 nnn

n 36

523

323 nnnn

Page 8: Chapter 8 Numerical Technique

Ch8_8

8.2 The Method of LU Decomposition

8204

0725

0013

0002

7000

2400

1920

3528

lower triangular matrix upper triangular matrix

Ax=y A=LU …

Page 9: Chapter 8 Numerical Technique

Ch8_9

Example 1Solving the following system of equations, which has a triangular matrix of coefficients.

354

2 3

8 2

321

21

1

xxx

xx

x

Solution

1st equations gives 482 11 xx

2nd equation gives 223423 2221 xxxx

3rd equation gives 331016354 33321 xxxxx

The solution is .3,2,4 321 xxx

By forward substitution:

Page 10: Chapter 8 Numerical Technique

Ch8_10

Example 2Solving the following system of equations, which has an upper triangular matrix of coefficients.

63

4

042

3

32

321

x

xx

xxx

Solution

3rd equation gives 263 33 xx

2nd equation gives 2424 2232 xxxx

1st equations gives 50822042 11321 xxxxx

The solution is .2,2,5 321 xxx

By back substitution:

Page 11: Chapter 8 Numerical Technique

Ch8_11

DefinitionLet A be a square matrix that can be factored into the form A = LU, where L is a lower triangular matrix and U is an upper triangular matrix, This factoring is called an LU decomposition of A. (Not every matrix has an LU decomposition, and when it exists, it is not unique.)

Page 12: Chapter 8 Numerical Technique

Ch8_12

Solution of AX = B1. Find the LU decomposition of A.

(If A has no LU decomposition, the method is not applicable.)

2. Solve LY = B by forward substitution.

3. Solve UX = Y by back substitution.

Let AX = B be a system of n equations in n variables, where A has LU decomposition A = LU. LUX = B two subsystems: UX = Y (upper triangular) and LY = B (lower triangular)

Method of LU Decomposition

How to decompose A=LU? 利用 elementary matrices

Page 13: Chapter 8 Numerical Technique

Ch8_13

Elementary Matrices (複習第二章 )

Definition An elementary matrix is one that can be obtained from the identity matrix In through a single elementary row operation.

Example

100

010

001

3I

010

100

001

1ER2 R3

100

050

001

2E5R2

100

012

001

3ER2+ 2R1

Page 14: Chapter 8 Numerical Technique

Ch8_14

Elementary Matrices (複習第二章 )

ihg

fed

cba

A

AEA

fed

ihg

cba

1

010

100

001

R2 R3

AEA

ihg

fed

cba

2

100

050

001

555

5R2

AEA

ihg

cfbead

cba

3

100

012

001

222

R2+ 2R1

一個矩陣做 elementary row operation ,相當於在左邊乘一個對應的 elementary matrix 。

Page 15: Chapter 8 Numerical Technique

Ch8_15

Elementary matrices (複習第二章 )Each elementary matrix is invertible.

Example1

221EI

RR

100

010

021

1E

100

010

001

I 112

100

010

021

EE

, 221

1 IERR

IEE 12 i.e.,

Note that (E1)12 = (E2)12.

Page 16: Chapter 8 Numerical Technique

Ch8_16

( 利用 elementary matrix)A … U (upper triangular) U = Ek E1 A A = (E1)1 (Ek)1 U

If each such elementary matrix Ei is a lower triangular matrices,it can be proved that (E1)1, , (Ek)1 are lower triangular, and(E1)1 (Ek)1 is a lower triangular matrix.Let L=(E1)1 (Ek)1 then A=LU.

How to decompose A=LU?

Page 17: Chapter 8 Numerical Technique

Ch8_17

Example 3Solving the following system of equations using LU decomposition.

21226574

132

321

321

321

xxxxxxxxx

SolutionLet us transform the matrix of coefficients A into upper triangular form U by creating zeros below the main diagonal as follows.

1226714312

A

1226110312

122 RR

310110312

133 RR

200110312

23 RR

U

Page 18: Chapter 8 Numerical Technique

Ch8_18

The elementary matrices that correspond to these row operations are

11001000123

,

103010001133

,

100012001122

321

RR

E

RR

E

RR

E

The inverse of these matrices are

110010001

,103010001

,100012001

13

12

11 EEE

We get

113012001

13

12

11 EEEL

Thus

200110312

113012001

UL

A

Page 19: Chapter 8 Numerical Technique

Ch8_19

We now solve the given system LUX = B by solving the two subsystems LY = B and UX = Y. We get

2

5

1

113

012

001

:

3

2

1

y

y

y

BLY

This lower triangular system has solution .2,7,1 321 yyy

271

200110312

:

3

2

1

xxx

YUX

The upper triangular system has solution .1,8,5 321 xxx

The solution to the given system is .1,8,5 321 xxx

Page 20: Chapter 8 Numerical Technique

Ch8_20

Construction of a LU decomposition of a Matrix A

1. Use row operations to arrive at U.

(The operations must involve adding multiples of rows to rows. In general, if row interchanges are required to arrive at U, an LU form does not exists.)

2. The diagonal element of L are ls.

The nonzero elements of L corresponding to row operations.

The row operation Ri + cRj implies that lij = c.

Page 21: Chapter 8 Numerical Technique

Ch8_21

Example 4Solve the following system if equations using LU decomposition.

5823841235

1243

321

321

321

xxxxxxxxx

Solution

2384

351

431

740

120

431

143

12

RR

RR

500

120

431

223 RR

These row operations lead to the following LU decomposition of A.

500

120

431

124

011

001

AL21= 1

L31= L32=

Page 22: Chapter 8 Numerical Technique

Ch8_22

We again solve the given system LUX = B by solving the two subsystems LY = B and UX = Y.

58

12

12

124

011

001

:

3

2

1

y

y

y

BLY

10

0

12

500

120

431

:

3

2

1

x

x

x

YUX

This lower triangular system has solution y1 = 12, y2 = 0, y3 = 10.

This upper triangular system has solution x1 = 1, x2 = 1, x3 = 2.

The solution to the given system is x1 = 1, x2 = 1, x3 = 2.

Page 23: Chapter 8 Numerical Technique

Ch8_23

Homework

Exercise 8.27(a), 9, 20