lecture 2 - matrix algebra

35
FINITE ELEMENT METHOD FINITE ELEMENT METHOD (BDA 4033) Lecture Module 2: Matrix Algebra Dr. Waluyo Adi Siswanto Universiti Tun Hussein Onn Malaysia

Upload: hanif-rashid

Post on 01-May-2017

240 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 2 - Matrix Algebra

FINITE ELEMENT METHODFINITE ELEMENT METHOD(BDA 4033)

Lecture Module 2: Matrix Algebra

Dr. Waluyo Adi SiswantoUniversiti Tun Hussein Onn Malaysia

Page 2: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 2

Topics to Topics to DiscussDiscuss

Matrix definition and notationMatrix definition and notation Definition

Transpose

Symmetric Matrix

Unit Matrix

Matrix OperationsMatrix Operations Addition

Multiplication

Inverse

Orthogonal MatrixOrthogonal Matrix

Solution of Simultaneous EquationsSolution of Simultaneous Equations

Page 3: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 3

Matrix Definition

A matrix is an m x n array of numbers arranged in m rows and n columns.

Matrix is then described as being of order m x n.

[a]=[a11 a12 ⋯ a1n

a21 a22 ⋯ a2n

⋮ ⋮ . ⋮

am1 am2 ⋯ amn]

Row m

Column n

Page 4: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 4

Example Matrix Definition

[M ]=[ 5 3 −3 2−6 5 4 −19]Rectangular matrix

[C ]=[5 3 −35 4 −192 4 −3 ]Square matrix

[B ]=[ 5 3 −3 ]Row matrix

[F ]=[53

−3]={53

−3}Column matrix (VectorVector)

VectorVector

2 x 4

3 x 3

1 x 3

3 x 1

Page 5: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 5

Transpose Matrix

The transpose matrix is obtained by interchanging rows and columnsinterchanging rows and columns.

[a ij ]T=[ a ji]

[C ]=[5 3 −35 4 −192 4 −3 ] [C ]

T=[

5 5 23 4 4

−3 −19 −3]Diagonalunchanged

Page 6: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 6

Transpose Matrixin OO Spreadsheet

Prepare data

Prepare area for result

Insert functionTRANSPOSETRANSPOSESelect the array data

OKOKTo showThe result

Page 7: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 7

Symmetric Matrix

If a square matrix is equal to its transposeequal to its transpose,

It is called a symmetric matrix

[ a ]=[ a ]T

[C ]=[5 3 −33 4 8

−3 8 −3] [C ]T=[

5 3 −33 4 8

−3 8 −3][C ] is a symmetric matrix

Page 8: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 8

Unit Matrix

The unitunit (or IdentityIdentity) matrix [I][I] is such that

The unit matrix is always a square matrix of any possible order with each element of the main diagonal is one and each element of the main diagonal is one and all other elements equal to zeroall other elements equal to zero.

[a] [I ]=[ I ][a ]=[a ]

[I ]=[1 0 00 1 00 0 1]For example, the 3 x 3 unit matrix is given by

Page 9: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 9

Addition of Matrices

Matrices of the same order can be added together by summing corresponding elements of the matricessumming corresponding elements of the matrices.

Subtraction is performed in similar manner

Matrices of unlike order cannot be added or subtracted.

[cij ]=[a ij][bij ]=[bij ][a ij ]

[A]=[−1 2−3 2] [B ]=[ 1 2

3 1] [C ]=[A][B]=[0 40 3]

Page 10: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 10

Multiplication of Matrices

The number of the columns of the first matrix must be equal to the number of rows of the second matrix.

Matrix multiplication is not cumulativeis not cumulative [A][B]≠[B][A]

[cij ]=∑e=1

n

a iebej

[A]=[2 13 2] [B ]=[ 1 −1

2 0 ] [C ]=[A] [B]=[ 4 −27 −3]

Page 11: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 11

Multiplication of Matricesin OO Calc Spreadsheet

Prepare data[A] and [B]

Prepare area for result Insert function MMULTMMULTSelect the array data [A] and [B]

OKOKTo showThe result

Page 12: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 12

Inverse of a Matrix

The inverse of a matrix is a matrix such that

[A]−1

[A]=[A] [A]−1

=[I ]

[A]−1

=[C ]

T

∣A∣=adj [ A]

∣A∣

[C ]

∣A∣

: Cofactor of matrix

: Determinant of matrix

[A]

[A]

Page 13: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 13

Cofactor Matrix

[A]=[−1 3 22 −4 20 4 1]

[C ]=[∣−4 2

4 1∣ −∣2 20 1∣ ∣2 −4

0 4 ∣−∣3 −2

4 1 ∣ ∣−1 −20 1 ∣ −∣−1 3

0 4∣∣ 3 −2

−4 2 ∣ −∣−1 −22 2 ∣ ∣−1 3

2 −4∣]=[−12 −22 8−11 −1 4−2 −2 −2]

Page 14: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 14

Adjoint and Determinant Matrix

Continuing the previous result

adj [A]=[C ]T=[−12 −11 −2

−2 −1 −28 4 −2 ]

det [ A]=∣A∣=−11∣−4 24 1∣3−1∣2 2

0 1∣−21∣2 −40 4 ∣=−10

Page 15: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 15

Determinant of a Matrixin OO Calc Spreadsheet

Prepare data [A] and place for result

Insert function MDETERM MDETERM Select the array data [A]

OKOKTo showThe result

Page 16: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 16

Inverse of a Matrixin OO Calc Spreadsheet

Prepare data [A]

Insert function MINVERSE MINVERSE Select the array data [A]

OKOKTo showThe result

Prepare area for result

Page 17: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 17

Orthogonal Matrix

A matrix [A] is an orthogonal matrix if

[A]−1=[ A]T

[A]=[ cos 60deg sin 60deg−sin 60deg cos 60deg]=[ 0.5 0.87

−0.87 0.5 ]

[A]T=[ 0.5 −0.87

0.87 0.5 ] [A]−1

=[ 0.5 −0.870.87 0.5 ]

Matrix [A] is an orthogonal matrix

Page 18: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 18

Solution Methodsof Simultaneous Linear Equations

Representation of linear equations in Matrix Matrix Inversion Method Classical Methods

Cramer's Rule Method Gaussian Elimination Method Gauss-Siedel Iteration Method

Page 19: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 19

Linear Equations in Matrix

a11 x1a12 x2⋯a1n xn=c1

a21 x1a22 x2⋯a2n xn=c2

⋮an1 x1an2 x2⋯ann xn=cn

The equation can be written in Matrix

[a11 a12 ⋯ a1n

a21 a22 ⋯ a2n

⋮ ⋮ . ⋮an1 an2 ⋯ ann

]{x1

x2

⋮xn

}={c1

c2

⋮cn

}[K ]{x }={F }or {x }=[K ]

−1{F }then

Page 20: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 20

Example Problem 2.1

a. Write the simultaneous equation in Matrixb. Find the unknown variables x1, x2 and x3 from the following equations

−x13 x2−2 x3=22 x1−4 x22 x3=1

4 x2 x3=3

[−1 3 −22 −4 20 4 1 ]{

x1

x2

x3}={

213}

[K ]{x }={F }or {x }=[K ]−1 {F }then

Page 21: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 21

Solving Simultaneous Equationin OO Calc Spreadsheet

{x1

x2

x3}={

4.11.1

−1.4}The result:

Page 22: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 22

Cramer's Rule Method

[−1 3 −22 −4 20 4 1 ]{

x1

x2

x3}={

213}

x1=

∣2 3 −21 −4 23 4 1 ∣

∣−1 3 22 −4 20 4 1∣

=4.1

x2=

∣−1 2 −22 1 20 3 1 ∣

∣−1 3 22 −4 20 4 1∣

=1.1 x3=

∣−1 3 22 −4 10 4 3∣

∣−1 3 22 −4 20 4 1∣

=1.4

Page 23: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 23

Gauss Elimination

Gauss Elimination is based on triangularisation of the coefficient matrix and evaluation of the unknowns by back-substitution starting from the last equation

The form can be summarised in general form by

a ij=aij−akjaikakk

k=1,2,⋯, n−1i=k1,⋯ , nj=k ,⋯, n1

x i=1a ii ai , n1− ∑

r=i1

n

a ir xr

Page 24: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 24

Example Problem 2.2

2 x12 x21 x3=92 x11 x2=4

1 x11 x21 x3=6

a. Find the unknown variables x1, x2 and x3 from the following equations, using Gauss Elimination Methodb. Verify the result in Speadsheet

n=3k=1,2i=2,3j=1,2,3,4

Since the order of matrix is n=3, the index for solving this problem

Page 25: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 25

The running index will be (for n=3)k = 1

i = 2j = 1 to 4

Calculate aij

i.e. a21

a22

a23

a24

i = 3

j = 1 to 4Calculate a

ij

i.e. a31

a32

a33

a34

k = 2i = 3

j = 2 to 4Calculate a

ij

i.e. a32

a33

a34

k=1,2,⋯, n−1i=k1,⋯ , nj=k ,⋯, n1

Page 26: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 26

The running index will be (for n=3)k = 1

i = 2j = 1 to 4

Calculate aij

i.e. a21

a22

a23

a24

a ij=aij−akjaikakk

[a]=[2 2 12 1 01 1 1]

a21=a21−a11

a21

a11

=2−222=0

a22=a22−a12

a21

a11

=1−222=−1

a23=a23−a13

a21

a11

=0−122=−1

a24=a24−a14

a21

a11

=4−9 22=−5

Page 27: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 27

i = 3

j = 1 to 4Calculate a

ij

i.e. a31

a32

a33

a34

a ij=aij−akjaikakk

[a]=[2 2 12 1 01 1 1]

a31=a31−a11

a31

a11

=1−212=0

a32=a32−a12

a31

a11

=1−212=0

a33=a33−a13

a31

a11

=1−112=0.5

a34=a34−a14

a31

a11

=6−912=1.5

Page 28: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 28

k = 2i = 3

j = 2 to 4Calculate a

ij

i.e. a32

a33

a34

a ij=aij−akjaikakk

[a]=[2 2 12 1 01 1 1]

a32=a32−a22

a32

a22

=0−−10

−1=0

a33=a33−a23

a32

a22

=0.5−−10

−1=0.5

a34=a34−a24

a32

a22

=1.5−−50

−1=1.5

Page 29: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 29

x i=1a ii ai , n1− ∑

r=i1

n

a ir xr

x3=1a33

a34−0 =1

0.51.5=3

x2=1a22

a24−a23 x3=1

−1[−5−−13]=2

x1=1a11

a14−a12 x2−a13 x3 =12[9−2 2−13]=1

Page 30: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 30

Verification using inverse matrix in OO Spreadsheet

Page 31: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 31

Gauss Siedel Iteration Method

Gauss-Siedel method is based on iterative approach

x1=1a11

c1−a12 x2−a13 x3−⋯−a1n xn

x2=1a22

c2−a21 x1−a23 x3−⋯−a2n xn

xn=1ann

cn−an1 x1−an2 x2−⋯−an , n−1 xn−1

A good initial guess x i=cia ii

Page 32: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 32

Example Problem 2.3

4x1− x2=2−x14x2−x3=5−x24x3−x4=6−x32x4=−2

a. Find the unknown variables x1, x2 and x3 from the following equations, using Gauss-Siedel Iteration approachb. Verify the result in Speadsheet

Page 33: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 33

A good initial guess x i=cia ii

[a]=[4 −1 0 0

−1 4 −1 00 −1 4 −10 0 −1 2

] {c }={256

−2} x1=0.5 x2=1 x3=1 x4=−1

x1=142 x2=0.75

x2=145x1x3=1.68

x3=146x2x4=1.672

x4=12−2 x3=−0.16

First trial Second trial

x1=1421.68=0.992

x2=1450.9921.672=1.899

x3=1461.899±0.16=1.944

x4=12−21.944=−0.028

Page 34: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 34

Page 35: Lecture 2 - Matrix Algebra

BDA 4033 Dr. Waluyo Adi Siswanto 35