Discrete Structure For Computer Science
Discrete Structure For Computer Science
The ith row of A is [a
i1
, a
i2
, a
i3
, a
in
]; 1 s i s m
The jth column of A is a
1j
a
2j
; 1 s j s n
a
3j
a
mj
We say that A is a matrix m x n. If m = n, then A
is a square matrix of order n, and a
11
, a
22
, a
33
,
..a
nn
form the main diagonal of A.
a
ij
which is in the ith row and jth column, is said
to be the i, jth element of A or the (i, j) entry
of A, often written as A = [a
ij
].
Ex 2:
A = 8 0 0 0
0 3 0 0
0 0 7 0
0 0 0 1
A square matrix A = [a
ij
], for which every entry
off the main diagonal is zero, that is a
ij
= 0 for i
= j, is called a diagonal matrix.
Two m x n matrices A and B, A = [a
ij
] and B =
[b
ij
], are said to be equal if a
ij
= b
ij
for 1 s i s m,
1 s j s n; that is, if corresponding elements are
the same.
Ex 3:
A = a 5 3 B = 1 5 x
2 7 -1 y 7 -1
3 b 0 3 4 0
So, if A = B, then a = 1, x = 3, y = 2, b = 4.
Matrix summation
If A = [a
ij
] and B = [b
ij
] are m x n matrices, then
the sum of A and B is matrix C = [c
ij
], defined by
c
ij
= a
ij
+ b
ij
; 1 s i s m, 1 s j s n.
C is obtained by adding the corresponding
elements of A and B.
A = 1 5 3 B = 2 0 3
2 7 -1 6 1 3
3 4 0 -3 1 9
C = 3 5 6
8 8 4
0 5 9
The sum of the matrices A and B is defined only when
A and B have the same number of rows and the same
number of columns (same dimension).
A matrix in when all of its entries are zero is
called zero matrix, denoted by 0.
Theorems involved in summation :
A + B = B + A.
(A + B) + C = A + (B + C).
A + 0 = 0 + A = A.
Matrices Product
If A = [a
ij
] is an m x p matrix and B = [b
ij
] is a p x
n matrix, then the product of A and B, denoted
AB, will produce the m x n matrix C = [c
ij
],
defined by
c
ij
= a
i1
b
1j
+ a
i2
b
2j
+ + a
ip
b
pj
;
1 s i s n, 1 s j s m
That is, elements a
i1
, a
i2
, .. a
ip
from ith row of A
and elements b
1j
, b
2j
, .. b
pj
from jth column of B,
are multiplied for each corresponding entries
and add all the products.
Ex 5:
A = 2 3 -4 B = 3 1
1 2 3 -2 2
5 -3
2 x 3 3 x 2
AB = 2(3) + 3(-2) + -4(5) 2(1) + 3(2) + -4(-3)
1(3) + 2(-2) + 3(5) 1(1) + 2(2) + 3(-3)
= 6 6 20 2 + 6 + 12
3 4 + 15 1 + 4 9
= -20 20
14 -4
2 x 2
If A is an m x p matrix and B is a p x n matrix, in
which AB will produce m x n, BA might be
produce or not depends on:
n = m, then BA cannot be produced.
n = m, p = m @ n, then we can get BA but the
size will be different from AB.
n = m= p, A = B, then we can get BA, the size
of BA and AB is the same, but AB = BA.
n = m = p, A = B, then we can get BA, the size
of BA and AB is the same, and AB = BA.
Identity matrix
Let say A is a diagonal matrix n x n. If all entries on its
diagonal are 1, it is called identity matrix, ordered n,
written as I.
Ex 7:
1 0 1 0 0 1 0 0 0
0 1 0 1 0 0 1 0 0
0 0 1 0 0 1 0
0 0 0 1
Theorems involved are:
A(BC) = (AB)C.
A(B + C) = AB + AC.
(A + B)C = AC + BC.
IA = AI = A.
Transposition Matrix
If A = [a
ij
] is an m x n matrix, then A
T
= [a
ij
]
T
is a n x
m matrix, where
a
ij
T
= a
ji
; 1 s i s m, 1 s j s n
It is called transposition matrix for A.
Ex 8:
A = 2 -3 5 A
T
= 2 6
6 1 3 -3 1
5 3
Theorems involved are:
(A
T
)
T
= A
(A + B)
T
= A
T
+ B
T
(AB)
T
= B
T
A
T
Matrix A = [a
ij
] is said to be symmetric if A
T
= A, that
is a
ij
= a
ji
,
A is said to be symmetric if all entries are
symmetrical to its main diagonal.
Ex 9:
A = 1 2 -3 B = 1 2 -3
2 4 5 2 4 0
-3 5 6 3 2 1
Symmetric Not Symmetric, why?
Boolean Matrix and Its Operations
Boolean matrix is an m x n matrix where all of its entries
are either 1 or 0 only.
There are three operations on Boolean:
a)Join by
Given A = [a
ij
] and B = [b
ij
] are Boolean matrices with the
same dimension, join by A and B, written as A v B, will
produce a matrix C = [c
ij
], where
c
ij
= 1 if a
ij
= 1 OR b
ij
= 1
0 if a
ij
= 0 AND b
ij
= 0
b)Meet
Meet for A and B, both with the same dimension, written
as A . B, will produce matrix D = [d
ij
] where
d
ij
= 1 if a
ij
= 1 AND b
ij
= 1
0 if a
ij
= 0 OR b
ij
= 0
Ex 10: A =1 0 1 B = 1 1 0
0 1 1 0 0 1
1 1 0 0 1 0
0 1 0 1 1 0
A v B = 1 1 1 A . B = 1 0 0
0 1 1 0 0 1
1 1 0 0 1 0
1 1 0 0 1 0
c) Boolean product
If A = [a
ij
] is an m x p Boolean matrix, and B = [b
ij
] is a
p x n Boolean matrix, we can get a Boolean product
for A and B written as A B, producing C, where:
c
ij
= 1 if a
ik
= 1 AND b
kj
= 1; 1 s k s p.
0 other than that
It is using the same way as normal matrix product.
+
+
Ex 11:
A = 1 0 0 0 B = 1 1 0
0 1 1 0 0 1 0
1 0 1 1 1 1 0
3 x 4 0 0 1
4 x 3
A B = 1 + 0 + 0 + 0 1 + 0 + 0 + 0 0 + 0 + 0 + 0
0 + 0 + 1 + 0 0 + 1 + 1 + 0 0 + 0 + 0 + 0
1 + 0 + 1 + 0 1 + 0 + 1 + 0 0 + 0 + 0 + 1
A B = 1 1 0
1 1 0
1 1 1
3 x 3
+
Exercise 3:
A = 1 0 0 0 B = 0 1 0 0 C = 0 0 1 0
0 1 1 0 0 0 1 1 1 0 0 0
0 0 0 1 0 1 0 1 1 1 0 0
1 1 0 0 0 0 1 0 1 1 1 0
Find:
a) A v B
b) A . B
c) A B
d) A v C
e) A . C
f) A C
g) B v C
h) B . C
i) B C
+
+