Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

FINITE ELEMENT METHOD

(BDA 31003)

Ch 1-2: Matrix Algebra


Topics to Discuss
Matrix definition and notation
Definition
Transpose
Symmetric Matrix
Unit Matrix

Matrix Operations
Addition
Multiplication
Inverse

Orthogonal Matrix
Solution of Simultaneous Equations
2
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.

𝑎11 𝑎12 ⋯ 𝑎1n


𝑎21 𝑎22 ⋯ 𝑎2n
𝑎 = ⋮ ⋮ . ⋮
𝑎𝑚1 𝑎𝑚2 ⋯ 𝑎𝑚𝑛 Row m

Column n

3
Example Matrix Definition

Rectangular matrix 5 3 −3 2
𝑀 = 2x4
−6 5 4 −19

5 3 −3
Square matrix 𝐶 = 5 4 −19 3x3
2 4 −3

Row matrix 𝐵 = 5 3 −3 1x3

Vector
5 5
Column matrix (Vector) 𝐹 = 3 = 3
3x1
−3 −3
4
Transpose Matrix

The transpose matrix is obtained by


interchanging rows and columns.
𝑇
𝑎𝑖𝑗 = 𝑎𝑗𝑖

5 3 −3 5 5 2
𝐶 𝑇 = 3
𝐶 = 5 4 −19 4 4
−3 −19 −3
2 4 −3
Diagonal
unchanged

5
Transpose Matrix
in OO/LO Calc Spreadsheet

Prepare data

Insert function
TRANSPOSE
Select the array data
Prepare area for result
OK
To show
The result
6
Transpose Matrix
in MS Excel

Prepare data

Insert function
TRANSPOSE PRESS F2
Select the array data
then

Ctrl + Shift + Enter

Prepare area for result


7
Transpose Matrix
in FreeMat / Matlab

8
Symmetric Matrix

If a square matrix is equal to its transpose,


It is called a symmetric matrix
𝑇
𝑎 = 𝑎
5 3 −3
5 3 −3 𝑇
𝐶 = 3 4 8
𝐶 = 3 4 8
−3 8 −3
−3 8 −3

𝐶 is a symmetric matrix
9
Unit Matrix

The unit (or Identity) matrix [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
all other elements equal to zero.
1 0 0
For example, the 3 x 3 unit matrix
is given by
𝐼 = 0 1 0
0 0 1
10
Addition of Matrices
Matrices of the same order can be added together by
summing corresponding elements of the matrices.
Subtraction is performed in similar manner
Matrices of unlike order cannot be added or subtracted.

[𝑐𝑖𝑗 ] = [𝑎𝑖𝑗 ] + [𝑏𝑖𝑗 ] = [𝑏𝑖𝑗 ] + [𝑎𝑖𝑗 ]

−1 2
[𝐴] = 0 4
−3 2 [𝐶] = [𝐴] + [𝐵] =
0 3
1 2
[𝐵] =
3 1
11
Addition of Matrices
in FreeMat / Matlab

12
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 cumulative [A][B]≠[B][A]

𝑐𝑖𝑗 = ෍ 𝑎𝑖𝑒 𝑏𝑒𝑗


𝑒=1
2 1
𝐴 =
3 2
4 −2
1 −1 𝐶 = 𝐴 𝐵 =
𝐵 = 7 −3
2 0
13
Multiplication of Matrices
in OO/LO Calc Spreadsheet

Prepare data
[A] and [B]

Prepare area for result Insert function MMULT


Select the array data [A] and [B]

OK
To show
The result

14
Multiplication of Matrices
in FreeMat

15
Inverse of a Matrix

The inverse of a matrix is a matrix such that


−1 −1
𝐴 𝐴 = 𝐴 𝐴 = 𝐼

−1
𝐶 𝑇 𝑎𝑑𝑗 𝐴
𝐴 = =
∣𝐴∣ ∣𝐴∣

𝐶 : Cofactor of matrix 𝐴

∣ 𝐴 ∣ : Determinant of matrix 𝐴
16
Cofactor Matrix

−1 3 −2
[𝐴] = 2 −4 2
0 4 1

−4 2 2 2 2 −4
+∣ ∣ −∣ ∣ +∣ ∣
4 1 0 1 0 4 −12 −22 8
3 −2 −1 −2 −1 3
𝐶 = −∣ ∣ +∣ ∣ −∣ ∣ = −11 −1 4
4 1 0 1 0 4
3 −2 −1 −2 −1 3 −2 −2 −2
+∣ ∣ −∣ ∣ +∣ ∣
−4 2 2 2 2 −4

17
Adjoint and Determinant Matrix

Continuing the previous result

−12 −11 −2
𝑇
𝑎𝑑𝑗 𝐴 = 𝐶 = −2 −1 −2
8 4 −2

𝑑𝑒𝑡 𝐴 =∣ 𝐴 ∣
−4 2 2 2 2 −4
= −1 +1 ∣ ∣ + 3 −1 ∣ ∣ − 2 +1 ∣ ∣
4 1 0 1 0 4
= −10

18
Determinant of a Matrix
in OO Calc Spreadsheet
Insert function MDETERM Select the array data [A]

Prepare data [A] and place for result

OK
To show
The result

19
Determinant of a Matrix
in FreeMat

20
Inverse of a Matrix
in OO Calc Spreadsheet

Insert function MINVERSE Select the array data [A]

Prepare data [A]

Prepare area for result

OK
To show
The result

21
Inverse of a Matrix
in FreeMat

22
Orthogonal Matrix
A matrix [A] is an orthogonal matrix if

−1 𝑇
𝐴 = 𝐴

cos 60deg sin 60deg 0.5 0.87


𝐴 = =
−sin 60deg cos 60deg −0.87 0.5

𝑇 0.5 −0.87 −1 0.5 −0.87


𝐴 = 𝐴 =
0.87 0.5 0.87 0.5

Matrix [A] is an orthogonal matrix


23
Solution Methods
of 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

24
Linear Equations in Matrix
𝑎11 𝑥1 + 𝑎12 𝑥2 + ⋯ + 𝑎1n 𝑥𝑛 = 𝑐1
𝑎21 𝑥1 + 𝑎22 𝑥2 + ⋯ + 𝑎2n 𝑥𝑛 = 𝑐2

𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛 𝑥𝑛 = 𝑐𝑛

The equation can be written in Matrix

𝑎11 𝑎12 ⋯ 𝑎1n 𝑥1 𝑐1


𝑎21 𝑎22 ⋯ 𝑎2n 𝑥2 𝑐2
⋮ ⋮ . ⋮ ⋮ = ⋮
𝑎𝑛1 𝑎𝑛2 ⋯ 𝑎𝑛𝑛 𝑥𝑛 𝑐𝑛
or 𝐾 𝑥 = 𝐹 then 𝑥 = 𝐾 −1 𝐹
25
Example Problem 2.1

−𝑥1 + 3𝑥2 − 2𝑥3 = 2


2𝑥1 − 4𝑥2 + 2𝑥3 = 1
4𝑥2 + 𝑥3 = 3
a. Write the simultaneous equation in Matrix
b. Find the unknown variables x1, x2 and x3 from the
following equations

−1 3 −2 𝑥1 2
2 −4 2 𝑥2 = 1
0 4 1 𝑥3 3
or 𝐾 𝑥 = 𝐹 −1
then 𝑥 = 𝐾 𝐹
26
Solving Simultaneous Equation
in OO Calc Spreadsheet

𝑥1 4.1
The result: 𝑥2 = 1.1
𝑥3 −1.4 27
Solving Simultaneous Equation
in FreeMat

28
Cramer's Rule Method
−1 3 −2 𝑥1 2 2 3 −2
2 −4 2 𝑥2 = 1 ∣ 1 −4 2 ∣
0 4 1 𝑥3 3 𝑥1 = 3 4 1 = 4.1
−1 3 2
∣ 2 −4 2 ∣
0 4 1

−1 2 −2 −1 3 2
∣ 2 1 2 ∣ ∣ 2 −4 1 ∣
𝑥2 = 0 3 1 = 1.1 𝑥3 = 0 4 3 = 1.4
−1 3 2 −1 3 2
∣ 2 −4 2 ∣ ∣ 2 −4 2 ∣
0 4 1 0 4 1
29
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

𝑎𝑖𝑘 𝑘 = 1,2, ⋯ , 𝑛 − 1
𝑎𝑖𝑗 = 𝑎𝑖𝑗 − 𝑎𝑘𝑗 𝑖 = 𝑘 + 1, ⋯ , 𝑛
𝑎𝑘𝑘
𝑗 = 𝑘, ⋯ , 𝑛 + 1
𝑛
1
𝑥𝑖 = 𝑎𝑖,𝑛+1 − ෍ 𝑎𝑖𝑟 𝑥𝑟
𝑎𝑖𝑖
𝑟=𝑖+1
30
Example Problem 2.2
2𝑥1 + 2𝑥2 + 1𝑥3 = 9
2𝑥1 + 1𝑥2 = 4
1𝑥1 + 1𝑥2 + 1𝑥3 = 6
a. Find the unknown variables x1, x2 and x3 from the
following equations, using Gauss Elimination Method
b. Verify the result in Speadsheet
Since the order of matrix is n=3, the index for solving this problem

𝑛=3
𝑘 = 1,2
𝑖 = 2,3
𝑗 = 1,2,3,4
31
𝑘 = 1,2, ⋯ , 𝑛 − 1 The running index will be (for n=3)
k=1
𝑖 = 𝑘 + 1, ⋯ , 𝑛 i=2
𝑗 = 𝑘, ⋯ , 𝑛 + 1 j = 1 to 4
Calculate aij
i.e. a21 a22 a23 a24

i=3
j = 1 to 4
Calculate aij
i.e. a31 a32 a33 a34

k=2
i=3
j = 2 to 4
Calculate aij
i.e. a32 a33 a34

32
The running index will be (for n=3)
2 2 1 k=1
𝑎 = 2 1 0 i=2
j = 1 to 4
1 1 1 Calculate aij
i.e. a21 a22 a23 a24

𝑎𝑖𝑘 𝑎21 = 𝑎21 − 𝑎11


𝑎21
=2−2
2
=0
𝑎𝑖𝑗 = 𝑎𝑖𝑗 − 𝑎𝑘𝑗 𝑎11 2
𝑎𝑘𝑘
𝑎21 2
𝑎22 = 𝑎22 − 𝑎12 =1−2 = −1
𝑎11 2

𝑎21 2
𝑎23 = 𝑎23 − 𝑎13 =0−1 = −1
𝑎11 2

𝑎21 2
𝑎24 = 𝑎24 − 𝑎14 =4−9 = −5
𝑎11 2
33
2 2 1 i=3
j = 1 to 4
𝑎 = 2 1 0 Calculate aij
1 1 1 i.e. a31 a32 a33 a34

𝑎𝑖𝑘 𝑎31 = 𝑎31 − 𝑎11


𝑎31
=1−2
1
=0
𝑎𝑖𝑗 = 𝑎𝑖𝑗 − 𝑎𝑘𝑗 𝑎11 2
𝑎𝑘𝑘
𝑎31 1
𝑎32 = 𝑎32 − 𝑎12 =1−2 =0
𝑎11 2

𝑎31 1
𝑎33 = 𝑎33 − 𝑎13 =1−1 = 0.5
𝑎11 2

𝑎31 1
𝑎34 = 𝑎34 − 𝑎14 =6−9 = 1.5
𝑎11 2
34
2 2 1 k=2
i=3
𝑎 = 2 1 0 j = 2 to 4
1 1 1 Calculate aij
i.e. a32 a33 a34

𝑎32 0
𝑎𝑖𝑘 𝑎32 = 𝑎32 − 𝑎22 = 0 − −1 =0
𝑎𝑖𝑗 = 𝑎𝑖𝑗 − 𝑎𝑘𝑗 𝑎22 −1
𝑎𝑘𝑘
𝑎32 0
𝑎33 = 𝑎33 − 𝑎23 = 0.5 − −1 = 0.5
𝑎22 −1

𝑎32 0
𝑎34 = 𝑎34 − 𝑎24 = 1.5 − −5 = 1.5
𝑎22 −1

35
𝑛
1
𝑥𝑖 = 𝑎𝑖,𝑛+1 − ෍ 𝑎𝑖𝑟 𝑥𝑟
𝑎𝑖𝑖
𝑟=𝑖+1

1 1
𝑥3 = 𝑎34 − 0 = 1.5 = 3
𝑎33 0.5

1 1
𝑥2 = 𝑎24 − 𝑎23 𝑥3 = −5 − −1 3 =2
𝑎22 −1

1 1
𝑥1 = 𝑎14 − 𝑎12 𝑥2 − 𝑎13 𝑥3 = 9−2 2 −1 3 =1
𝑎11 2
36
Verification using inverse matrix in OO Spreadsheet

37
Gauss Siedel Iteration Method

Gauss-Siedel method is based on iterative approach

1
𝑥1 = 𝑐1 − 𝑎12 𝑥2 − 𝑎13 𝑥3 − ⋯ − 𝑎1𝑛 𝑥𝑛
𝑎11
1
𝑥2 = 𝑐2 − 𝑎21 𝑥1 − 𝑎23 𝑥3 − ⋯ − 𝑎2𝑛 𝑥𝑛
𝑎22

1
𝑥𝑛 = 𝑐𝑛 − 𝑎𝑛1 𝑥1 − 𝑎𝑛2 𝑥2 − ⋯ − 𝑎𝑛,𝑛−1 𝑥𝑛−1
𝑎𝑛𝑛

𝑐𝑖
A good initial guess 𝑥𝑖 =
𝑎𝑖𝑖
38
Example Problem 2.3

4𝑥1 − 𝑥2 = 2
−𝑥1 + 4𝑥2 − 𝑥3 = 5
−𝑥2 + 4𝑥3 − 𝑥4 = 6
−𝑥3 + 2𝑥4 = −2

a. Find the unknown variables x1, x2 and x3 from the


following equations, using Gauss-Siedel Iteration approach
b. Verify the result in Spead sheet

39
𝑐𝑖
4 −1 0 0 2 A good initial guess 𝑥𝑖 =
−1 4 −1 0 5 𝑎𝑖𝑖
𝑎 = 𝑐 = 𝑥1 = 0.5 𝑥3 = 1
0 −1 4 −1 6
0 0 −1 2 −2 𝑥2 = 1 𝑥4 = −1

First trial Second trial


1 1
𝑥1 = 2 + 𝑥2 = 0.75 𝑥1 = 2 + 1.68 = 0.992
4 4
1 1
𝑥2 = 5 + 𝑥1 + 𝑥3 = 1.68 𝑥2 = 5 + 0.992 + 1.672 = 1.899
4 4
1 1
𝑥3 = 6 + 𝑥2 + 𝑥4 = 1.672 𝑥3 = 6 + 1.899 ± 0.16 = 1.944
4 4
1 1
𝑥4 = −2 + 𝑥3 = −0.16 𝑥4 = −2 + 1.944 = −0.028
2 2
40
41
Thank you

42

You might also like