0% found this document useful (0 votes)
2 views

Chapter2 - Part2_Functions

Uploaded by

ahda.dzia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter2 - Part2_Functions

Uploaded by

ahda.dzia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Chapter 2 (Part 2)

Sets and Functions


CCS3003
DISCRETE STRUCTURE
Chapter Outline

1. Set operations and laws of set

2. Cartesian product

3. Venn diagram

4. Function: injective, surjective and bijective

5. Compound function and inverse function

CCS3003_DRNS_SEM1_2024/2025 2
Functions
• One-to-one and onto Functions
• Inverse Function
• Function Composition
• Floor, Ceiling, Factorial

CCS3003_DRNS_SEM1_2024/2025 3
Functions
Definition: Let A and B be nonempty sets. A function f from A to B,
denoted f : A → B is an assignment of each element of A to exactly one
element of B. We write f(a) = b if b is the unique element of B assigned
by the function f to the element a of A.
Students Grades
• Functions are sometimes
A
called mappings or Carlota Rodriguez
B
transformations.
Sandeep Patel C
Jalen Williams D

F
Kathy Scott

CCS3003_DRNS_SEM1_2024/2025 4
Functions
• A function f : A → B can also be defined as a subset of A×B (a relation).
• A function f : A → B , is a relation from A to B that satisfies two properties:
• Every element in A is related to some element in B.
• No element in A is related to more than one element in B.

A B
a
x
b
y
c
d z

CCS3003_DRNS_SEM1_2024/2025 5
Functions
Given a function f: A → B:
• We say f maps A to B or
f is a mapping from A to B.
• A is called the domain of f.
• B is called the codomain of f.
• If f(a) = b,
• then b is called the image of a under f.
• a is called the preimage of b.
• The range of f is the set of all images of points in A under f. We denote
it by f(A).
• Two functions are equal when they have the same domain, the same
codomain and map each element of the domain to the same element
of the codomain.

CCS3003_DRNS_SEM1_2024/2025 6
Questions
f(a) = ? z
A B
The image of d is ? z a
x
The domain of f is ? A b
y
The codomain of f is ? B c

The preimage of y is ? b d z

f(A) = ? {y, z}
The preimage(s) of z is (are) ? {a,c,d}

CCS3003_DRNS_SEM1_2024/2025 7
Injections
Definition: A function f 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 of f.
A function is said to be an injection if it is one-to-one.

A B
x
a
v
b
y
c
z
d

CCS3003_DRNS_SEM1_2024/2025 8
Surjections
Definition: A function f from A to B is called onto or
surjective, if and only if for every element
there is an element with . A
function f is called a surjection if it is onto.

A B
a x

b
y
c
z
d

CCS3003_DRNS_SEM1_2024/2025 9
Bijections
Definition: A function f is a one-to-one correspondence, or a
bijection, if it is both one-to-one and onto (surjective and injective).

A B
a x

b
y
c

d z

CCS3003_DRNS_SEM1_2024/2025 10
One-to-one and Onto Functions

CCS3003_DRNS_SEM1_2024/2025 11
Functions

CCS3003_DRNS_SEM1_2024/2025 12
Functions

CCS3003_DRNS_SEM1_2024/2025 13
Showing that f is one-to-one or onto

CCS3003_DRNS_SEM1_2024/2025 14
Showing that f is onto function

Example : Let f be the function from {a,b,c,d} to {1,2,3} defined by


f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3.
Is f an onto function?
Solution: Yes, f is onto since all three elements of the codomain
are images of elements in the domain.

If the codomain were changed to {1, 2, 3, 4}, f would not be onto.

CCS3003_DRNS_SEM1_2024/2025 15
One-to-one and Onto Functions

Example : Is the function f(x) = x2 from the set of integers onto?


Solution: No, f is not onto because there is no integer x with x2 = −1,
for example.

Example :

CCS3003_DRNS_SEM1_2024/2025 16
Showing that f is one-to-one and onto

Example 1:

Example 2:

CCS3003_DRNS_SEM1_2024/2025 17
Inverse Functions
Definition: Let f be a bijection from A to B. Then the
inverse of f, denoted , is the function from B to A
defined as
No inverse exists unless f is a bijection. Why?

CCS3003_DRNS_SEM1_2024/2025 18
Inverse Functions

A f
B A B
a V V
a

b b
W W
c c

d X X
d

Y Y

CCS3003_DRNS_SEM1_2024/2025 19
Questions
Example 1: Let f be the function from {a,b,c} to {1,2,3} such
that f(a) = 2, f(b) = 3, and f(c) = 1. Is f invertible and if so what
is its inverse?

Solution: The function f is invertible because it is a one-to-one


correspondence. The inverse function f-1 reverses the correspondence
given by f, so f-1 (1) = c, f-1 (2) = a, and f-1 (3) = b.

CCS3003_DRNS_SEM1_2024/2025 20
Questions

Example 2: Let f: Z → Z be such that f(x) = x + 1. Is f


invertible, and if so, what is its inverse?

Solution: The function f is invertible because it is a


one-to-one correspondence. The inverse function f-1
reverses the correspondence so f-1 (y) = y – 1.

CCS3003_DRNS_SEM1_2024/2025 21
Questions

Example 3: Let f: R → R be such that .


Is f invertible, and if so, what is its inverse?

Solution: The function f is not invertible because it is not


one-to-one .

CCS3003_DRNS_SEM1_2024/2025 22
Composition
 Definition: Let f: B → C, g: A → B. The composition of
f with g, denoted is the function from A to C
defined by

CCS3003_DRNS_SEM1_2024/2025 23
Composition

g f
A B C A C
V a
a h h
b i b
W i
c
c
X j
d
d j
Y

CCS3003_DRNS_SEM1_2024/2025 24
Composition
Example 1: If and ,
then

and

CCS3003_DRNS_SEM1_2024/2025 25
Composition Questions
Example 2: Let f and g be functions from the set of integers to the set of
integers defined by f(x) = 2x + 3 and g(x) = 3x + 2.
What is the composition of f and g, and also the composition of g and f ?
Solution:
(f∘g) (x)= f(g(x))
= f(3x + 2) = 2(3x + 2) + 3 = 6x + 7
(g∘f) (x)= g(f(x))
= g(2x + 3) = 3(2x + 3) + 2 = 6x + 11

CCS3003_DRNS_SEM1_2024/2025 26
Function, Inverse and Composition

Consider the following:

CCS3003_DRNS_SEM1_2024/2025 27
Identity Function

Given a set X, define a function Ix from X to X by

Ix (x) = x for all x in X.

Ix is called the identity function on X because whatever input to the


identity function the output comes out unchanged.

CCS3003_DRNS_SEM1_2024/2025 28
Equality of Functions
Example:

CCS3003_DRNS_SEM1_2024/2025 29
Equality of Functions
Solution:

CCS3003_DRNS_SEM1_2024/2025 30
Boolean Functions

CCS3003_DRNS_SEM1_2024/2025 31
Solution:

CCS3003_DRNS_SEM1_2024/2025 32
Exercise 1

Find the inverse function of 𝑓 𝑥 = 𝑥 3 + 1.

𝑓 −1 𝑥 = 𝑦
𝑥 3 +1 = 𝑦
𝑥3 = 𝑦 − 1
𝑥 = 3 𝑦−1

3
∴ 𝑓 −1 𝑥 = 𝑥−1

= (𝑥 − 1)1Τ3

CCS3003_DRNS_SEM1_2024/2025 33
Exercise 2
Find 𝑓 ⃘𝑔 and 𝑔 ⃘ 𝑓, where 𝑓 𝑥 = 𝑥 2 + 1 and 𝑔 𝑥 = 𝑥 + 2, are functions from R to R.

• Identify whether f  g = g  f

𝑓(𝑔 𝑥 ) = 𝑓 𝑥 + 2
= (𝑥 + 2)2 +1
= 𝑥 2 + 4𝑥 + 5

𝑔(𝑓 𝑥 ) = 𝑔 𝑥 2 + 1
= 𝑥2 + 1 + 2
= 𝑥2 + 3

∴𝒇∘𝒈≠ 𝒈∘𝒇

CCS3003_DRNS_SEM1_2024/2025 34
Exercise 3
Find 𝑓 ⃘𝑔 and 𝑔 ⃘ 𝑓, where 𝑓 𝑥 = 𝑥 2 + 1 and 𝑔 𝑥 = 𝑥 + 2, are functions from R to R.

• Identify whether ( f  g ) −1 = g −1  f −1

𝑓 𝑔 𝑥 = 𝑥+2 2+1=𝑦 𝑔(𝑥) = 𝑥 + 2 = 𝑦


(𝑥 + 2)2 = 𝑦 − 1 𝑥 =𝑦 −2
𝑥+2 = 𝑦 −1 𝑔−1 𝑥 = 𝑥 − 2
𝑥 = 𝑦 −1 −2
𝑓. 𝑔 −1 (𝑥) = 𝑥 − 1 − 2 𝑓 𝑥 = 𝑥2 + 1 = 𝑦
𝑥2 = 𝑦 − 1
𝑥 = 𝑦 −1
𝑓 −1 𝑥 = 𝑥 − 1

∴ 𝒇. 𝒈 −𝟏 = 𝒈−𝟏 . 𝒇−𝟏 𝑔−1 . 𝑓 −1 𝑥 = 𝑥 − 1 − 2

CCS3003_DRNS_SEM1_2024/2025 35
Exercise 4
Find 𝑓 ⃘𝑔 and 𝑔 ⃘ 𝑓, where 𝑓 𝑥 = 𝑥 2 + 1 and 𝑔 𝑥 = 𝑥 + 2, are functions from R to R.

• Identify whether ( g  f ) −1 = f −1  g −1
𝑓 𝑥 = 𝑥2 + 1 = 𝑦
𝑔 𝑓 𝑥 = 𝑥2 + 1 + 2 = 𝑦 𝑥2 = 𝑦 − 1
𝑥2 = 𝑦 − 3 𝑥 = 𝑦 −1
𝑥 = 𝑦 −3 𝑓 −1 𝑥 = 𝑥 − 1

𝑔. 𝑓 −1 (𝑥) = 𝑥 −3 𝑔(𝑥) = 𝑥 + 2 = 𝑦
𝑥 =𝑦 −2
𝑔−1 𝑥 = 𝑥 − 2

𝑓 −1 . 𝑔−1 𝑥 = 𝑥 − 2 − 1
𝑓 −1 . 𝑔−1 𝑥 = 𝑥 − 3
−𝟏
∴ 𝒈. 𝒇 = 𝒇−𝟏 . 𝒈−𝟏

CCS3003_DRNS_SEM1_2024/2025 36
Graphs of Functions
• Let f be a function from the set A to the set B. The graph of the function f
is the set of ordered pairs {(a,b) | a ∈A and f(a) = b}.

Graph of f(n) = 2n + 1 Graph of f(x) = x2


from Z to Z from Z to Z

CCS3003_DRNS_SEM1_2024/2025 37
Some Important Functions
 The floor function, denoted
is the largest integer less than or equal to x.
 The ceiling function, denoted
is the smallest integer greater than or equal to x
Example:

CCS3003_DRNS_SEM1_2024/2025 38
Floor and Ceiling Functions

Graph of (a) Floor and (b) Ceiling Functions

CCS3003_DRNS_SEM1_2024/2025 39
Floor and Ceiling Functions

CCS3003_DRNS_SEM1_2024/2025 40
Factorial Function
Definition: f: N → Z+ , denoted by f(n) = n! is the product of the first n
positive integers when n is a nonnegative integer.
f(n) = 1 ∙ 2 ∙∙∙ (n – 1) ∙ n, f(0) = 0! = 1

Examples:
f(1) = 1! = 1
Stirling’s Formula:
f(2) = 2! = 1 ∙ 2 = 2

f(6) = 6! = 1 ∙ 2 ∙ 3∙ 4∙ 5 ∙ 6 = 720

f(20) = 2,432,902,008,176,640,000.

CCS3003_DRNS_SEM1_2024/2025 41
TERIMA KASIH
THANK YOU
谢谢
Xièxiè
நன்றி
Naṉṟi
‫شكرا‬
ً
Shukran

CCS3003_DRNS_SEM1_2024/2025 42

You might also like