CSE212 DiscreteMaths Lecture-7 Functions
CSE212 DiscreteMaths Lecture-7 Functions
Discrete Mathematics
Functions 1
Definition: Function
Definition
Let A and B be non empty sets. A function f from A to B is an
assignment of exactly one element of B to each element of A. We
write f (a) = b if b is the unique element of B assigned by the
function f to the element a of A. If f is a function from A to B,
we write f : A → B.
A B
a f b = f (a)
Functions 2
Definitions: Domain, Codomain, Image, Preimage and
Range
Definition
If f is a function from A to B, we say that A is the domain of f
and B is the codomain of f .
If f (a) = b, we say that b is the image of a and a is the preimage
of b.
The range of f is the set of all images of elements of A.
Also, If f is a function from A to B, we say that f maps A to B.
A B
a f b = f (a)
Functions 3
Definition: Image of a Subset
Definition
Let f be a function from the set A to the set B and let S be a
subset of A. The image of S under the function f is the subset of
B that consists of the images of the elements of S. We denote the
image of S by f (S), so
f (S) = {t ∈ B | ∃s ∈ S with (t = f (s))}.
We also use the shorthand f (S) = {f (s) | s ∈ S} to denote this set.
A f B
a x
b y
c S f (S)
z
d
Functions 4
Example
A f B
a x
b y
c S f (S)
z
d
Functions 5
Definition: One-To-One (Injective) Function
Definition
A function f from A to B is said to be one-to-one, or injective, if
and only if f (a) = f (b) implies that a = b for all a and b in the
domain A. A function is said to be an injection if it is injective.
Functions 6
Definition: Onto (Surjective) Function
Definition
A function f from A to B is called onto, or surjective, if and only
if for every element b ∈ B there is an element a ∈ A with
f (a) = b. A function f is called a surjection if it is surjective.
Functions 7
Definition: One-To-One Correspondence (Bijective)
Function
Definition
The function f is a one-to-one correspondence if it is both
one-to-one and onto.
Functions 8
Example 1
A f B
a w
x
b
y
c z
Is f injective?
Is f surjective?
Is f bijective?
Functions 9
Example 2
A f B
a x
b y
c
z
d
Is f injective?
Is f surjective?
Is f bijective?
Functions 10
Example 3
A f B
a w
b x
c y
d z
Is f injective?
Is f surjective?
Is f bijective?
Functions 11
Example 4
A f B
a w
b x
c y
d z
Is f injective?
Is f surjective?
Is f bijective?
Functions 12
Example 5
A f B
a w
x
b
y
c z
Is f injective?
Is f surjective?
Is f bijective?
Functions 13
Venn Diagram of Function Classification
Relations
Functions
Injections Surjections
Bijections
Functions 14
Addition and Product of Functions
Definition
Let f1 and f2 be functions from A to R. Then f1 + f2 and f1 f2 are
also functions from A to R defined by
Functions 15
Definition: Composition of Functions
Definition
Let g be a function from the set A to the set B, and let f be a
function from the set B to the set C . The composition of the
functions f and g , denoted by f ◦ g , is defined by
(f ◦ g )(a) = f (g (a)).
f ◦g
A g B f C
a g g (a) f f (g (a))
f ◦g
Functions 16
Definition: Inverse Function
Definition
Let f be a bijection from the set A to the set B. The inverse
function of f is the function that assigns to an element b
belonging to B the unique element a in A such that f (a) = b. The
inverse function of f is denoted by f −1 . Hence, f −1 (b) = a when
f (a) = b. The inverse function is also a bijection.
A B
f −1
a = f −1 (b) f b = f (a)
f −1
Functions 17
Identity Function
Definition
Identity function (also called identity mapping): The identity
mapping 1X : X → X is the function with domain and codomain
X defined by
1X (x) = x, ∀x ∈ X .
Functions 18
Left and Right Inverse
Definition
Let f : X → Y be a fonction with domain X and codomain Y ,
and g : Y → X be a fonction with domain Y and codomain X .
The function g is a left inverse of f if g ◦ f = 1X .
The function g is a right inverse of f if f ◦ g = 1Y .
The function g is an inverse of f if g is both a left and right
inverse of f . When f has an inverse, it is often written f −1 .
Functions 19
Left and Right Inverse
Theorem
A function is injective if and only if it has a left inverse.
A function is surjective if and only if it has a right inverse.
A function is bijective if and only if it has an inverse.
If a function has an inverse, then this inverse is unique.
Note: The left and right inverses are not necessarily unique.
Functions 20