ITP3902 DMS Lec 4 Matrix Arithmetic

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Lecture 4 Matrix Arithmetic

Lecture 4
Matrix Arithmetic

ITP3902 Discrete Mathematics & Statistics Page 1


Lecture 4 Matrix Arithmetic

Introduction to Matrix Arithmetic

A matrix is a set of real or complex numbers (or


elements) arranged in rows and columns to form a
rectangular array.
A matrix having m rows and n columns is an m x n
(read ‘m by n’ or ‘m cross n’) matrix and is referred to
as having order m x n.
A matrix can be represented explicitly by enclosing
the array within large square brackets.

ITP3902 Discrete Mathematics & Statistics Page 2


Lecture 4 Matrix Arithmetic

Example 1 is a 2 x 3 matrix,
where 1, 1, 3, 4, 6, 9 are the elements of the
matrix.
Example 2 is a 4 x 3 matrix.
Example 3 (5 2 7 1) is a 1 x 4 matrix ( a row vector)

Example 4 is a 2 x 1 matrix ( a column vector)

ITP3902 Discrete Mathematics & Statistics Page 3


Lecture 4 Matrix Arithmetic

Short Questions

So matrix is of order ___________ 2 x 3

and matrix is of order __________ .

4x2

ITP3902 Discrete Mathematics & Statistics Page 4


Lecture 4 Matrix Arithmetic

What is Matrix?
• in the i-th row and the j-th column of a matrix A is
called an element or an entry.
• Any digital image can be represented by a matrix
e.g.
1 1 1 1 1
sampling  
 0 1 0 1 0
 0 1 0 1 0
 
• All image processing techniques involve matrix operations
• When using Photoshop, your computer is working with
matrices! LCD monitor shows images to you in the form of
matrices!
ITP3902 Discrete Mathematics & Statistics Page 5
Lecture 4 Matrix Arithmetic

Matrix Notation
Each element in a matrix has its own particular
‘address’ or location which can be defined by a system
of double suffixes: the first indicates the row, and the
second indicates the column.
Example 5
A=

ITP3902 Discrete Mathematics & Statistics Page 6


Lecture 4 Matrix Arithmetic

Short Questions

The locations of the elements 66, –89 and 71 can be


stated as respectively.
The elements on the locations 31, 42 and 23 are
respectively.
22, 12, 43

12, 32, 88

ITP3902 Discrete Mathematics & Statistics Page 7


Lecture 4 Matrix Arithmetic

Further, a whole matrix can be denoted by a single


general element enclosed in square brackets, or by a
single letter printed in bold type.
Example 6

can be denoted by or by A.
Similarly, can be denoted by or by X.

ITP3902 Discrete Mathematics & Statistics Page 8


Lecture 4 Matrix Arithmetic

Equal Matrices

Two matrices are said to be equal if all the


corresponding elements are equal. Therefore, the two
matrices must also be of the same order.

Example 7
 1 3  8 3
Let A    and B    , then A  B.
 3 8  3 8

ITP3902 Discrete Mathematics & Statistics Page 9


Lecture 4 Matrix Arithmetic

Addition and Subtraction of Matrices


Only matrices of the same order can be added or
subtracted. The result from the sum or difference is
then determined by adding or subtracting the
corresponding elements.
Example 8

 7 9 5   42 34 21  49 43 26 
       
 3 6 3   13 16 18   16 22 21 

 5 0   2 3   3  3
       
  2 1    6 6   4  5
ITP3902 Discrete Mathematics & Statistics Page 10
Lecture 4 Matrix Arithmetic

Exercise
 3 1  1  2 6 1
Let A    and B   . Calculate
0  2 4  10  3 6 
A + B and A – B.

Solution
5 7 0
 
10  5 10 
 1  5  2
 
  10 1  2 

ITP3902 Discrete Mathematics & Statistics Page 11


Lecture 4 Matrix Arithmetic

Multiplication of Matrices

Scalar multiplication
Example 9

 7 9 5   28 36 20 
4  
 3 6 3   12 24 12 
i.e. k[aij] = [kaij]
This also means that we can take a common factor out
of every element.

ITP3902 Discrete Mathematics & Statistics Page 12


Lecture 4 Matrix Arithmetic

Multiplication of Two Matrices

Two matrices can be multiplied together only when the


number of columns in the matrix on the left equals the
number of rows in the matrix on the right.
e.g A is a m x n matrix and B is a n x p matrix then

A B  C
(m  n) (n  p)  (m  p)

where C is a new matrix of size m x p


n
cij  ai1b1 j  ai 2b2 j    ainbnj   aik bkj
k 1
for all i=1,2,…,m ; j=1,2,…,p
ITP3902 Discrete Mathematics & Statistics Page 13
Lecture 4 Matrix Arithmetic

Multiplication of Two Matrices

ITP3902 Discrete Mathematics & Statistics Page 14


Lecture 4 Matrix Arithmetic

Multiplication of Two Matrices


Example 10
A is a 2 x 3 matrix and B is a 3 x 3 matrix,
therefore, C = A X B where C is a 2 x 3 matrix .
Find C, elements by elements.
 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 3 2 1  1 3 2   c21 c22 c23 
 
c11= a11 b11 + a12 b21 + a13 b31
= 1 x 1 + 2 x 0 + 3 x (–1)
= –2
ITP3902 Discrete Mathematics & Statistics Page 15
Example 10 (Cont’d.)

 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 3 2 1  1 3 2   c21 c22 c23 
 

c12= a11 b12 + a12 b22 + a13 b32 = 1x0 + 2x2 + 3x3
= 13
 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 c21 c22 c23 
 3 2 1  1 3 2 
 
c13= a11 b13 + a12 b23 + a13 b33 = 1x(-2) + 2x1 + 3x2
=6

Discrete Mathematics Page16


Example 10 (Cont’d.)

 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 3 2 1  1 3 2   c21 c22 c23 
 
c21= a21 b11 + a22 b21 + a23 b31 = 3x1 + 2x0 + 1x(-1)
=2
 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 c21 c22 c23 
 3 2 1  1 3 2 
 
c22= a21 b12 + a22 b22 + a23 b32 = 3x0 + 2x2 + 1x3
=7

Discrete Mathematics Page17


Example 10 (Cont’d.)

 1 0  2
 1 2 3    c11 c12 c13 
A    B   0 2 1  C  AB   
 3 2 1  1 3 2   c21 c22 c23 
 
c = a b + a b + a b = 3x(-2) + 2x1 + 1x2
23 21 13 22 23 23 33

= -2

Plug in the computed elements back to C, we have

  2 13 6 
C  AB   
 2 7  2
Discrete Mathematics Page18
Lecture 4 Matrix Arithmetic

Exercise

 1 5
   8 4 3
 2 7    
 3 4   2 5 8 This step
  can be
 1 8  5  2 1 4  5  5 1 3  5  8  omitted.
 
  2  8  7  2 2  4  7  5 2  3  7  8
 3 8  4  2 3 4  4  5 3 3  4  8
 
 18 29 43 
 
  30 43 62 
 32 32 41
 
ITP3902 Discrete Mathematics & Statistics Page 19
Lecture 4 Matrix Arithmetic

Exercise
3 1  2 6 
If A    and B    then
0  2 10  3 

A + B =  5 7 
10  5 
 

AB =  16 15 
 
  20 6 

3A = 9 3 
 
 0  6

ITP3902 Discrete Mathematics & Statistics Page 20


Lecture 4 Matrix Arithmetic

Matrix Multiplication is not Commutative


Example 11
If and then

then and
Therefore AB ≠ BA .
In general CD ≠ DC for any matrices C and D

ITP3902 Discrete Mathematics & Statistics Page 21


Lecture 4 Matrix Arithmetic

Transpose ( 轉置 ) of a Matrix

If M is a matrix, its transpose is denoted by MT.


Example 12

If .

i.e. the 1st row becomes the 1st column,


the 2nd row becomes the 2nd column, etc.

ITP3902 Discrete Mathematics & Statistics Page 22


Lecture 4 Matrix Arithmetic

Square Matrix
A square matrix is one in which
no. of rows = no. of columns
Example 13

 1 0  9 2 4
A    B 
 2 4   2 3 6

Square matrix Not a square matrix

ITP3902 Discrete Mathematics & Statistics Page 23


Lecture 4 Matrix Arithmetic

Symmetric Matrix

A square matrix M is symmetric if M = MT


Example 14
If then

Therefore, M is a symmetric matrix.

ITP3902 Discrete Mathematics & Statistics Page 24


Lecture 4 Matrix Arithmetic

Diagonal Matrix

A diagonal matrix M is a square matrix such that all of


the off-diagonal elements are equal to 0.
Example 15

diagonal

ITP3902 Discrete Mathematics & Statistics Page 25


Lecture 4 Matrix Arithmetic

Unit Matrix (Identity Matrix)

A unit matrix I is a square matrix with all elements in


the diagonal equal to 1 and all off-diagonal elements
equal to 0.
Example 16

Unit matrix behaves like the unit factor in ordinary


algebra where IM = MI = M

ITP3902 Discrete Mathematics & Statistics Page 26


Lecture 4 Matrix Arithmetic

Null Matrix (Zero Matrix)

A null matrix N is a matrix with all its elements equal


to 0.

Example 17

Null matrix behaves like the zero in ordinary algebra


where NM = MN = N

ITP3902 Discrete Mathematics & Statistics Page 27

You might also like