yasser f. o. mohammad assiut university egypt. previously in nm introduction to nm solving single...

16
Yasser F. O. Mohammad Assiut University Egypt

Upload: posy-henderson

Post on 31-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Yasser F. O. MohammadAssiut University

Egypt

Page 2: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Previously in NM Introduction to NM Solving single equation System of Linear Equations

Vectors and Matrices Solving Upper Triangular Form Matrices

4 5 6 7 8 9 10-10

-8

-6

-4

-2

0

2

4

6

8

10

Page 3: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Introduction

3

Solving three equations in three unknowns

828153

01062

132

zyx

zyx

zyx

11198

242

132

zy

zy

zyx

33

242

132

z

zy

zyx

21)1(3)1(2

,12)1(42

,133

xx

yy

zz

Page 4: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Gauss Elimination (Main Idea)Convert the system to UTF then solve it

The following operations do not change the system or the solution of (AX=B):Interchanges: changing order

Scaling: Multiplying an equation with a constant

Replacement: replacing an equation with the sum of itself with a nonzero multiple of another

jij RmRR

j jR mR

, ,i i j jT R R R R T

1

.

.i

M

R

RA

R

Page 5: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Basic Gauss Elimination ProcedureWrite in matrix-vector form : Ax = b

8

0

1

b,

28143

1062

321

A

8|28143

0|1062

1|321

combine in theaugmented

matrix

• Basic Gaussian elimination procedure

jij RmRR

Page 6: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Pivot

6

At the kth stage of Gaussian elimination procedure, the appropriate multiple of the kth row is used to reduce each of the entries in the kth column below the kth row to zero

kth row : pivot rowkth column : pivot columnelement akk : pivot element

• ex : If at 3rd elimination procedure,

nnnn

n

n

n

baa

baa

baaa

baaaa

|00

|

|00

|0

|

3

3333

222322

11131211

Page 7: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Example

7

The sum of the voltage drops around a closed loop is zero

V=IR

0V1

0V2

200V3

20R1 25R 3

30R 5 10R 2

10R 4 1i

2i

3i

200)(10)(1030

0)(20)(1025

0)(10)(20

13233

12322

3121

iiiii

looprightlower

iiiii

looprightupper

iiii

loopleft

Page 8: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

System

200501010

0105520

0102030

321

321

321

iii

iii

iii

200

0

0

b,

501010

105520

102030

A

0V1

20R1 25R 3

30R 5 10R 2

10R 4 1i

2i

3i

Page 9: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

SolutionStep 1

The pivot is a11 = 30 Multiply the first row by 20/30 and add it to the second row Multiply the first row by 10/30 and add it to the third row

200

0

0

b,

3/1403/500

3/503/1250

102030

A

Page 10: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

SolutionStep 2

The pivot is a22 = 125/3 Multiply the second row by 2/5 and add it to the third row to get

.

200

0

0

b,

4000

3/503/1250

102030

A

Page 11: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Solution• Step 3: By back substitution,

330/)5)(10()2)(20(0

,23/125/)5)(3/50(0

,540/200/

11

31321211

22

32322

3333

a

xaxabx

a

xabx

abx

Page 12: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Pivoting Strategies1. No pivotingUse as the pivot element in step i.

May fail even if a solution exists

iia

1

2

0 1 5

1 0 2

x

x

Page 13: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Pivoting Strategies2. Trivial Pivoting

Will find a solution if one exists

May cause large rounding error if aii is small

0

0 and 0 and ii ii

iji ii ji

a if apivot

a if a a j i

Page 14: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Pivoting Strategies3. Partial PivotingFind the row with maximum value in the

pivot column and use it as the pivot row (exchange with current pivot)

Page 15: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Pivoting Strategies4. Scaled Partial PivotingFind the row with the maximum relative

value in the pivot column and use it as the pivot row

Page 16: Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices

Matlab: Simplest Implementation % Gaussian Elimination function which can solve k systems of the form

Ax=b1,....,Ax=bk at the same time

function x = Gauss( A , b ) [n,k1] = size(A); [n1,k] = size(b); x = zeros(n,k); for i=1 : n-1 m = -A(i+1:n , i) / A(i,i); A(i+1:n , : ) = A(i+1:n , : ) + m*A(i,:); b(i+1:n , : ) = b(i+1:n , : ) + m*b(i,:); end x(n,:) = b(n,:) ./ A(n,n); for i=n-1 : -1 : 1 x(i,:) = ( b(i,:) - A(i , i+1:n) * x(i+1:n , : ) ) ./ A(i,i); end