MCA Mathematical Foundation For Computer Application 05
MCA Mathematical Foundation For Computer Application 05
Names of Sub-Units
Introduction, Cartesian Products and Relations, Defining Functions, Types of Function Plain, Plain
Function, One–to–One Function, Onto Function, the Pigeon–hole Principle, Function Composition,
Inverse Function, Defining Relations, Properties of Relations, Computer Recognition: Zero–One
Matrices and Directed Graphs, Partial Orders: Hasse Diagrams, Equivalence Relations and Partitions
Overview
In this unit, you will learn about the Cartesian product of two sets. Further in this unit, you will
also learn the different types of relations and functions. After studying this unit, you will be able to
differentiate between one–to–one function and onto function. In the end, you will become proficient
in finding the inverse of the function and defining zero one matrix. You will also be able to draw the
directed graph and Hasse diagram for a partial order.
Learning Objectives
Learning Outcomes
https://people.ucsc.edu/~miglior/chapter%20pdf/Ch04_SE.pdf
https://www.researchgate.net/publication/332254891_Relations_and_Functions
5.1 INTRODUCTION
Relation in day to day life how to people associated with each other, i.e., whether they are parents and
their child or husband and wife or uncle and nephew or our neighbours or friends, etc. Like all persons
have some relation with each other in mathematics also two sets may be associated with each other
based on their properties.
Here, in this unit we are going to study one of the most important topics of mathematics, i.e., relations
and functions. One may confuse with the terms, relations and functions and may consider it one or the
same thing. But in reality, functions are the special type of relations that has one image only for each set
of ordered pair. Before understanding the concept of relation, you should first understand the concept
of the Cartesian product of two sets.
Note: If M has p number of elements and N has q number of elements then MXN will have pxq elements.
Here, M has 3 elements and N has 2 elements.
Therefore, the number of elements in M N = 3 2 = 6 elements.
2
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Note: Two order pair are said to be equal if and only if both the first and second element of the first
ordered pair is equal to the corresponding first and second element of the second ordered pair.
Example 1:
If (x – 5, y – 2)= (7, 11) find the value of x and y.
Solution:
Two ordered pairs will be equal only when their corresponding elements are equal.
Therefore, x – 5=7 and y–2=11
x=7 + 5 & y = 11+2
x=12 & y = 13
5.2.2 Relations
A subset of the Cartesian product of any two sets says P and Q obtained by describing a relationship
between two sets P and Q are called relation.
Note: The second element in a relation is called the image of the first element.
Example 2:
Let R be relation on Natural Numbers such that
R = {(m, n): m = 2n + 1, n ≤ 3 and n N}
R = {(1, 3), (2, 5), (3, 7)}
The set of all first elements in a relation is called the domain of the relation and the set of all second
elements in a relation is called the range of the relation.
Thus, in the above example, A = {1, 2, 3} is the domain of the relation R and the set B = {3, 5, 7} is the range
of the relation. Thus, here whole set N is not the domain and only the first elements of relation will come
under a domain. While the whole set N will come under the co–domain of the given relation.
Note: If there are m and n number of elements in the set M & N then the set MXN will have mxn numbers
of elements and the total number of relations possible = 2mn.
Example 3:
Let set P = {1, 2, 3, 4, ..................... 20}
Let R = {(p, q): p = 3q+1 and p, q P}. Write the domain, co–domain and range of the given relation. Also,
find the number of relations possible from set P to P.
Solution:
R = {(1, 4), (2, 7), (3, 10), (4, 13), (5, 16), (6, 19)}
3
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Set A Set B
7 8
8 9
9 10
Set A Set B
7
8 5
9 7
4
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
5
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
5 6
7 8
9 10
5
6 6
7 7
8 10
a p
b q
c r
6
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
a
b p
c q
7
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
f is invertible if and only if it is one and onto. If the inverse of f is denoted by f–1.
Example 7:
x7
If f and g are function from RR such that f(x) = 4x+7 and g(x) = . Show that g(x) is the inverse
4
of f(x).
Solution:
(x 7)
fog(x) = 4 +7=x–7+7=x=I
4 x
4x 7 7
gof(x) = = x = Ix
4
Note: The second element in a relation is called the image of the first element.
Example 8
Let R be a relation from AA such that f(x) =2x+1 and A = {1, 2, 3}.
Therefore, R = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
8
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Equivalence Relation: Before knowing about equivalence relation, we should first know some other
definitions.
Reflexive Relation: A relation R in a set P is said to be a reflexive relation if (p, p) R for all p
belonging to set P.
Symmetric Relation: A relation R in a set P is said to be asymmetric relation if (p, q) R implies (q,
p) R for all p, q R.
Transitive Relation: A relation R in a set P is said to be a transitive relation if (p, q) R and (q, r)
R implies (p, r) R for all p, q & r R. A relation R in a set P is said to be an equivalence relation if R
is reflexive, symmetric and transitive.
Example 11
Let P = {1, 2, 3} and R = {(a, b): a & b≤3 & a, b P}. Check whether R is equivalence Relation.
Solution
R = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}.
Here, (x, x) R for all x P. Therefore, R is reflexive.
Also, if (x, y) R (y, x) R. Therefore, R is symmetric.
Now if (x, y) & (y, z) R then (x, z) R. Therefore, R is Transitive.
Since, R is all reflexive, symmetric and transitive. Therefore, R is equivalence Relation.
14 7 8 12
P 12 9 6 5
4 1 0 6
9
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Example 13
0 1 0 0 1
M 1 0 1 1 0
0 1 0 1 0
10
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Solution
0 1 11 0 0
M N
1
1 00 01
0 1 0
1 0 0
1 0 1 0 0 0
0 0 0 1 0 1
1 0
0 1 1
Note: The order of Matrix MR will be mxn as there are m elements in set A and n elements in set B.
Let P be a set of natural numbers less than or equal to 3.
P = {1, 2, 3}
Let R1 be relation from PP such that:
R1 = {(m, n): m + n ≤ 4 where m, n P}
11
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
R1 = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (3, 1)}
Hence, MR will be 3 3 matrix where
Mij = 1 if (mi, nj) R1
= 0 if (mi, nj) R1
1 2 3
1 1 1 1
Therefore MR 2
1 1 0
3
1 0 0
5.10.6 Properties of Zero–One Matrix
Various properties of Zero–one matrix are as follows:
1. Reflexive Matrix: A square matrix of relation from set P P is said to be reflexive of (p, p) R p
P.
In a matrix it means that mii = 1 for i = 1, 2, 3, n, i.e., all diagonal elements of the square matrix
will be 1.
2. Symmetric Matrix: A square matrix of relation from set P P is said to be symmetric of (a, b) R
(b, a) R.
In a matrix, it means that mij = 1 whenever mji = 1 or M R = (MR)T, i.e., the square matrix will be
symmetric if the matrix is equal to its transpose. Transpose as we know is obtained by interchanging
the rows and columns of the matrix.
3. Transitive Matrix: A square matrix of relation from set P P is said to be transitive of (a, b) M R2
then (a, b) MR. Thus, the matrix will be transitive when MR = M R2
5.10.7 Graph
A graph is a pictorial representation of data that consist of the following two elements:
1. A finite set of points is called nodes or vertices.
2. A finite set of lines that join pair of vertices called edges.
City A City C
City B City D
EDGES City E
VERTICES OR NODES
12
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Thus, the graph is the set of order pairs of a set of vertices or nodes V and edges E. This can be denoted
as G = (V, E).
Consider the following graph given Figure 8:
d
b
c
x y
m n
Application of graph
The following points describe the applications of graph are as follows:
In computer science, the graph is used to represent the social networks on Facebook, Twitter,
Instagram, LinkedIn, etc.
Graphs are also used to represent the city–road network.
13
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
A D
B
C E
A B C D E
A 0 1 1 1
0
B 1 0 0 1
1
A C 1 0 0 1
0
D 0 1 0 1
0
E 1
1 1 1 0
The following points describe the advantages of adjacency matrix are as follows:
Easy to implement for less number of nodes.
We can determine whether two nodes are connected or not in the blink of an eye.
14
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Adjacency List: Graph may also be represented by an array of the list. N number of nodes in a graph
may be represented by n number of the list. Arrow is used to show all the vertices with which a given
vertex is connected.
Example 18
An example of adjacency list is shown in Figure 12:
A E
B
C D
A B C D /
B A D E /
C A D /
D A B C E /
E B D /
15
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
Now when aRb then b is also related to a. As both a and b have their birthday in the same year. Therefore,
the given relation is symmetric.
Now, when aRb and bRc, then aRc as a and b have a birthday in the same year and b and c have the
birthday in the same year. Hence, a and c have their birthday in the same year. Hence, the given relation
is transitive.
Therefore, this is an example of equivalence relation.
Now, let us learn about another relation called the anti–symmetric relation.
For example,
Let A = {1, 2, 3, 4, 6, 8}
Let R be the relation on set A such that (a, b) R iff a divides b a, b A.
Therefore, R = {(1, 1), (1, 2), (1, 2), (1, 3), (1, 4), (1, 6), (2, 2), (2, 4), (2, 6), (2, 8), (3, 3), (3, 6), (4, 4), (4, 8), (6, 6), (8, 8)}
Now, every element of set A divides itself. Therefore aRa a A. Thus, the given relation is reflexive.
Now, when a divides b, b does not belong to a until and unless a=b. Hence, when (a, b) R, (b, a)R a,
b A. Thus, the given relation is anti–symmetric.
Also, if a divides b and b divides c then a divides c. Thus, when (a, b)R and (b, c) R then (a, c) R.
Hence, the given relation is transitive.
Therefore, the given relation on set A is a partial order.
16
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
The partial order relations are represented by symbol which is just like less than or equal to symbol.
Another example of partial order relation is as follows:
Let A = {1, 2, 3,........................... 10} and let P be the set of all subsets of A.
Define a relation R onset P such that set M is related to set N iff M N M, N P. The given relation is
anti–symmetric as it is reflexive, anti–symmetric and transitive.
5.11.3 POSET
Any set P together partial order relation R also known as partial ordering relation on set P is called
POSET and is denoted by [P, R].
12
6 9
17
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
In Figure 13, each lower element divides the upper element connected with lines. Like 1 divide 1, 3, 6, 12
and 9. 3 divide 3, 6, 9 and 12. 6 divide 6 and 12. And 12 divide 12 only.
Solution:
R = {(1, 1), (1, 3), (1, 5), (2, 2), (2, 4), (3, 1), (3, 3), (3, 5), (4, 2), (4, 4), (5, 1), (5, 3), (5, 5)}
Now, here a A, (a, a) R as the sum of two odd or two even numbers is always even. Hence, given
relation is reflexive.
Now, if (a, b) R then (b, a) R as a sum of two natural numbers follows the property of commutative
law. Hence, the given relation is symmetric.
Now, (a, b) R and (b, c)
R then (a, c) R. Hence, the given relation is transitive.
Therefore, the given relation is an equivalence relation.
The term partition is related to an equivalence relation. Now, before understanding the concept of
partition we should first understand the concept of equivalence class which is related to the term
equivalence relation. We can find the equivalence classes for only those relations that are equivalent.
18
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Note: The elements of one partition are not related to any element of another partition.
Example 21
The 3 partition of equivalence relation are as follows:
P1 = {a, b, c}
P2 = {d}
P3 = {e, f}
Find all the elements of the equivalence relation.
Solution:
For finding all the elements of equivalence relation just find the Cartesian product of all partitions with
itself, i.e., P1X P1, P2X P2 and P3X P3.
Therefore, R = {(a, a), (a, b), (a, c), (b, a), (b, b), (b, c), (c, a), (c, b), (c, c), (d, d), (e, e), (e, f), (f, e), (f, f)}
Assume M and N be two non–empty sets. Then, set of all ordered pairs (m, n) such that m M & n
N is called the Cartesian product of sets M & N.
If M has p number of elements and N has q number of elements then MXN will have pxq elements.
If there are m and n number of elements in the set M & N then the set MXN will have mxn numbers
of elements and the total number of relations possible = 2mn.
A subset of the Cartesian product of any two sets says P and Q obtained by describing a relationship
between two sets P and Q is called relation.
The second element in a relation is called the image of the first element.
If g(x): PQ and h(y): Q R the function goh(x) =g[h(x)] is said to be composition of the function.
A relation R in a set P is called empty relation if no element of set P is related to any element of the
same set.
The relation R is said to be universal relation on set P if every element of P is related to all elements
of P.
The graph is the set of order pairs of sets of vertices or nodes V and edges E. This can be denoted as
G = (V, E).
19
JGI JAINDEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
The graph may be used to represent social networks, city–road networks, pages linked by hyperlinks
on the website, etc.
The partition of a set P defined on relation R is a collection of subsets Pi where i = 1 to k such that:
P1P2P3........................ Pk = P &
P1 P2P3 ....................... Pk =
The minimum number of partitions possible for any given set P is 1 when each element is related to
all other elements. The Cartesian product of set P to set P is one such example where each element
is related to all other elements.
The maximum number of partitions possible for any given set P with n number of elements is n
where each element is just related to itself.
5.14 GLOSSARY
Cartesian product of Sets: The set of all ordered pairs (m, n) such that m M & n N is called the
Cartesian product of sets M & N. The Cartesian product of M & N is denoted by the symbol MXN.
The Cartesian product of 3 sets: The Cartesian product of 3 sets M, N & O contains triplets such that
MXNXO = {(m, n, o): mM, nN & oO}
Relations: A subset of the Cartesian product of any two sets say P and Q obtained by describing a
relationship between two sets P and Q are called relation.
Function: A relation from set P to set Q is said to form a function if every element of set P has one
and only one image in set Q. Thus, the domain of the function is set P. Hence, if the ordered pair (p, q)
belongs to function (f) such that q is the image of p then p is called the pre–image.
One–one or injective function: A function f: P Q is said to be injective or one–one if the images of
distinct elements of P under f are distinct, i.e., if for all x, y P if f(x) = f(y) then x = y otherwise f is
said to be many–one function.
Subjective or onto function: A function f: PQ is said to be subjective or onto function if every
element of Q is the image of some element in P, i.e., for every ‘b’ P there exist ‘a’ such that f(a) = b.
Bijective Function: A function f: PQ is both one–one and onto then the function is said to be
bijective function.
Pigeon Hole Principle: The pigeon hole principle states that if there are n+1 pigeons and n boxes
then there must be at least one box such that it occupies one than one pigeon.
Equivalence Relation: A relation R in a set P is said to be an equivalence relation if R is reflexive,
symmetric and transitive.
Zero–One Matrix: A matrix in which all the elements or the entries are either zero or one is called
Zero–One Matrix.
Graph: A graph is a pictorial representation of data that consist of the following two elements:
A finite set of points is called nodes or vertices.
A finite set of lines that join pair of vertices called edges.
Partial Order: A relation R on any set P is said to be a partial order iff it is
Reflexive: i.e., every element is related to itself.
Anti–symmetric: i.e., if (a, b) R then (b, a) R until and unless a = b.
Transitive: i.e., if (a, b) R and (b, c) R then (a, c) R.
20
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Hasse Diagram: Hasse diagram also known as the ordering diagram is the graphical representation
of the relationship between the elements of POSET. Hasse diagram depicts about the order of the
relationship between the elements of POSET with an upward orientation.
Equivalence Class: Let R be an equivalence relation on set P. Then, the equivalence class for p P
(denoted by [p] and read as mod of p) is the subset of P such that:
[p] = {a: a P and aRp}. We can find the equivalence class for each member of an equivalence relation.
Partition of Equivalence Relation: The partition of a set P defined on relation R is a collection of
subsets Pi i = 1 to k such that:
P1P2P3 .......................Pk = P &
P1 P2P3....................... Pk =
2. Let set P = {1, 3, 5, 7, 9}. Define relation R on set P such that R = {(a, b): 0≤a–b≤4 & a, b P}. Find the
domain, co–domain and range of the given relation.
3. Let set P = {1, 2, 3, 4.............. 30}. Define relation R on set P such that R = {(a, b): b = 4a+1 & a, b P}. Find
the domain, co–domain and range of the given relation.
4. Let f(x) = 4x2 + 7 & g(x) = 8x + 13. Find (f+g)(x).
5. Is the following relation represent one–to–one function? Give reason to support your answer. R = {(1,
3), (2, 5), (3, 7), (4, 7), (5, 9)}
6. Let P = {1, 2, 3} and Q = {4, 5, 6}. Is the following relation represents onto function?
R = {(1, 4), (2, 6), (3, 6)}
Give a reason to support your answer.
7. If f(x) = x2 + 2 and g(x) = 7x + 10. Find fog(x).
2x 7 5x 7
8. If f and g are function from RR such that f(x) = and g(x) = Show that g(x) is the
3x 5 2 3x
21
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
inverse of f(x).
9. Let
1 0 1 1 1 0
P 0 0 1 Q 0 0 1
0 1 1 0 0 0
22
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
23
JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
Mathematical Foundation for Computer Application
11. R = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (5, 1), (5, 2)}
1 2 3 4 5
1 1 1 1 1 1
2 1 1 1 1 1
M 31 1 1 0 0
R
4 1 1 0 0 0
5 1 1 0 0 0
12.
F
D
A
E
C
B
13.
18
12 15
20
10
3 5
14. R = {(1, 1), (1, 3), (1, 5), (1, 7), (2, 2), (2, 4), (2, 6), (3, 1), (3, 3), (3, 5), (3, 7), (4, 2), (4, 4), (4, 6), (5, 1), (5, 3), (5, 5),
(5, 7), (6, 2), (6, 4), (6, 6), (7, 1), (7, 3), (7, 5), (7, 7)}
[1] = {1, 3, 5, 7}
[2] = {2, 4, 6}
24
UNIT 05: Fundamental Relations and Functions JGI JAIN
DEEMED-TO-BE UNIVERSIT Y
[3] = {1, 3, 5, 7}
[4] = {2, 4, 6}
[5] = {1, 3, 5, 7}
[6] = {2, 4, 6}
[7] = {1, 3, 5, 7}
There are two classes, i.e., {2, 4, 6} and {1, 3, 5, 7} hence two partitions.
15. R = {(2, 2), (2, 4), (2, 6), (4, 2), (4, 4), (4, 6), (6, 2), (6, 4), (6, 6), (5, 5), (11, 11), (11, 33), (33, 11), (33, 33)}
https://www.vedantu.com/maths/difference-between-relations-and-functions
http://gvpcew.ac.in/Material%203%20Units/2%20CSE%20MFCS.PDF
Research on application of graph theory and write down its application in different fields, such
as software engineering, electrical engineering, computer science, networking marketing and
chemistry.
25