Dm. Unit-2
Dm. Unit-2
Discrete Mathematics
Functions
A function , written f:A→B, is a mathematical relation where each element of a set A, called the domain ,
is associated with a unique element of another set B, called the codomain of the function.
For each element a∈A, we associate a unique element b∈B. The set of all such associations is called a
function f from A into B, denoted f:A→B, with (a,b) used to indicate the mapping f:a→b, or f(a)=b. Here
b is understood to be the image of a assigned by f. The range is the set of all image values f(a). With this
notation, a is allowed to vary over all elements in the set A.
Domain and co-domain – if f is a function from set A to set B, then A is called Domain and B is
called co-domain.
Range – Range of f is the set of all images of elements of A. Basically Range is subset of co- domain.
Image and Preimage – b is the image of a and a is the pre-image of b if f(a) = b.
Properties of Function:
Addition and multiplication: let f1 and f2 are two functions from A to B, then f1 + f2 and f1.f2 are
defined as-:
f1+f2(x) = f1(x) + f2(x). (addition)
f1f2(x) = f1(x) f2(x). (multiplication)
Equality: Two functions are equal only when they have the same domain, same co-domain and same
mapping elements from domain to co-domain.
Types of functions:
One to one function(Injective):
A function is called one to one if for all elements a and b in A, if f(a) = f(b),then it must be
the case that a = b. It never maps distinct elements of its domain to the same element of its
co-domain.
Injective means we won't have two or more "A"s pointing to the same "B".So many-to-one is NOT OK
(which is OK for a general function).As it is also a function one-to-many is not OK But we can have a
"B" without a matching "A"Injective is also called "One-to-One"
Surjective means that every "B" has at least one matching "A" (maybe more than one).There won't be a
"B" left out.
There are various examples of surjective functions, which are described as follows:
Example 1: In this example, we will assume X = {4, 5, 7, 8}, and Y = {1, 3}, and f = {(4, 1), (5, 3), (7, 1),
(8, 3)}. Now we have to show whether f is an surjective function from X to Y.
X = {4, 5, 7, 8}
Y = {1, 3}
So, all the elements of set Y contain a domain element on set X. That means the elements 4, 7 of set X,
have image 1, and both elements 5, 8 have image 3. Here {1, 3} is known as the range of the function, and
that range is equal to Y. Thus, f: X → Y is onto or surjective function.
Example 2: In this example, we have two sets, X and Y where X = {1, 2, 3, 4}, and Y = {x, y, z}. Now we
have to determine the number of onto functions.
X = {1, 2, 3, 4}
Y = {x, y, z}
Now, we will put the value of n and m in the following formula, and after that, we will get the following:
= 34 - 3C1(2)4 + 3C2(1)4
= 81 - 3 (16) + 3(1)
= 81 - 48 + 3
= 84-48
= 36
Example 3: In this example, we have a function g: R → R, which is defined as g(x) = 1 + x2. Now have to
determine whether this function is surjective or onto function.
As we know that x2 > 0 for all the real numbers. Hence, 1 + x2 > 1 or g(x) > 1, and we can also say that the
range of this function is (1, ∞). The real numbers (R) are also contained by the second set. So this range
and codomain are not equal to each other. Hence, the given function is not a surjective function.
Example 1:
In this example, we have to prove that the function f(x) = 3x - 5 is bijective from R to R.
Solution:
On the basis of bijective function, a given function f(x) = 3x -5 will be a bijective function if it
contains both surjective and injective functions.
Prove that Function is injective
If we want to show that the given function is injective, then we have to prove that f(a) = c and f(b)
= c then a = b.
For this, we will assume that
f(a) = c and f(b) = c
Therefore, we can write it like this:
c = 3a -5 and c = 3b -5
Thus, we can write it like this:
3a - 5 = 3b - 5
a=b
So, we can say that the given function f(x)= 3x -5 is injective.
Thus, the function f(x) = 3x - 5 satisfies the condition of onto function and one to one function. So
we can say that the given function is bijective.E
Example 2:
In this example, we will have a function f: A → B, where set A = {x, y, z} and B = {a, b, c}. We have
to prove that this function is bijective or not.
Solution:
As we know f: A → B such thatf = {(x, a), (y, b), (z, c)}As we can see that the above function
satisfies the property of onto function and one to one function. That's why the given function is a
bijective function.
Inverse Functions:
Bijection functions are also known as invertible functions because they have inverse
function properties. The inverse of bijection f is denoted as f-1. It is a function which
assigns to b, a unique element such that f(a) = b. hence f-1 (b) = a.
Steps to find an Inverse function
Notes Prepared by:
Asst.Prof.Vidya A. Huse(v50huse@gmail.com)
According to DBATU Syllabus 2022-23 UNIT 2:Functions and Relations
Discrete Mathematics
We can easily determine the inverse function with the help of the following sequence of steps. Here we
will assume a function f where f(x) = ax + b, and then try to determine the inverse of this function with the
help of following steps:
1) For the above function f(x) = ax + b, we will replace f(x) = y, and then obtain y = ax + b.
2) In this function, we will interchange y with x and x with y. After interchanging, y = ax + b will
become x = ay + b.
3) Now we will solve this expression x = ay + b for y. After solving this expression, we will get y = (x
- b) / a.
4) Lastly, we will replace y = f-1(x), and then we will have f-1(x) = (x - b) / a.
There are various examples of inverse functions. Some of the examples of inverse function are described
as follows:
Example 1: In this example, we will consider two functions, f and g. Where f(x) = 2x + 3 and g(x) = (x-3)
/ 2. Now we have to determine the inverse of these functions with the help of the formula of an inverse
function.
Solution:
To prove this, first we will take the left side part, which is described as follows:
(f o g)(x) = f (g(x))
= f ((x-3) /2)
= x-3+3
=x
Now we will take the right side of part and try to prove it like this:
(g o f)(x) = g (f(x))
= g(2x+3)
= (2x +3 -3) /2
= 2x /2
=x
With the help of the inverse formula, we can say that f and g are inverses of each other.
Example 2: In this example, we have a function f. Where f(a) = 4a+1 /3a-2. Now we have to determine the
inverse function with the help of the formula of an inverse function.
Solution:
Here we will use the formula of inverse function to determine the inverse function.
b = (4a+1) / (3a-2)
a = (4b+1) / (3b-2)
Now we will solve the expression for y. For this, we will multiply both sides by (3b- 2) and get the
following:
a(3b - 2) = 4b+1
3ab - 2a = 4b+1
3ab - 4b = 2a+1
b(3a - 4) = 2a+1
b = 2a+1 /3a-4
if the distinct element of surjective if one more injective and surjective functions.
codomain. element of B.
2 This function can also be This function can also This function can also be called
function. function.
Composition of Functions
In Maths, the composition of a function is an operation where two functions say f and g generate a new function say
h in such a way that h(x) = g(f(x)). It means here function g is applied to the function of x. So, basically, a function is
applied to the result of another function.
he order of function is an important thing while dealing with the composition of functions since (f ∘ g) (x)
is not equal to (g ∘ f) (x).
The relation and function is an important concept of Class 11 and 12. See below the function composition
symbol and domain with example.
Symbol: It is also denoted as (g∘f)(x), where ∘ is a small circle symbol. We cannot replace ∘ with a dot (.),
because it will show as the product of two functions, such as (g.f)(x).
Domain: f(g(x)) is read as f of g of x. In the composition of (f o g) (x) the domain of function f becomes
g(x). The domain is a set of all values which go into the function.
f ∘ (g ∘ h) = (f ∘ g) ∘ h
Commutative Property: Two functions f and g are said to be commute with each other, if and only if;
g∘f=f∘g
Go through the below-given steps to understand how to solve the given composite function.
Now,
Step 2: Substitute the variable x that is there in the outside function with the inside function by taking the
individual functions as a reference.
That means,
= 9x2
It is possible to compose a function with itself. Suppose f is a function, then the composition of function f
with itself will be
(f∘f)(x) = f(f(x))
(f∘f)(x) = f(f(x))
= f (3x2)
= 3(3x)2
= 3.9x2
= 27x2
g(x) = x+ 1
Solution: Given,
Notes Prepared by:
Asst.Prof.Vidya A. Huse(v50huse@gmail.com)
According to DBATU Syllabus 2022-23 UNIT 2:Functions and Relations
Discrete Mathematics
f(x) = 2x+1
g(x) = -x2
To find: g(f(x))
g(f(2)) = -(2.2+1)2
= -(4+1)2
=-(5)2
=-25
Equivalence Relation
In mathematics, an equivalence relation is a kind of binary relation that should be reflexive, symmetric and
transitive. The well-known example of an equivalence relation is the “equal to (=)” relation. In other
words, two elements of the given set are equivalent to each other if they belong to the same equivalence
class. Equivalence Relation Definition
A relation R on a set A is said to be an equivalence relation if and only if the relation R is reflexive,
symmetric and transitive. The equivalence relation is a relationship on the set which is generally
represented by the symbol “∼”.
A binary relation ∼ on a set A is said to be an equivalence relation, if and only if it is reflexive, symmetric
and transitive.
x ∼ x (Reflexivity)
x ∼ y if and only if y ∼ x (Symmetry)
If x∼y and y∼z, then x∼z (Transitivity)
Equivalence relations can be explained in terms of the following examples:
The sign of ‘is equal to (=)’ on a set of numbers; for example, 1/3 = 3/9.
For a given set of triangles, the relation of ‘is similar to (~)’ and ‘is congruent to (≅)’ shows equivalence.
For a given set of integers, the relation of ‘congruence modulo n (≡)’ shows equivalence.
The image and domain are the same under a function, which shows the relation of equivalence.
For a set of all angles, ‘has the same cosine’.
For a set of all real numbers,’ has the same absolute value’.
Let us assume that R be a relation on the set of ordered pairs of positive integers such that ((a, b), (c, d))∈
R if and only if ad=bc. Is R an equivalence relation?
In order to prove that R is an equivalence relation, we must show that R is reflexive, symmetric and
transitive.
Reflexive Property
According to the reflexive property, if (a, a) ∈ R, for every a∈A
Symmetric Property
Notes Prepared by:
Asst.Prof.Vidya A. Huse(v50huse@gmail.com)
According to DBATU Syllabus 2022-23 UNIT 2:Functions and Relations
Discrete Mathematics
Transitive Property
From the transitive property,
Now, assume that ((a, b), (c, d))∈ R and ((c, d), (e, f)) ∈ R.
The above relation implies that a/b = c/d and that c/d = e/f,
Question 1:
Let us assume that F is a relation on the set R real numbers defined by xFy if and only if x-y is an integer.
Prove that F is an equivalence relation on R.
Solution:
Symmetric: Consider x and y belongs to R and xFy. Then x – y is an integer. Thus, y – x = – ( x – y), y – x
is also an integer. Therefore yFx.
Transitive: Consider x and y belongs to R, xFy and yFz. Therefore x-y and y-z are integers. According to
the transitive property, ( x – y ) + ( y – z ) = x – z is also an integer. So that xFz.
Question 2:
Show that the relation R is an equivalence relation in the set A = { 1, 2, 3, 4, 5 } given by the relation R =
{ (a, b):|a-b| is even }.
Solution:
Reflexive Property :
|a – a| = | 0 |=0
Hence R is Reflexive
Symmetric Property :
|a – b| = |b – a|
Hence |a – b| is even,
Hence R is symmetric.
Transitive Property :
So,
Hence R is transitive.
Combinatorics:
Combinatorics is a stream of mathematics that concerns the study of finite discrete structures. It deals with
the study of permutations and combinations, enumerations of the sets of elements. It characterizes
Mathematical relations and their properties.Mathematicians use the term “Combinatorics” as it refers to the
larger subset of Discrete Mathematics. It is frequently used in computer Science to derive the formulas
and it is used for the estimation of the analysis of the algorithmsCombinatorics is the branch of
Mathematics dealing with the study of finite or countable discrete structures. It includes the enumeration or
counting of objects having certain properties. Counting helps us solve several types of problems such as
counting the number of available IPv4 or IPv6 addresses.
Counting Principles –
There are two basic counting principles, sum rule and product rule.
Sum Rule – If a task can be done in one of n1 ways or one of n2 ways, where none of the set of n1 ways
is the same as any of the set of n2 ways, then there are n1+n2 ways to do the task.
Product Rule – If a task can be broken down into a sequence of k subtasks, where each subtask can be
performed in n1,n1,...nk respectively, then the total number of ways the task can be performed is
n1*n2*...*nk.
● Example 1 – In how many ways can 3 winning prizes be given to the top 3 players in a game
played by 12 players?
● Solution – We have to distribute 3 prizes among 12 players. This task can be divided into 3
subtasks of assigning a single prize to a certain player.
Giving out the first prize can be done in 12 different ways. After giving out the first prize, two
prizes remain and 11 players remain. Similarly, the second prize and third prize can be given in
11 ways and 10 ways. The total number of ways by the product rule is 12 * 11 * 10 = 1320.
● Example 2 – In how many ways can a person choose a project from three lists of projects of
sizes 10, 15, and 19 respectively?
● Solution – The person has a choice of choosing a project from either of the three lists. So the
person can choose from either 10 projects or 15 projects or 19 projects. Since choosing from
one list is not the same as choosing another list, the total number of ways of choosing a pro
Principle of Inclusion-Exclusion :
The sum-rule mentioned above states that if there are multiple sets of ways of doing a task, there shouldn’t
be any way that is common between two sets of ways because if there is, it would be counted twice and the
enumeration would be wrong.
The principle of inclusion-exclusion says that in order to count only unique ways of doing a task, we
must add the number of ways to do it in one way and the number of ways to do it in another and then
subtract the number of ways to do the task that are common to both sets of ways.
The principle of inclusion-exclusion is also known as the subtraction principle. For two sets of ways A1
and A2, the enumeration would like-
● Example 1 – How many binary strings of length 8 either start with a ‘1’ bit or end with two
bits ’00’?
● Solution – If the string starts with one, there are 7 characters left which can be filled in
ways.
If the string ends with ’00’ then 6 characters can be filled in ways.
Now if we add the above sets of ways and conclude that it is the final answer, then it would be
wrong. This is because there are strings with start with ‘1’ and end with ’00’ both, and since
they satisfy both criteria they are counted twice.
So we need to subtract such strings to get a correct count.
Strings that start with ‘1’ and end with ’00’ have five characters that can be filled in
ways.
So by the inclusion-exclusion principle we get-
Total strings = 128 + 64 – 32 = 160
Counting:
Permutations
A permutation is an arrangement of some elements in which order matters. In other words a Permutation is
an ordered Combination of elements.
Examples
From a set S ={x, y, z} by taking two at a time, all permutations are −
xy,yx,xz,zx,yz,zy.
We have to form a permutation of three digit numbers from a set of numbers S={1,2,3}. Different three
digit numbers will be formed when we arrange the digits. The permutation will be = 123, 132, 213, 231,
312, 321
Number of Permutations
The number of permutations of ‘n’ different things taken ‘r’ at a time is denoted by nPr
nPr=n!/(n−r)!
where n!=1.2.3.…(n−1).n
Solution − As we are taking 6 cards at a time from a deck of 6 cards, the permutation will be 6P6=6!=720
Problem 2 − In how many ways can the letters of the word 'READER' be arranged?
Solution − There are 6 letters word (2 E, 1 A, 1D and 2R.) in the word 'READER'.
Combinations
A combination is selection of some given elements in which order does not matter.
nCr=n!/r!(n−r)!
Problem 1
Solution
The cardinality of the set is 6 and we have to choose 3 elements from the set. Here, the ordering does not
matter. Hence, the number of subsets will be 6C3=20.
Problem 2
There are 6 men and 5 women in a room. In how many ways can we choose 3 men and 2 women from the
room?
Solution
The number of ways to choose 3 men from 6 men is 6C3 and the number of ways to choose 2 women from
5 women is 5C2
Hence, the total number of ways is − 6C3×5C2=20×10=200
Problem 3
How many ways can you choose 3 distinct groups of 3 students from a total of 9 students?
Solution
For choosing 3 students for 1st group, the number of ways − 9C3
The number of ways for choosing 3 students for 2nd group after choosing 1st group − 6C3
The number of ways for choosing 3 students for 3rd group after choosing 1st and 2nd group − 3C3
Hence, the total number of ways =9C3×6C3×3C3=84×20×1=1680
Pigeonhole Principle
In 1834, German mathematician, Peter Gustav Lejeune Dirichlet, stated a principle which he called the
Pigeonhole Principle states that if there are fewer pigeon holes than total number of pigeons and each
pigeon is put in a pigeon hole, then there must be at least one pigeon hole with more than one pigeon. If n
pigeons are put into m pigeonholes where n > m, there's a hole with more than one pigeon.
Examples
Ten men are in a room and they are taking part in handshakes. If each person shakes hands at least once
and no man shakes the same man’s hand more than once then two men took part in the same number of
handshakes.
There must be at least two people in a class of 30 whose names start with the same alphabet.
|A∪B|=|A|+|B|−|A∩B|
For three sets A, B and C, the principle states −
|A∪B∪C|=|A|+|B|+|C|−|A∩B|−|A∩C|−|B∩C|+|A∩B∩C|
The generalized formula -
|⋃ni=1Ai|=∑1≤i<j<k≤n|Ai∩Aj|+∑1≤i<j<k≤n|Ai∩Aj∩Ak|−⋯+(−1)\n−1|A1∩⋯∩A2|
Problem 1
Solution
|A∪B|=|A|+|B|−|A∩B|=25+16−8=33
Problem 2
In a group of 50 students 24 like cold drinks and 36 like hot drinks and each student likes at least one of
the two drinks. How many like both coffee and tea?
Solution
Let X be the set of students who like cold drinks and Y be the set of people who like hot drinks.
Recurrence Relations
A recurrence relation is a functional relation between the independent variable x, dependent variable f(x)
and the differences of various order of f (x). A recurrence relation is also called a difference equation, and
we will use these two terms interchangeably.
The order of the recurrence relation or difference equation is defined to be the difference between the
highest and lowest subscripts of f(x) or ar=yk.
The degree of a difference equation is defined to be the highest power of f (x) or ar=yk
Example3: The equation yk+3 +2yk+2 +4yk+1+2yk= k(x) has degree 1, because the highest power of yk is 1
and its order is 3.
Example4: The equation f (x+2h) - 4f(x+h) +2f(x) = 0 has the degree1 and its order is 2.
Generating Functions-
Generating functions are used to represent sequences efficiently by coding the terms of a sequence as
coefficients of powers of a variable (say) in a formal power series.
Now with the formal definition done, we can take a minute to discuss why should we learn this concept.
This concept can be applied to solve many problems in mathematics. There is a huge chunk of
mathematics dealing with just generating functions.
● It can be used to solve various kinds of Counting problems easily.
● It can be used to solve recurrence relations by translating the relation in terms of sequence to a
problem about functions.
● It can be used to prove combinatorial identities.
In simple words generating functions can be used to translate problems about sequences to problems about
functions which are comparatively easy to solve using maneuvers.
A generating function is a “formal” power series in the sense that we usually regard x as a placeholder
rather than a number. Only in rare cases will we actually evaluate a generating function by letting x take a
real number value, so we generally ignore the issue of convergence.
of real numbers is the infinite series:
By the method of generating functions with the initial conditions a0=2 and a1=3.
+2G(t)=0............equation (ii)
Now, put a0=2 and a1=3 in equation (ii) and solving, we get
-1=- A ∴A=1
= B ∴B=1