GENG 300 NUMERICAL METHODS
Dr. Mohammad Aman Ullah
WHAT IS VECTORS
9HFWRULVDRQHGLPHQVLRQD ODUUD\RI QXPEHUV
([DPSOHV
ª º
URZYHFWRU> @ FROXPQYHF WRU««»»
«¬»¼
ªº ª º ª º ª º
« » «» « » « »
,GHQWLW\ YHFWRUV H « » H « » H « » H « »
« » « » «» « »
« » « » « » « »
¬ ¼ ¬ ¼ ¬ ¼ ¬¼
4
MATRICES
0 DWUL[ DWZRGLPHQVLRQD ODUUD\RI QXPEHUV
([DPSOHV
ª º
ª º « »
]HURPDWUL[ « LGHQWLW\
PDWUL[
»¼ « »
¬ Banded «¬ »¼
ª
«
º Matrix ª º
»» « »
GLDJRQDO « 7ULGLDJRQD O« »
« » « »
« » « »
¬ ¼ ¬ ¼ 5
MATRICES
([DPSOHV
ªD D D D º
ª º « D »
D D
V\PPHWULF«« »» XSSHUWULDQJXODU « »
« D D »
«¬ »¼ « »
¬ D ¼
ª D º
«D D »
ORZHUWULDQJXODU « »
«D D D »
« »
D D
¬ D D ¼ 6
WHAT IS A MATRIX?
| A matrix is usually given a “name” so that it can
be referred to easily, e.g.
ª º
X « »
« »
«¬ »¼
| By referring to ;we are therefore referring to the
table of numbers contained within ;
| By convention, the name of the matrix is either
underlined or in bold
7
DIMENSION OF A MATRIX
| The dimension of a matrix is determined by the
number of its rows and the number of its columns
3 columns
ª º
X « » 3 rows
« »
«¬ »¼
GLP X u
| In general, for a matrix with m rows and n
columns
GLP X P u Q
8
DIMENSION OF A MATRIX
Matrix $ has dimension 4x4
ª º
« »
A « »
« »
« » Matrix % has dimension 3x4
¬ ¼
ª º
B « »
« »
«¬ »¼
Thus, the dimension of a matrix is determined by its number
of rows and columns
GLP X QXPEHURIURZV u QXPEHURIFROXPQV 9
THE SUBSCRIPT OF A MATRIX ELEMENT
| The subscript of a matrix element indicates its
position in the matrix
ª [ [ [QQ º
«[ [QQ »
X «
[
» [LM
« »
« »
¬ [P [P [PQ ¼
| The i indicates the row position
| The j indicates the column position
10
IDENTITY MATRIX
Identity matrix is a diagonal matrix where all elements of the main diagonal
are equal to 1
Identity matrix has properties similar to unity. That is
> , @> $@ > $ @> , @ > $@
11
TRANSPOSED MATRIX
| The transpose of a matrix $, is written as $7LQVRPH
ERRNVLWPLJKWEHZULWWHQDV $¶
| When a matrix is transposed,
y its rows becomes the columns of the transposed matrix
y its columns become the rows of the transposed matrix
| E.g. then ª º
« »
ª º AT « »
A « »
¬ ¼ « »
« »
¬ ¼
GLP A PuQ GLP A T QuP 12
ADDITION AND SUBTRACTION OF MATRICES
| Matrices can only be added or subtracted if their
dimensions are equal
| If dim($) = dim(%), then
AB DLM ELM AB DLM ELM
| If dim($) = dim(%) = dim(&), then
ABC DLM ELM FLM ABC DLM ELM FLM
13
ADDITION OF MATRICES
| Commutative Law is true (position of the
matrices with respect to the mathematical
operation does not matter)
AB BA
| Associative Law is true (the order of the
mathematical operation does not matter)
A + B + C = (A + B) + C = A + (B + C)
14
ADDITION AND SUBTRACTION (EPL EXAMPLE)
Home games
W D L
Man United 3 0 0
Man City 3 0 0
Chelsea 3 0 0
Away games
W D L
Man United 2 1 0
Man City 2 1 0
Chelsea 1 1 1
15
ADDITION AND SUBTRACTION (EPL EXAMPLE)
| Let the home games matrix be +
| Let the away games matrix be $
| Then the overall match record, represented by 2,
is given by:
O= H+A
ª º ª º ª º
O « » « » « »
« » « » « »
«¬ »¼ «¬ »¼ «¬ »¼
16
MULTIPLICATION BY A SCALAR
| A scalar is a non-matrix value
| Matrices can be multiplied by scalars
| The dimensions of the matrices do not matter
| Suppose D is a scalar and $ is a matrix
| Then
D A D DLM
| Similarly
D A E B J C D DLM E ELM J FLM
17
THE ZERO MATRIX
| The zero matrix is a matrix with all elements
equal to zero
| It is the result of the subtraction of 2 equal
matrices
| E.g.
ª º ª º ª º
« » « » « »
¬ ¼ ¬ ¼ ¬ ¼
Zero Matrix
18
MULTIPLICATION OF MATRICES
| If matrix $ has dim(m x n) and matrix % has
dim(n x p), then the product is a matrix & $%
which has
dim(m x p)
| The multiplication can only be made if $ has the
same number of columns as the number of rows
of matrix %
| The elements of the matrix & is given by:
FLN DLEN DL E N DL EN DLQ EQN
Q
¦D E
M
LM MN
19
MULTIPLICATION OF MATRICES (EXAMPLE)
ª º
ª º « » ª u u u u u u º
« » « » « u u u u u u »
¬ ¼ ¬ ¼
«¬ »¼
u u u
ª º
« »
¬ ¼
20
MULTIPLICATION OF MATRICES (EXAMPLE)
ª º
ª º « » ª u u u u u u º
« » « » « u u u u u u »
¬ ¼ ¬ ¼
«¬ »¼
u u u
ª º
« »
¬ ¼
21
MULTIPLICATION OF MATRICES (EXAMPLE)
ª º
ª º « » ª u u u u u u º
« » « » « u u u u u u »
¬ ¼ ¬ ¼
«¬ »¼
u u u
ª º
« »
¬ ¼
22
MULTIPLICATION OF MATRICES (EXAMPLE)
ª º
ª º« » ª u u u u u u º
« » « « u u u u u u »
¬ ¼ » ¬ ¼
«¬ »¼
u u u
ª º
« »
¬ ¼
| Note: The elements of each row of the left matrix
is multiplied into the elements of each column of
the right matrix and added
| The dimension of the resultant matrix is given by
the number of rows of the left matrix and the
number of columns of the right matrix 23
MULTIPLICATION OF MATRICES
| The position of the matrices matter, i.e. the
multiplication of matrices is non commutative
| In general, AB z BA
| Multiplication of matrices is associative AB C = A BC
| Multiplication of matrices is distributive
A B C AC + BC
24
THE INVERSE MATRIX
If matrix [A] is square and nonsingular, there is another matrix >$@,
Called the inverse of [A], for which
>$@>$@ >$@> $@ > , @
The inverse matrix for a 2x2 matrix can be given as:
ª D D º
>$@ «
D D D D ¬ D D »¼
25
Details will be covered in Chapter 11
MATRIX-VECTOR MULTIPLICATION
| A common occurrence is the product: Ax
where $ is a matrix and [ is a vector
ª [ º
«[ »
ª D Q º
DQ
« »
A « » x
« »
« » « »
«¬ DP DPQ »¼ ¬ [Q ¼
GLP A PuQ GLP x Q u
GLP Ax P u
26
APPLICATION OF MATRIX MULTIPLICATION
W D L
Man United 5 1 0
Man City 5 1 0
Chelsea 4 1 1
ª º
« »
| Let the “data” matrix be: X
« »
«¬ »¼
ª: º ª º
s «'» « »
| Let the “scores” vector be: « » « »
«¬ / »¼ «¬»¼
27
28
APPLICATION OF MATRIX MULTIPLICATION
| Then, the points that each team has is given by:
P = Xs
| That is,
ª º ª º ª u u u º ªº
P « » « » « u u u » «»
« »« » « » « »
«¬ »¼ «¬»¼ «¬ u u u »¼ «¬»¼
29