00-2/1 li e ti s tlinear equation system...

16
1 00-2/1 Li E ti S t Linear Equation System (ระบบสมการเชิงเส ) โดย รย์ เห็มส วรรณ สาขาวิชาวิศวกรรมเครืÉองกล ปีการศึกษา 1/2555 2 Linear System Equation Liner System Equation: n equation, n unknowns Linear System Equation 11 1 12 2 1 1 21 1 22 2 2 2 (1) n n n n a x a x a x b a x a x a x b + + + = + + + = 1 1 2 2 (1) n n n n n a x a x ax b + + + = # Matrix Form of Linear Equation System (1) (by Multiplication Matrix) a a a x b ⎤⎧ 11 12 1 1 1 21 22 2 2 2 (2) n n a a a x b a a a x b Ax B ⎤⎧ ⎥⎪ = = # # 1 2 n n nn n n a a a x b ⎦⎩ # # { } , 0 " " coefficient matrix unknown vector if B homogeneous system A x É { } {} 0 " " , " 0 if B forzing vector homogeneous system nonho if B moge B neous syste = " m หัวข้อที Éจะ ศึกษาในบทนีÊ

Upload: others

Post on 24-Mar-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

1

00-2/1

Li E ti S tLinear Equation System

(ระบบสมการเชงเสน)( )

โดย วทรย เหมสวรรณ สาขาวชาวศวกรรมเครองกล ปการศกษา 1/2555

2Linear System Equation

Liner System Equation: n equation, n unknownsLinear System Equation

11 1 12 2 1 1

21 1 22 2 2 2 (1)

n n

n n

a x a x a x b

a x a x a x b

+ + + =+ + + =

……

1 1 2 2

(1)

n n n n na x a x a x b

+ + + =…

Matrix Form of Linear Equation System (1) (by Multiplication Matrix)a a a x b⎡ ⎤ ⎧ ⎫ ⎧ ⎫11 12 1 1 1

21 22 2 2 2 (2)

n

n

a a a x b

a a a x bAx B

⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎢ ⎥ ⎪ ⎪ ⎪ ⎪

⎪ ⎪ ⎪ ⎪⎢ ⎥ = ⇒ →⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪=

……

1 2n n nn n na a a x b

⎢ ⎥⋅ ⋅ ⋅ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

……

{ }

,

0 " "

coefficient matrix unknown vector

if B homogeneous system

A x≡ ≡

⇒⎧⎪ { }{ }0 "

",

"

0

if Bforzing vector

homogeneous system

nonhoif B mogeB

neous syste

= ⇒≡

≠ ⇒ "m

⎧⎪⎨⎪⎩

หวขอทจะศกษาในบทน

Page 2: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

หวขอทศกษา: Non-Homogeneous Linear System Equation

3

การหาคารากของระบบสมการ ดวยวธตรง (Ch 7 * , 9** , 10**)

หวขอทศกษา: Non Homogeneous Linear System Equation

- Graphical Methods

- Cramer’ Rule

- Gauss elimination

- Gauss-Jordan and Matrix Inversion- LU Decomposition

การหาคารากของระบบสมการ ดวยวธไมตรง (การคานวณซา) (Ch 11 *)การหาคารากของระบบสมการ ดวยวธไมตรง (การคานวณซา) (Ch 11 )

- Jacobi Iteration

G S id l M th d- Gauss-Seidel Method

41. The Graphical methods & General Case of Solution

Matrix form of Non-Homogeneous Equations: n equations, n unknowns1. The Graphical methods & General Case of Solution

[ ] { } { }1 1

(1)n n n n

A X B× × ×

= →

Case (a) Case (b) Case (c)General Case of System Equation

( ) ( ) ( )x + y = 1

2x - y = 0x + y = 1

2x + 2y = 2x + y = 1x + y = 2y 2x 2y 2 x y 2

Solution Solution

“Unique Solution” “Infinitely Many Solution” “No Solution”

Page 3: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

52. Cramer’s Rule2. Cramer s Rule

Cramer’s Rule คอ กรรมวธในการแก Linear system equation ทมจานวนสมการเทากนกบจานวน ป ไ ป ป ใ ตวแปรทไมทราบคา (n equations , n unknowns) ซงกรรมวธนจะเปนการประยกตใชหลกการ

Determinate of matrix

[ ]{ } { }

11 12 1

21 22 2

1 1

2 2

n

n

a a a

a a aM t i f A

x b

x bBX⇒

⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⇒ ⎨ ⎬ ⎨ ⎬

……

[ ]{ } { }

1 2n n nn n n

Matrix from

a a a

A B

x b

X= ⇒⋅ ⋅

=⋅

⎢ ⎥⇒ ⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

……1 2

' :

n n nn n n

A A A

Cramer s lRu e

⎣ ⎦ ⎩ ⎭ ⎩ ⎭

1, 2, ,

1 2; ;

det

.

(

;

)

..B B n B

n

A A Ax x x

A ASolution of system

A A

A= = =⇒

เมอ

,

det( )

n B

A A

A

=

=

เมอDeterminate ของ A ทสมาชกในหลกท n ของ A ถกแทนดวย B

,

Note. Cramer’s Rule ใชไดเฉพาะกรณท |A| ≠ 0 (A isn't Singular matrix) เทานน

62. Cramer’s Rule (cont.)2. Cramer s Rule (cont.)

EX. #1 Solve the linear system Step 2. Check: system equation can solve by

10 25

0 (1)

90 (2)

x y z

y z

− + = →+ = →

Cramer’s Rule ? |A| = 0 เลก (มองหาวธอน)

เชน Gauss Elimination20 10 80 (3)x y+ = →

n

Check: |A| = 0 ? เชน Gauss Elimination

|A| ≠ 0 ใช Cramer’s Rule ไดnSol

Step 1. Set (1) - (3) to matrix from 10 25 1 1 1 11 0 20

10 0 10 0 10 25A

− −+ − +=

1 1 1 0

0 10 25 90y

x−⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥

950 #1(0 250) 0 20( 25 10) OK+ − − + − − −==

3 3 3 1 3 120 10 0 80z× × ×

⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦

⇑ ⇑

⎩ ⎭ ⎩ ⎭ Step 3. Solve: Cramer’s Rule,

'n B

Cramer s RuleA

x⇒ ={ } { }[ ]A BX =

nCramer s Rule xA

1 101

−901 10 25

9508 10 00

x⇒ =−

Page 4: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

72. Cramer’s Rule (cont.)2. Cramer s Rule (cont.)

[ ]1 1

0 ( 1)(25)(80) 1(10)(90)1 1 19000 −

+ + − +⎧ ⎫[ ][ ]0 ( 1)(25)(80) 1(10)(90)1 1 190010 25

950 950 95080(10)(1) 0 010

90 2

0

##

80

x+ + +⎧ ⎫ −= = = =⎨ ⎬− − −− +

⇒+⎩ ⎭

[ ][ ]

1 10 0 01 1 38000 25

950 950 95020(90)(1) 80(25)(1)

0

900

4 ##y+ + +⎧ ⎫ −= = = =⎨ ⎬⎩ ⎭

⇒[ ]950 950 95020(90)(1) 80(25)(1) 0

8020 0

y ⎨ ⎬− − −− + +⎩ ⎭

1 1 0[ ][ ]

1 11(10)(80) ( 1)(90)(20) 01 1 19000 10

950 950 9500 10(90)(1)

0

900

20

##

010

2

8

z−

+ + − +⎧ ⎫ −= = = =⎨ ⎬− − −− + +⎩⇒

⎭20 010 8

2x⎧ ⎫ ⎧ ⎫2

4

2

x

y

z

Ans⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪⎩ ⎭ ⎩ ⎭

∴ =z⎩ ⎭ ⎩ ⎭

83. Gauss Elimination

Gauss Elimination คอ กรรมวธในการแก Linear system equation โดยจดการกบสมประสทธของ

3. Gauss Elimination

[A] ใหอยในรป Upper triangular matrix โดยใชการขจดแบบไปขางหนา (Forward elimination) แลวใชกรรมวธการแทนคายอนกลบ (Back Substitution) หาคาตอบของ Unknown

11 12 1 1 1

21 22 2 2 2

n

n

a a a x b

a a a x b

⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎢ ⎥ ⎪ ⎪ ⎪ ⎪

⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎨ ⎬ ⎨ ⎬

…… { }1 12 121

1n nx xb a a

ax ⋅ ⋅− − −= …

21 22 2 2 2

1 2

n

n n nn n na a a x b

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥⋅ ⋅ ⋅ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

……

{ }

{ }

1 12 111

21

1

n n a

xx β α− ⋅=1 2n n nn n n⎣ ⎦ ⎩ ⎭ ⎩ ⎭ { }1 ( 1)( 1) 1)

1(

nn n n nn n

xx β αα

β

− −−

−−

=

1 (Forward elimination)n

nnnx

βα

=11 12 1 1

22 2

1

2 20na a a x b

xα α β⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎢ ⎥ ⎪ ⎪ ⎪ ⎪

⎪ ⎪ ⎪ ⎪⎢ ⎥

……

222 2 2 20

0 0

0 0 0

n x

x

α α β

α β

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩

……

(Back Substitution)0 0 0 nn n nxα β⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭* Eliminate: aij (by ±, scalar multiplication)

Page 5: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

93. Gauss Elimination (cont.)

EX. #1 จงหาคาตอบของระบบสมการ Step 3. Find x1 , x2 by 3. Gauss Elimination (cont.)

1 2

1 2

1 (1)

2 0 (2)

x x

x x

+ = →− = →

Back Substitution method

2 22 #3

from r x⇒ =

nSol

Step 1 Set to matrix form ( )1 1 211 11

3

fr x xom r ⇒ = −Step 1. Set to matrix form1 11 1 1

2 1 0

x r←⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥⎣ ⎦ ⎩ ⎭⎩ ⎭( )

1

11 11

2 1 #3 3

⎡ ⎤= − =⎢ ⎥⎣ ⎦2 22 1 0x r

⎨ ⎬ ⎨ ⎬⎢ ⎥ ←−⎣ ⎦ ⎩ ⎭⎩ ⎭

Step 2. Forward Eliminate

( ) 13 3⎢ ⎥⎣ ⎦

1 1 3

2 3

xAns

x⎧ ⎫ ⎧ ⎫∴ =⎨ ⎬ ⎨ ⎬

⎩ ⎭⎩ ⎭p

2 2 3x ⎩ ⎭⎩ ⎭Step 2.1 Eliminate a21 (2)

1 1 1r x→ ⎧ ⎫⎡ ⎤ ⎧ ⎫1 1

1 2 22

1 1 1

2(1) 2 2(1) ( 1) 2(1) 0

r x

r r x

→ ⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥− → − − − −⎣ ⎦ ⎩ ⎭⎩ ⎭

1 1 1⎧ ⎫⎡ ⎤ ⎧ ⎫1 1

2 20 3

1 1 1

2

x r

x r

←⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥⎣ ⎦ ⎩ ⎭←⎩ ⎭

103. Gauss Elimination (cont.)

EX. #2 Solve the linear system0 (1)x y z+ = →

Step 2.1 Eliminate a21, a31 , a41

1 1 1 0→ ←⎡ ⎤ ⎧ ⎫

3. Gauss Elimination (cont.)

10 25

0 (1)

0 (2)

90 (3)

x y z

x y z

y z

− + = →− + − = →

+ = →

1 1

1 2 2

1 1 1

0 0 0 0

0 10 25 90

0r rx

r

r

r ry

r

′←′←

→ ←−⎡ ⎤ ⎧ ⎫⎧ ⎫⎢ ⎥ ⎪ ⎪+ → ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬→ ⎢ ⎥ ⎪ ⎪ ⎪ ⎪10 25

20 10

90 (3)

80 (4)

y z

x y

+ = →+ = →

n

1

1 4

3

420

0 10 25 90

0 30 020 8

rrz

r r r

←′←− −

→ ⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩ ⎭⎢ ⎥ ⎪ ⎪− →⎣ ⎦ ⎩ ⎭จดเรยงใหมnSol

Step 1. Set to matrix formจดเรยงใหม

1

0 10 25 90

1 1 1 0 rx

r

←−⎡ ⎤ ⎧ ⎫⎧ ⎫⎢ ⎥ ⎪ ⎪⎪ ⎪ ⎪ ⎪⎢ ⎥

′←1

2

1 1 1 0

1 1 1 0

rx

ry

←−⎡ ⎤ ⎧ ⎫⎧ ⎫⎢ ⎥ ⎪ ⎪ ←− − ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬

⎢ ⎥

2

3

4

0 10 25 90

0 30 20 80

0 0 0 0

y

z

r

r

r

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩ ⎭⎢

←′←

⎥ ⎪ ⎪⎣ ⎦ ⎩

−′←⎭

33 1

44 3 4 1

0 10 25 90

20 10 0 80

yr

zr×

× ×

⎨ ⎬ ⎨ ⎬ ←⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩ ⎭⎢ ⎥ ⎪ ⎪ ←⎣ ⎦ ⎩ ⎭

40 0 0 0 r⎣ ⎦ ⎩ ←⎭Step 2.2 Eliminate a32

1 11 1 1 0r r→ ←−⎡ ⎤ ⎧ ⎫⎧ ⎫Step 2. Forward Eliminate

1 1

2 3

2 2

33

1 1 1 0

0 10 25 9

0 0 95 19

0

0

r rx

yr

r

r

r r

′ ′

→ ←⎡ ⎤ ⎧ ⎫⎧ ⎫⎢ ⎥ ⎪ ⎪→ ⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬→ ⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩ ⎭⎢ ⎥

′′←

′←+2 33

44 0 0 0 0z

r r′

⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩ ⎭⎢ ⎥ ⎪ ⎪→⎣ ⎦ ⎩ ′′←⎭

Page 6: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

113. Gauss Elimination (cont.)

Step 3. Find x, y, z by Back Substitution method HW#1. จงหาของ x, y, z ดวยกรรมวธ 3. Gauss Elimination (cont.)

Gauss Elimination

11 12 13 1a a a x b⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥

1

2

1

0 10 25 90

1 01 rx

from U matrix yr

←−⎡ ⎤ ⎧ ⎫⎧ ⎫⎢ ⎥ ⎪ ⎪⎪ ⎪ ⎪ ⎪⎢ ⎥⇒ =⎨ ⎬ ⎨ ⎬

⎢ ⎥

′←3

21 22 23 2

31 32 33 3

a a a y b

a a a z b

⎢ ⎥ ⎢ ⎥⎢ ⎥ =⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎣ ⎦⎣ ⎦ ⎣ ⎦

3

4

0 0 95 190

0 0 00

from U matrix y

zr

r

⎢ ⎥⇒ ⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎩

′′⎭⎢ ⎥ ⎪ ⎪⎣ ⎦ ⎩ ⎭

←′′←

1 1

190 2 #95

z = =31 32 33 3⎣ ⎦⎣ ⎦ ⎣ ⎦

เมอ aij และ bi เปนคาคงทใดๆ ทไมเทากบ 0( ) ( )[ ]

( )[ ] ( ) ( )[ ]

1 190 25 90 2510 10

2 4

1 10 1 1 0 1 1

#

4 2 2 #

y z

x y z

= = =

= − − − = − − − =

− − โดยท i =1, 2, 3 ; j =1, 2, 3

( )[ ] ( ) ( )[ ]0 1 1 0 1 11 1

4 2 2 #x y z= − − − = − − − =

2x⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪

4

2

y Ans

z

⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪∴ =⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪⎩ ⎭ ⎩ ⎭⎩ ⎭ ⎩ ⎭

123. Gauss Elimination (cont.)

EX. #3 Linear system: Infinitely Many Solution 4 2 2 (1)

Step 2.2 Eliminate: a32

3. Gauss Elimination (cont.)

4 2 2 (1)

6 2 29 (2)

4 8 4 24 (3)

y z

x y z

− = →− + = →+ →

2 2

1 1

0 14

6 2 1 29

7 7r r

r x r

y

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪

′ ′→ − − ←⎢ ⎥4 8 4 24 (3)x y z+ − = →

nSol

2 33( 14 / 4) 00 0 0r rr z− ⎪ ⎪ ⎪ ⎪′ ′ →− ⎢ ⎥⎣ ⎦ ⎩ ⎭ ′′←⎩ ⎭

St 3 Fi d b B k S b tit ti th d

16 2 1 29x r− ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥

Step 3. Find x, y, z by Back Substitution method ( ) 1 27 14 1 #

7z yy= = −+−

Step 1. Set to matrix form

2

33 3 3 1 3 1

4 8 4 24

0 4 2 2

y r

z r× × ×

⎪ ⎪ ⎪ ⎪⎢ ⎥− = ←⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪− ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭[ ] 129 2 1

#7

y arbitrary=

+

Step 2.1 Eliminate: a21, a31

[ ]

( )[ ]

29 2 16

129 2 16

2 #1 5

x y z

y y

= + −

= + − =−

Step 2. Forward Eliminate

( )1 1

1 2 20 14 7 7

6 2 1 29

6 / 4

r x r

r r y r′− −→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫

⎪ ⎪ ⎪ ⎪⎢ ⎥− → =⎨ ⎬ ⎨ ⎬⎢ ⎥ ←

( )[ ]6

y y

5

( )

x

y arbitrary y Ans⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪∴ ∞ < < ∞⎨ ⎬ ⎨ ⎬( )1 2

3

2

30 4 2 2

y

z rr⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ′− ⎪→ ⎢ ⎥⎦ ⎭ ⎩ ←⎣ ⎩ ⎭

( )

2 1

y arbitrary y Ans

z y

∴ = −∞ < < ∞⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪−⎩ ⎭ ⎩ ⎭

Page 7: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

133. Gauss Elimination (cont.)

EX. #4 Linear system: No Solution 2 3 8 (1)

Step 2.2 Eliminate: a32

3. Gauss Elimination (cont.)

2 3 8 (1)

5 2 3 (2)

8 7 0 (3)

x y z

x z

+ − = →+ = →+ → 2 2

1 12 1

0 1 3.

3 8

.88 6

r x r

yr r

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪

′−→ ←8 7 0 (3)x y z− + = →

nSol2 331 / 1.25 0 0( ) 0 0 4. rr zr

⎢ ⎥ ⎪ ⎪ ⎪ ⎪− ⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ′′←′→ ⎭′

12 1 3 8x r− ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥

Step 3. Find x, y, z by Back Substitution method

3: 0 0 0 0.4r x y z Nfo o Solutionrm ′′ + + ≠ ⇒

Step 1. Set to matrix form

2

33 3 3 1 3 1

5 0 2 3

8 1 7 0

y r

z r× × ×

⎪ ⎪ ⎪ ⎪⎢ ⎥ = ←⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪− ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

3

This Linear System is not Solution Ans∴

Step 2.1 Eliminate: a21, a31

Step 2. Forward Eliminate

( )1 1

1 2 22 / 5 0 1 3.8 6.8

2 1 3 8r x r

r r y r

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥− → =⎨ ⎬ ⎨ ⎬⎢ ⎥

′− ←

21 31

( )

( )1 2

1

2

332 / 8 0 1.25 4.7 85

y

r r z r⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪− → ⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭ ′− ←

143. Gauss Elimination (cont.)

จาก EX#2, EX#3, EX#4 จะพบวาผลเฉลยของ Linear system equation ม 3 กรณ ไดแก

3. Gauss Elimination (cont.)

1). Exactly one Solution (มชดคาตอบเพยงชดเดยว “ Unique Solution” เชน EX#2 )2). Infinitely many Solution (มชดคาตอบ > 1 ชด เชน EX#3 )3). No Solution (ไมมชดคาตอบ เชน EX#4 )

2 " "# :A Unique Solutof E nX io′ " "#3:A Solutionof EX′ ∞ # "4 ":A No Solutof nEX io′

6 2 1 | 29−⎡ ⎤ 2 1 3 | 8−⎡ ⎤

2 " "# :A Unique Solutof E nX io " "#3:A Solutionof EX ∞ #4:A No Solutof nEX io

1 1 1 | 0−⎡ ⎤⎢ ⎥

0

0 0

6 2

0

1 | 29

14 7 | 7

| 0

⎡ ⎤⎢ ⎥− −⎢ ⎥⎢ ⎥⎣ ⎦

0

0 0 0

|

1 3.8 | 6.8

| 0.4

⎡ ⎤⎢ ⎥−⎢ ⎥⎢ ⎥⎣ ⎦

10 25 | 90

95 | 190

0

0 0

⎢ ⎥⎢ ⎥

− −⎢ ⎥⎢ ⎥ |⎣ ⎦ ⎣ ⎦

0 0 0 | 0⎢ ⎥⎣ ⎦

“ Unique Solution” “ ∞ Solution” “ No Solution” q Solution

oror

Page 8: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

154. Gauss-Jordan Method

Gauss-Jordan เปน ทคลายคลงกบกรรมวธ Gauss Elimination โดยจดการกบสมประสทธของ [A] ใ ใ ไ ไ โ

4. Gauss Jordan Method

ใหอยในรป Identity matrix (I) ซงจะมขอไดเปรยบคอ จะไดคาตอบของระบบสมการโดยตรง

b⎡ ⎤ ⎧ ⎫ ⎧ ⎫11 12 1 1 1

21 22 2 2 2

n

n

a a a x b

a a a x b

⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎢ ⎥ ⎪ ⎪ ⎪ ⎪

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥

……

1 2n n nn n na a a x b

⎨ ⎬ ⎨ ⎬⎢ ⎥⋅ ⋅ ⋅ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

……

1 (Eliminate to matrix : I)*1

*2

1

2

x

x

β

β

=

=2*1*

1

2

0 0

0

1

1 0

x

x

ββ

⎧ ⎫⎧ ⎫⎡ ⎤⎪ ⎪⎪ ⎪⎢ ⎥

⎪ ⎪ ⎪ ⎪⎢ ⎥

…22 β

(Solution)2

*

20 1

1

0

0 0

0 10

x

x

β

β

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭ *n nx β=30 10 nx β⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

* Eliminate: aij (by ±, scalar multiplication)

164. Gauss-Jordan Method (cont.)

EX. #1 จงหาคาตอบของระบบสมการ Step 2.2 Scale diagonal to 14. Gauss Jordan Method (cont.)

1 2

1 2

1 (1)

2 0 (2)

x x

x x

+ = →− = →

n

( )( )

111

22 2

1

3

1 1 1

0 1 2 /

/

/ 3

x

r

r

xr

r→ ⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥→⎣ ⎦ ⎩

′←

⎭ ′←⎩ ⎭nSol

Step 1. Set to matrix formStep 2.3 Eliminate a12 (1)

1 11 2(1 / 1) 1 1 1 1 2 / 3x rr r ′′ ′ ←− − −→ ⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥1 1

2 2

1 1 1

2 1 0

x r

x r

←⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥ ←−⎣ ⎦ ⎩ ⎭⎩ ⎭

2 20 1 2 / 3x rr ′′ ⎨ ⎬ ⎨ ⎬⎢ ⎥→ ⎣ ⎩ ⎭ ←⎦ ⎩ ⎭

1 11 0 1 / 3 rx⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥⎣ ⎦ ⎩ ⎭

′′←′⎩ ⎭

Step 2. Forward Eliminate 1 1 3

2 3

xAns

⎧ ⎫ ⎧ ⎫∴ =⎨ ⎬ ⎨ ⎬⎩ ⎭⎩ ⎭

2 20 1 2 / 3 rx⎨ ⎬ ⎨ ⎬⎢ ⎥⎣ ⎦ ⎩ ⎭ ′←⎩ ⎭

2 2 3x⎨ ⎬ ⎨ ⎬

⎩ ⎭⎩ ⎭Step 2.1 Eliminate a21 (2)1 11 1 1r x→ ⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥

ขนตอนการขจด matrix A ไปเปน matrix I1 2 22 2(1) 2 2(1) ( 1) 2(1) 0r r x

⎨ ⎬ ⎨ ⎬⎢ ⎥− → − − − −⎣ ⎦ ⎩ ⎭⎩ ⎭

1 11 1 1x r←⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥

1. Eliminate [A] ไปเปน matrix U2. Scale แนว diagonal ของ matrix U 1

2 20 3 2x r=⎨ ⎬ ⎨ ⎬⎢ ⎥⎣ ⎦ ⎩ ⎭←⎩ ⎭

2. Scale แนว diagonal ของ matrix U 13. ขจด สปส. เหนอแนว diagonal ของ matrix U 0

Page 9: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

174. Gauss-Jordan Method (cont.)

EX. #2 Solve the linear system4. Gauss Jordan Method (cont.)

Step 2. Scale diagonal of matrix U to 1 1 1 1 0

0 10 25 90

x

y

−⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

1 1

2 2

/ 1

/ 10

1 1 1 0

0 1 2.5 9

r x r

r y r

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥→ = ←⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥

nSol

3 3 3 1 3 120 10 0 80z× × ×⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭ 3 3/ 95 0 0 1 2r z r⎪ ⎪ ⎪ ⎪→ ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

Step 3. Eliminate สปส. เหนอแนว diagonal เปน 0 Step 1. Forward Eliminate to matrix U

Step 1.1 Eliminate a21, a31Step 3.1 Eliminate a13, a23

1 3 11 1 1 0 2r r x r− → − − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪

1 1

2 2

1

0 10 25 90

1 1 0r x

r

r

r y

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥→ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪

1 3 1

2 3 2

3 3

2.5

0

0 1 0 4

0 0 1 2

x

r r y r

r z r

→ ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥− → = ←⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪→ ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

1 3420 0 30 20 80z rr r⎢ ⎥ ⎪ ⎪ ⎪ ⎪− →⎢ ⎥⎣ ⎦ ⎩ ⎭− − ←⎩ ⎭

Step 1.2 Eliminate a32

3 3⎣ ⎦ ⎩ ⎭ ⎩ ⎭

Step 3.2 Eliminate a12( 1) 1 0 0 2r r x r−− → ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫

1

2 2

1

0 10 25 90

1 1 1 0x r

y

r

r r

→ − ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥→ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ←

p 32 1 2 1

2 2

3 3

( 1) 1 0 0 2

0 1 0 4

0 0 1 2

r r x r

r y r

r z r

→ ←⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥→ = ←⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪→ ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

2 3

2 2

33 0 0 95 190

y

z rr r⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪→⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ←⎭+

3 30 0 1 2r z r→ ←⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

2, 4 , 2 Ansyx z∴ = = =

184.1 การหา Inverse matrix ดวยกรรมวธ Gauss-Jordan. ve se at Gauss Jo da

เดมหา Inverse Matrix จาก[ ]1 ( )

; ( ) ( )Tadj A

A adj A cof AA

− = =

การหา Inverse Matrix ดวยกรรมวธแบบ Gauss-Jordanจากนยาม

1AA

สรป การหา A-1 ดวยวธของ Gauss-Jordan1

1 1 1

(1)I

I

AA

A AA A

− − − ⇐

= →

คณ (1) ดวย A-1

][x IA =จาก( eliminate matri A I )

[ ] [ ]

1 1 1

1 1; (2)

I

I x x

A AA A

A A− −

⇐=

= = →

คณ (1) ดวย A 1 ( eliminate matrix A I )1][I x A−=จะได[ ] [ ]; (2)I x xA A= = → ][I x Aจะได

1][x A−=นนคอ

Page 10: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

195. Inverse Matrix (cont.)

EX. #1 จงหา A-1 ดวยกรรมวธ Gauss-Jordan5. Inverse Matrix (cont.)

Step 3 Eliminate สปส เหนอแนว diagonal เปน 0 1 1

2 1A

⎡ ⎤= ⎢ ⎥−⎣ ⎦

Step 3. Eliminate สปส. เหนอแนว diagonal เปน 0 Step 3.1 Eliminate a12

[ ]1

2

2 1 0 1 / 3 1 / 3

0 1 2 / 1 /3 3

r rX

r⇑ ⇑ ⇑

− ⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦nSol จาก A[x] = I ซง [x] = A-1

[ ] 1

2

1 1 1 0

2 1 0 1

rX

r

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦

1[ ]I X A−⇑ ⇑ ⇑

1/ 3 1 / 3⎡ ⎤[ ]1 #1 / 3 1 / 3

2 / 3 1 / 3A x− ⎡ ⎤

∴ = = ⎢ ⎥−⎣ ⎦Step 1. Forward Eliminate A U Step 1.1 Eliminate a21

[ ]1 1

1 2 22

1 1 1 0

0 3 2 1

r rX

r r r

→ ←

→ ←

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥− −⎣ ⎦ ⎣ ⎦

21 1: ?

1 1 1 / 3 1 / 3

Recheck A A I− =

⎡ ⎤ ⎡ ⎤= ⎢ ⎥ ⎢ ⎥1 2 2⎣ ⎦ ⎣ ⎦

⎡ ⎤ ⎡ ⎤

Step 2. Scale diagonal of matrix U to 1 2 1 2 / 3 1 / 3

1.

0I OK

⎢ ⎥ ⎢ ⎥− −⎣ ⎦ ⎣ ⎦

⎡ ⎤= =⎢ ⎥[ ]1 1

2 2/ 3

1 1 1 0

0 1 2 / 3 1/ 3

r rX

r r

→ ←

→ ←

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦

0 1.I OK⎢ ⎥⎣ ⎦

205.1 การหา Inverse matrix ดวยกรรมวธ Gauss-Jordan (cont.)5. ve se at Gauss Jo da (co t.)

EX. #2 จงหา A-1 ดวยกรรมวธ Gauss-Jordan Step 1.2 Eliminate a32⎡ ⎤⎡ ⎤1 1 1

0 10 25A

=⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

[ ]1

2

1

2

1 1 1

0 10 25

0 0 95

1 0 0

0 1 0

20 3 1

r

r

r

x r

→ −

→⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦20 10 0⎢ ⎥⎣ ⎦nSol จาก A[x] = I ซง [x] = A-1

2 3 33 0 0 95 20 3 1r r r←→⎢ ⎥+ −⎢ ⎥⎣ ⎦ ⎣ ⎦Step 2. Scale diagonal of matrix U to 1

⎡ ⎤

[ ]1

2

1 1 1

0 10 25

1 0 0

0 1 0

r

x r

− ←

←⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥

[ ]1

2

1

2

/ 1

/ 10

1 1 1 1 0 0

0 1 2.5 0 0.1 0

r

r

r

x r

→ −

⎡ ⎤⎢ ⎥⎡ ⎤⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥[ ] 2

320 10 0 0 0 1 r←⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

St 1 F d Eli i t A U

[ ]2

3

2

3/ 95 0 0 1 20 3 195 95 95

r r←→ −⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦⎢ ⎥⎣ ⎦

Step 1. Forward Eliminate A U Step 1.1 Eliminate a21, a31

⎡ ⎤⎡ ⎤Step 3.1 Eliminate a13, a23

Step 3. Eliminate สปส. เหนอแนว diagonal เปน 0 75 3 1−⎡ ⎤

⎢ ⎥

[ ]1

2

1

2

20

1 1 1 1 0 0

0 10 25 0 1 0

0 30 20 20 0 1

r

r

r

x r

→ −

→⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦[ ]

1 3

2 32.5

95 95 951 1 050 2 2.50 1 0

95 95 95

r r

r r x

→ −−→

⎢ ⎥− ⎡ ⎤ ⎢ ⎥⎢ ⎥ ⎢ ⎥− =⎢ ⎥ ⎢ ⎥⎢ ⎥1 3 320 0 30 20 20 0 1r r r←→ − −⎢ ⎥− ⎢ ⎥⎣ ⎦ ⎣ ⎦

3

95 95 950 0 1

20 3 195 95 95

r → −⎢ ⎥⎢ ⎥⎣ ⎦ ⎢ ⎥⎢ ⎥⎣ ⎦

Page 11: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

215.1 การหา Inverse matrix ดวยกรรมวธ Gauss-Jordan (cont.)5. ve se at Gauss Jo da (co t.)

11 1 0 75 3 11

r←− −⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥

QUIZ # จงหา A-1 ดวยกรรมวธ Gauss-Jordan[ ] 2

3

0 1 0 50 2 2.5

0 0 1 20

195

3 1

x r

r

−⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥⎢ ⎥ −⎢ ⎥⎣ ⎦ ⎣ ⎦

1 0 0

2 1 0A =⎡ ⎤⎢ ⎥⎢ ⎥

Step 3.2 Eliminate a12

⎡ ⎤

5 4 1⎢ ⎥⎢ ⎥⎣ ⎦

[ ]1 2 1

2 2

1 0 0 25 1 3.5

0 1 0 50 2 2.5195

3 1

r r r

r x r

→ ←

→ ←

+ ⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦3 30 0 1 20 3 1r r→ ←⎢ ⎥ −⎢ ⎥⎣ ⎦ ⎣ ⎦

25 1 3.51

−⎡ ⎤⎢ ⎥1 50 2 2.5

20

1[ ]95

3 1

x A Ans− −⎢ ⎥∴ = = ⎢ ⎥−⎢ ⎥⎣ ⎦

225.2 การหาคารากของระบบสมการดวยการทา Inverse Matrix5. ส ve se at

การแก Linear system equation ดวยการประยกตใชหลกการ Inverse matrix ของระบบสมการ (n equations , n unknowns) สามารถกระทาไดดงน

11 12 1 1 1na a a x b⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥

…11 12 1

21 22 2

1 1

2 2

n

nSystem of Equation

a a a x b⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⇒ =⎨ ⎬ ⎨ ⎬⎢ ⎥⋅ ⋅ ⋅ ⎪ ⎪ ⎪ ⎪⎢ ⎥

……

1 2 1 1n n nn n nn n n na a a x b

× × ×

⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭…

[ ] { } { }M t i F A X B⇒

[ ] [ ] [ ] { } [ ] { }1 1

1 1 1

n n n nn n n n n nmultiply by A A AA X B

× × ×

− − −

× × ×⇒ =

[ ] { } { }1 1n n n n

Matrix From A X B× × ×

⇒ =

1 1n n

[ ] [ ]( ){ } [ ] { }1 1

1 1n n nn n n n nA AA X B

× ×

× × ×

−⇒ =

[ ] { } [ ] { }1

1 1n n nn n nAI X B

× ××

×⇒ =

{ } [ ] { } ( )1 1

1'; 0

n nn niSol sn t Singular matriAt n xu io X A AB

×× ×∴ ⇒ = ≠

Page 12: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

235.2 Inverse Matrix (cont.)

EX. #1 แกระบบสมการดวยการ Inverse Matrix5.2 Inverse Matrix (cont.)

1 #3

1 1 1/ 3 1 / 31

2 1 2 / 3 1 / 3A− =

− −⎡ ⎤ ⎡ ⎤∴ = ⎢ ⎥ ⎢ ⎥

⎣ ⎦ ⎣ ⎦1

2

1 1 1

2 1 0

x

x⎧ ⎫⎡ ⎤ ⎧ ⎫=⎨ ⎬ ⎨ ⎬⎢ ⎥−⎣ ⎦ ⎩ ⎭⎩ ⎭

3 2 1 2 / 3 1 / 3− − −⎣ ⎦ ⎣ ⎦

11 12 22 121

21 22 21 1111 22 21 12

1a a a aA A

a a a aa a a a−⎡ ⎤ ⎡ ⎤

= ⇒ =⎢ ⎥ ⎢ ⎥−−

⎣ ⎦ ⎣ ⎦−nSol จาก {x} = [A]-1 {B}

[ ]( )( )T

cof Aadj A

21 22 21 1111 22 21 12a a a aa a a a⎣ ⎦ ⎣ ⎦

วธท 2. หา A-1 ดวยกรรมวธ Gauss-Jordanจาก A[x] = I ซง [x] = A-1

Step 1. หา A-1

[ ]1 ( )( ) cof Aadj AA

A A− = =

จาก A[x] = I ซง [x] = A[ ] 1

2

1 1 1 0

2 1 0 1

rX

r

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦1A Gauss Jordan− ⇒ −

T

2⎣ ⎦ ⎣ ⎦

[ ]1 1

1 2 22

1 1 1 0

0 3 2 1

r rX

r r r

→ ←

→ ←

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥− −⎣ ⎦ ⎣ ⎦

วธท 1. หา A-1 จาก [ ]1 ( )( )T

cof Aadj AA

A A− = = [ ]1 1

2 2/ 3

1 1 1 0

0 1 2 / 3 1 / 3

r rX

r r

→ ←

→ ←

⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦( 1) (2) 1 2

( )(1) (1) 1 1

cof A ⇒ =− − −⎡ ⎤ ⎡ ⎤

⎢ ⎥+

⎢ ⎥−⎣ ⎦ ⎣

−− ⎦+ [ ]1 2

2

1 0 1 / 3 1 / 3

0 1 2 / 3 1 / 3

r rX

r

− ⎡ ⎤ ⎡ ⎤=⎢ ⎥ ⎢ ⎥−⎣ ⎦ ⎣ ⎦

[ ] ; 3#1 1

( ) ( )2 1

Tadj A cof A A= = −

− −⎡ ⎤= ⎢ ⎥−⎣ ⎦

[ ]1 #1 / 3 1 / 3

2 / 3 1/ 3A x− ⎡ ⎤

∴ = = ⎢ ⎥−⎣ ⎦

245.2 Inverse Matrix (cont.)5.2 Inverse Matrix (cont.)

Step 2. หาคาตอบของระบบสมการ EX. #2 แกระบบสมการดวยการ Inverse Matrixจาก {x} = [A]-1 {B}

{ } [ ] { }1 1 / 3 1 / 3 1x A B

− ⎡ ⎤ ⎧ ⎫= = ⎨ ⎬⎢ ⎥

1 1 1 0

0 10 25 90

x

y

−⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪{ } [ ] { }

2 2 2 12 / 3 1 / 3 0

1/ 3 0

2 / 3 0

x A B× ×

⎨ ⎬⎢ ⎥−⎣ ⎦ ⎩ ⎭+⎧ ⎫

= ⎨ ⎬+⎩ ⎭

3 3 3 1 3 120 10 0 80z× × ×

⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

nSol จาก { } [A]-1 {B}1

1

2

22 / 3 0

1/ 3##

2 / 3

xAns

x

×

⎧ ⎫ ⎧ ⎫∴ =⎨ ⎬ ⎨ ⎬

⎩ ⎭

+⎩

Sol จาก {x} = [A] 1 {B}จาก ตย. กน.

1 1 1 25 1 3.5− −⎡ ⎤⎡ ⎤2 2 / 3x ⎩ ⎭⎭⎩1

1 1 1 25 1 3.510 10 25 50 2 2.595

20 10 0 20 3 1

A A−= −⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥ ⇒ = ⎢ ⎥⎢ ⎥

⎢ ⎥ −⎢ ⎥⎣ ⎦ ⎣ ⎦⎣ ⎦ ⎣ ⎦

{ } [ ] { }1

25 1 3.5 01

50 2.5 9095

2x A B−

⎡ ⎤ ⎧ ⎫⎪ ⎪⎢ ⎥= = ⎨ ⎬⎢ ⎥⎪ ⎪

3 3 3 1

9520 80

2

13

x× ×

⎢ ⎥⎪ ⎪

⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎨ ⎬ ⎨ ⎬

⎭⎢ ⎥−⎣ ⎦ ⎩

4 ##

2

y A sn

z

⎪ ⎪ ⎪ ⎪∴ =⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪⎩ ⎭ ⎩ ⎭

Page 13: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

256. การแกระบบสมการ ดวยกรรมวธ LU Decomposition 6. ส U eco pos t o

LU Decomposition เปนกรรมวธแกระบบสมการ โดยทาการแยกเมตรกซสมประสทธ [A] ออกเปนเมตรกซ L และ เมตรกซ U (Lower & Upper Triangular matrix)

จาก [ ]{ } { } (1)A x B= →จาก [ ]{ } { } (1)A x B →

ถาแยก [ ] [ ][ ]11 12 13 11 12 130 0

0 0 )

1

21 (A l

a a a

L U a a a

u a u

u u=

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⇒ = →⎢ ⎥ ⎢ ⎥ ⎢ ⎥ถาแยก [ ] [ ][ ] 21 22 23

31

22 2

32 33

3

33

21

31 32

0 0

0 0

)21

1

(A l

l

L U a a a

a a

u u

a ul

= ⇒ = →⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

แทน (2) ใน (1) จะไดแทน (2) ใน (1) จะได[ ] [ ]{ }( ) { }L U x B=

[ ]{ } { } (3)L y B= →

แก (3) หา {y} (ใชการแทนคาแบบไปขางหนา)แก (3) หา {y} (ใชการแทนคาแบบไปขางหนา)จากนนหาคาตอบของระบบสมการ {x} จาก (ใชการแทนคาแบบยอนกลบ)

[ ]{ } { } (4)U x y= →

266. กรรมวธ LU Decomposition (cont.) 6. U eco pos t o (co t.)

การหา สปส. ของ เมตรกซ L และ เมตรกซ U0 01⎡ ⎤ ⎡ ⎤ ⎡ ⎤

จาก11 12 13

21 22 23

11 12 13

22 2321

0 0

0 0

0

1

1

1 0

l

l

a a a

a

u

a a

u u

u u

l

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⇒ =⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦31 32 33 331 332 01 0la a a l u⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

คานวณชดท 1 คานวณชดท 3.

11 1111 111 #a au u= → =

คานวณชดท 1.12 22 22 1221 2122 22 #

#

1

1

a au u u u

l l

l l= → = −+

+

112 12 12

13 13

2

13 13

1

1

#

#

a u u

u

a

a au

= → =

= → =

13 23 2323 23 2 32 1 11 #1a u u ul l ua= → = −+

คานวณชดท 4.13 1313 13

คานวณชดท 2. 3131 3

1212 22

2223 2

322 3 #

ll l lu

au

au

u−

= →+ =

1111

2121 2121 #

aa u

ul l= → =

1u u ul la = + +

คานวณชดท 4.

131 311

11 1

1

33 #

aa l

ul u= → =

31 3213 2

31 3

3 33

33 1 3

3

2

3

33 3 2

1

#

u u u

u

l l

l l

a

a u u

= + +

= − −

Page 14: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

276. กรรมวธ LU Decomposition (cont.) 6. U eco pos t o (co t.)

EX. #2 Solve the linear system Step 2. หา {y} จาก (3) ⎧ ⎫⎡ ⎤ ⎧ ⎫1 1 1 0

0 10 25 90

x

y

−⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

1

2

0

90

1

0 1

0 0

0

y

y

⎧ ⎫⎡ ⎤ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥

nSol

3 3 3 1 3 120 10 0 80z× × ×⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭ 3 8020 3 1 y⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭⎩ ⎭

1 0 0y⎧ ⎫ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪ ⎪ ⎪จาก [ ]{ } { }

[ ] [ ]{ }( ) { }

(1)

(2)

A

L U

x B

x B

=

=

→2

3 1 2

90 90

80 20 3 190

y

y y y

⎪ ⎪ ⎪ ⎪ ⎪ ⎪= =⎨ ⎬ ⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪ ⎪ ⎪− − −⎩ ⎭⎩ ⎭⎩ ⎭[ ] [ ]{ }( ) { }

[ ]{ } { }

( )

(3)

U

L

x

y B=

3 ⎩ ⎭⎩ ⎭⎩ ⎭

Step 3. หา {x} จาก (4) 01 1 1 x⎡ ⎤ ⎧ ⎫ ⎧ ⎫−

Step 1. แยก [A] = [L][U] [ ]{ } { }: (4)USo x y= →

0

90

19

1 1 1

10 25

95

0

0 00

x

y

z

⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥ −⎣ ⎦ ⎩ ⎭ ⎩ ⎭−p [ ] [ ][ ]

1

0 1

1 1 1

0 10 25

1 1 1

10 2

0 0

0 0 5

−⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥ ⎢ ⎥

−19950 00 z⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

2

4 #

x⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎨ ⎬ ⎨ ⎬0 1

20 3 1

0 10 25

20 10 0

10 20 0

0 0

5

95⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦−

4 #

2

y

z

∴ =⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪⎩ ⎭ ⎩ ⎭

28สรป: Non-Homogeneous Linear System Equationส : No o oge eous ea Syste quat o

[ ] [ ] [ ] [ ] [ ]0M t i f A X B B[ ] [ ] [ ] [ ] [ ]1 1; 0

m n n mMatrix from A X B B

× × ×⇒ = ≠

Case of System Gauss EliminationThe MethodsCramer’s Rule Inverse Matrix

m ≠ nUnique Solution

m = n ∞ Solution**

No Solution** (บอกได) (บอกไมได) (บอกไมได)** A i Si l i ( |A| 0 )** : A is Singular matrix ( |A|=0 )

Page 15: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

29การหาคารากของระบบสมการ: ดวยการวนทาซา (Iteration)ส : ( te at o )

1. Jacobi Iteration Method ใ กรรมวธคานวณซาของ Jacobi ใชแนวคดเดยวกนกบกรรมวธ Simple Fixed-point iteration

ของการหาคารากของสมการตวเดยว (ในการศกษากอนหนา) คอFixed-Point Iteration

จาก f = f(x)

S t i+1 ( i) ป

Jacobi Iteration: Linear system

เรมตนSet: xi+1 = g(xi) แลวคานวณดงรป

1 1 11 2, , ..., nx x xเดาคา เรมตน

คานวณ 11 12 1 1 1na a a

a a a

x b

x b⎧ ⎫ ⎧ ⎫⎡ ⎤⎪ ⎪ ⎪ ⎪⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥

…จาก

1x ( )

( )11

11 1 12 2 1

12 2 21 1 2

1

1

...

...

i i in n

i i in n

a

a

b a x a x

b a x a x

x

x

+

+

⎧ ⎫⎧ ⎫ − − −⎪ ⎪⎪ ⎪ ⎪ ⎪⎪ ⎪ ⎪ ⎪⎪ ⎪ − − −⎪ ⎪ ⎪ ⎪=⎨ ⎬ ⎨ ⎬

21 22 2

1 2

2 2n

n n nn n n

a a a

a a a

x b

x b

⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥⋅ ⋅ ⋅ ⎪ ⎪ ⎪ ⎪⎢ ⎥ ⎪ ⎪ ⎪ ⎪⎣ ⎦ ⎩ ⎭ ⎩ ⎭

………

( )1i ix g x+ =( )

22

11 1 ( 1) ( 1)

1...

nn

i iin n n n n nn

a

ab a x a xx +

− −

=⎨ ⎬ ⎨ ⎬⎪ ⎪ ⎪ ⎪⎪ ⎪ ⎪ ⎪⎪ ⎪ ⎪ ⎪− − −⎪ ⎪ ⎪ ⎪⎩ ⎭ ⎩ ⎭

1ix +

ลเขา ?ไม 1 1 1i i ix x x+ + +

หยดใช

ไม 1 2, , ..., nx x x

301. Jacobi Iteration Method (cont.)1. Jacobi Iteration Method (cont.)

EX. #1 Solve the system by Jacobi Iteration method3 0 1 0 2 7 85 3x x⎧ ⎫ ⎧ ⎫⎡ ⎤ ⎧ ⎫ ⎧ ⎫1 1

2 2

3 3

3 0.1 0.2 7.85 3

0.1 7 0.3 19.3 2.5

0.3 0.2 10 71.4 7

x x

x exact solution x

x x

− − ⎧ ⎫ ⎧ ⎫⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎢ ⎥− = − ⇒ = −⎨ ⎬ ⎨ ⎬ ⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪−⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭⎩ ⎭ ⎩ ⎭3 3⎣ ⎦ ⎩ ⎭ ⎩ ⎭⎩ ⎭ ⎩ ⎭

{ } { }2 3 1 31 1

1 21 17.85 0.1 0.2 19.3 0.1 0.33 7

;i ii i i in x x x xSol x x+ + − −= + + = +⇒ ⇒

{ }11

3 21 71.4 0.3 0.2

10i i ix xx + − +⇒ =

Iter No. x1 x2 x3 εa-x1(%) εa-x2

(%) εa-x3(%)

1 0 0 0 - - -2 2.61667 -2.75714 7.14000 100 100 1003 3.00076 -2.48852 7.00636 12.800 10.794 1.9074 3.00081 -2.49974 7.00021 0.001 0.449 0.0885 3.00002 -2.50000 6.99998 0.026 0.011 0.0036 3.00000 -2.50000 7.00000 0.001 0.000 0.0007 3.00000 -2.50000 7.00000 4.221E-05 4.488E-05 1.066E-05

Page 16: 00-2/1 Li E ti S tLinear Equation System ระบบสมการเชิงเส้นeng.sut.ac.th/me/box/1_55/425207/02-2_1 linear equation system.pdf · 9 3. Gauss Elimination

31การหาคารากของระบบสมการ: ดวยการวนทาซา (Iteration)ส : ( te at o )

2. Gauss-Seidel Method กรรมวธของ Gauss-Seidel จะคลายกบกรรมวธของ Jacobi แตตางกนตรงท Gauss-Seidel จะ

Update คาใหมทนท โดยจะนาคาทไดไปคานวณทนท ดงรป

11 12 13 1 1a a a x b

a a a x b

⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪⎢ ⎥ =⎨ ⎬ ⎨ ⎬⎢ ⎥จาก

เรมตน

1 1 11 2 3, ,x x xเดาคา เรมตน

21 22 23 2 2

31 32 33 3 3

a a a x b

a a a x b

=⎨ ⎬ ⎨ ⎬⎢ ⎥⎪ ⎪ ⎪ ⎪⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭

จาก

( )11 1 12 132 3

1i i ib a ax xx + = − −

คานวณ

1

( )

( )

1

1 1

1 12 1311

2 21 2322

2 1

2 3

3

1i i i

b a aa

b a a

x xx

xa

x x+ += − −

( )

( )

11 1 12 13

112 3

1

1

i i ib a aa

x xx + = − − ( )22

3 31 323

1 13

3

11 2

1i i ib a a xa

x x+ + += − −

( )

( )

1 12 21 23

222 1

1 11

3

1

1

i i

i i

i

i

b a a xa

x x+ +

+ + +

= − −ลเขา ?

ไม 1 1 11 2 3, ,i i ix x x+ + +

( )3 31 323

1 13

3

11 2

1i i ib a a xa

x x+ + += − −

หยดใช

322. Gauss-Seidel Method (cont.)2. Gauss Seidel Method (cont.)

EX. #1 Solve the system by Gauss-Seidel method3 0 1 0 2 7 85 3⎧ ⎫ ⎧ ⎫⎡ ⎤ ⎧ ⎫ ⎧ ⎫1 1

2 2

3 3

3 0.1 0.2 7.85 3

0.1 7 0.3 19.3 2.5

0.3 0.2 10 71.4 7

x x

x exact solution x

x x

− − ⎧ ⎫ ⎧ ⎫⎡ ⎤ ⎧ ⎫ ⎧ ⎫⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎢ ⎥− = − ⇒ = −⎨ ⎬ ⎨ ⎬ ⎨ ⎬ ⎨ ⎬⎢ ⎥ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪−⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭⎩ ⎭ ⎩ ⎭3 30.3 0.2 10 71.4 7x x⎢ ⎥⎣ ⎦ ⎩ ⎭ ⎩ ⎭⎩ ⎭ ⎩ ⎭

{ } { }1 1 121 2 1 33

1 17.85 0.1 0.2 19.3 0.1 0.33 7

;i ii ii in x x xx x xSol + + +− −⇒ = + + = +⇒

{ }1 1 113 2

3 7

1 71.4 0.3 0.210

i i ix x x+ + +−= +⇒

Iter No x x x ε (%) ε (%) ε (%)Iter No. x1 x2 x3 εa-x1(%) εa-x2

(%) εa-x3(%)

1 0 0 0 - - -2 2 61667 2 79452 7 00561 100 100 1002 2.61667 -2.79452 7.00561 100 100 1003 2.99056 -2.49962 7.00029 12.5023 11.7977 0.07604 3 00003 2 49999 7 00000 0 3158 0 0145 0 00424 3.00003 -2.49999 7.00000 0.3158 0.0145 0.00425 3.00000 -2.50000 7.00000 0.0011 0.0005 1.01E-05