0% found this document useful (0 votes)
17 views45 pages

9 1 (Funxtions)

The document discusses discrete structures, focusing on functions, their definitions, properties, and types such as one-to-one and onto functions. It explains the concepts of domain, codomain, range, and provides examples of function arithmetic, inverse functions, and compositions of functions. Additionally, it highlights the importance of bijections and the conditions under which functions can be invertible.

Uploaded by

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

9 1 (Funxtions)

The document discusses discrete structures, focusing on functions, their definitions, properties, and types such as one-to-one and onto functions. It explains the concepts of domain, codomain, range, and provides examples of function arithmetic, inverse functions, and compositions of functions. Additionally, it highlights the importance of bijections and the conditions under which functions can be invertible.

Uploaded by

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

SE2053\ACS1153 - Discrete

Structures
Fall 2023

Functions
Application of
Functions

• Define discrete structures such as sequences and strings


• Represent the time that a computer takes to solve
problems of a given size
• Represent the complexity of algorithms
•…
Functions
• In many examples we assign to each element of a set, a
particular element of a second set (which may be the
same as the first).
• For example, suppose that each student in a discrete
mathematics class is assigned a letter grade from the set
{A,B,C,D, F}.
• This assignment is an example of a function.

Ali A
Babar B
Umer C
Imran D
Hamza F
Functions
• Let A and B be nonempty sets.

• A function f from A to B is an assignment of exactly


one element of B to each element of A.

• If b is the unique element of B assigned by the function


f
to the element a of A, we write f(a) = b.

• If f is a function from A to B, we write f: A → B.


Functions

• 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 pre-


image of b.

• The range of f is the set of all images of elements of A.

• Also, if f is function from A to B, we say that f maps A to


B.
Functions
• A function takes an element from a set and maps it to
a
UNIQUE element in another set.

Domain R f maps R to Z Z Co-domain


f

f(4.3)
4.3 4

Pre-image of 4 Image of 4.3


Arrow Diagram of
Functions
• The definition of a function implies that the arrow diagram
for a function f has the following two properties:

• Every element of A has an arrow coming out of it

• No elements of A has two arrows coming out of it that


point to two different elements of B.
Arrow Diagram of
The pre-image The image
Functions(example) of “a”
Domain Co-domain of 1
Ali A “a” 1

Babar B “bb“ 2

Chishti C “ccc 3
c” 4
Dawood D
“dd” 5
Ammara F
“e”

A class grade function A string length function

g(Ali) = A f(x) = length x


g(Babar) = C f(“a”) = 1
g(Chishti) = A f(“bb”) = 2
… …
Functions
The range of f is the set of all images of elements of
A.

Range
a 1
e 2
i 3
o 4
u 5
Functions

“a” 1
“bb“ 2
“cccc” 3
“dd” 4
“e” 5

Not a valid function


Functions and Non-
Functions
• Which of the arrow diagrams define functions from
• A = {2,4,5,6,7} to B = {1,2,4,6,8}.

Domain Co-domain Domain Co-domain


2 1 2 1
4 2 4 2
5 4 5 4
6 6 6 6
7 8 7 8

A B A B

Not a Function Not a Function


Exampl
e
• Let f : Z → Z
assign the square of an integer to this integer
• What is f (x) =?
• f(x) = x2
• What is domain of f ?
• Set of all integers
• What is codomain of f ?
• Set of all integers
• What is the range of f ?
• {0, 1, 4, 9, . . . }. All integers that are perfect squares
Function
Arithmetic
• Just as we are able to add (+), subtract (-), multiply (*),
and divide (÷) two or more numbers, we are able to + ,
-,
* , and ÷ two or more functions

and f/g are also functions from A to R defined for all x ∈


• Let f and g be functions from A to R. Then f + g, f – g, f * g

A by:
• (f + g)(x) = f(x) + g(x)
• (f - g)(x) = f(x) - g(x)
• (f *g)(x) = f (x)*g(x)
• (f/g)(x) = f(x)/g(x) given that g(x)≠0
Function
Arithmetic
Let f1 and f2 be functions from R to R such that:

• f1(x) = 2x
• f2(x) = x2
• Find f1 + f2 and f1*f2.
• f1+f2 = (f1+f2)(x) = f1(x)+f2(x) = 2x+x2
• f1*f2 = (f1*f2)(x) = f1(x)*f2(x) = 2x*x2 = 2x3
Function
Arithmetic
• Let f and g be functions from R to R such that:
• f (x) = 3x+2 g (x) = -2x + 1
• What is the function f *g?
• f*g = (f*g) (x) = f (x)*g(x) = (3x+2)*(-2x+1) = -6x2- x
+2

Let x = -1, what is f(-1)*g(-1) and (f*g)(-1)?


• f (-1) = 3(-1) + 2 = -1
• g(-1) = -2(-1) + 1= 3
• f(-1)*g(-1) = -1×3 = -3
• (f *g) (-1) = -6(-1)2 – (-1) + 2 = -6+1+2 = -3
One-to-One
Function
• A function is one-to-one if each element in the co-domain
has a unique pre-image
• Formal definition: A function f is one-to-one if f(a) =
f(b) implies a = b for all a and b in the domain of f.
a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
5 5

A one-to-one function A function that is


not one-to-one
One-to-One
Function
• 𝑓 is one-to-one using quantifiers as

• ∀𝑎∀𝑏 𝑓 𝑎 = 𝑓 𝑏 → 𝑎 = 𝑏 or
equivalently
∀𝑎∀𝑏 𝑎 ≠ 𝑏 → 𝑓(𝑎) ≠ 𝑓 𝑏

• Where 𝑎 and 𝑏 in domain of 𝑓.


More on One-to-One
Functions
• Injective is synonymous with one-to-one
• “A function is injective”
• A function is an injection if it is one-to-one

a 1
e 2
• Note that there can
i 3
be un-used elements
o 4
in the co-domain
5

A one-to-one function
Example one-to-one
• Determine whether the function 𝑓 from *𝑎, 𝑏,
function
𝑐, 𝑑+ to
*1, 2, 3, 4, 5+ with 𝑓 𝑎 = 4, 𝑓 𝑏 = 5, 𝑓
𝑐 = 1, 𝑎𝑛𝑑
𝑓(𝑑) = 3 is one-to-one.
Onto
Functions
• A function is onto if each element in the co-domain is an
image of some pre-image
• Formal definition: A function f is onto if for all b  B,
there exists a  A such that f(a) = b.

a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
u 5

An onto function A function that


is not onto
Onto
functions
• A function 𝑓 is onto if ∀𝑏∃𝑎(𝑓𝑎 = 𝑏), where the
domain for 𝑎 is the domain of the function and the
domain for 𝑏 is the codomain of the function.
More on Onto
Functions
• Surjective is synonymous with onto
• “A function is surjective”
• A function is a surjection if it is onto

• Note that there can


be multiple used a 1
elements in the e 2
co-domain i 3
o 4
u

An onto function
Example onto
• Determine whether the function 𝑓 from *𝑎, 𝑏, 𝑐,
function
𝑑+ to
*1, 2, 3+ defined by 𝑓 𝑎 = 3, 𝑓 𝑏 =
2, 𝑓 𝑐 = 1, 𝑎𝑛𝑑
𝑓(𝑑) = 3. Is 𝑓 an onto function?
Onto vs One-to-
One
• Are the following functions onto, one-to-one, both, or
neither?
a 1 a 1
a 1
b 2 b 2
b 2
c 3 c 3
c 3
4 d 4
4
1-to-1, not onto Both 1-to-1 and onto Not a valid function
a 1 a 1
b 2 b 2
c 3 c 3
d d 4

Onto, not 1-to-1 Neither 1-to-1 nor onto


Exampl
e• Determine whether the function f (x) = 𝑥2 from the set

𝑓: 𝑍 → 𝑍; 𝑓 𝑥 = 𝑥2
of integers to the set of integers is one-to-one.
Exampl
• Determine whether the function f (x) = 𝑥 + 1 from the
e
set

𝑓: 𝑍 → 𝑍; 𝑓 𝑥 = 𝑥 + 1
of integers to the set of integers is onto.
Bijections
• Consider a function that is
both one-to-one and onto:
a 1
• Such a function is a one-to-one b 2

correspondence, or a bijection. c 3
d 4
Exampl
e
• Determine whether the following functions are bijective or
not?

𝑓: 𝑅 → 𝑅; 𝑓 𝑥
= 𝑥3
= �
𝑓: 𝑅 − *0+ → 𝑥+1�
𝑅; 𝑓 𝑥
Floor and
X is the largest integer that is less than or
Ceiling
equal to x and ceiling(x) = X is the smallest integer
• floor(x) =

that is greater than or equal to x


• The floor and ceiling functions give you the nearest
integer up or down.

Sample value x Floor 𝒙 Ceiling 𝒙

12/5 = 2.4 2 3

2.7 2 3

−2.7 −3 −2

−2 −2 −2
Identity
Functions
• A function such that the image and the pre-image are
ALWAYS equal

• f(x) = 1*x
• f(x) = x + 0

• The domain and the co-domain must be the same


set.
Inverse
Function
• Let f be a one-to-one correspondence from the set A to
the set B.
• The inverse function of f is the function that assigns to an
element in b belonging to B the unique element a in A
such that f(a) = b.
• The inverse function of f is denoted by f −𝟏
.
• Hence , f −𝟏
(b) = a when f(a) = b.
Inverse
Functions
If f(a) = b, then f-1(b) = a

A B

f
a= f-1(b) f(a)=b

f-1

A=domain of f B=Co-domain of f
Inverse
Functions If f(x) = y, then f-1(y) = x
Let f(x) = 2*x
f(x)=y
R f R

f-1

4.3 f(4.3) 8.6


f-1(8.6)

Then f-1(y) = y/2


More on Inverse
Functions
•Can we define the inverse of the following functions?

a 1 a 1
b 2 b 2
c 3 c 3
4 d

What is f-1(2)? What is f-1(2)?


Not onto! Not 1-to-1!
• An inverse function can ONLY be done defined on a
bijection
More on Inverse
Functions
• A one-to-one correspondence is called invertible
because we can define an inverse of this function.

• A function is not invertible if it is not a one-to-one


correspondence, because the inverse of such a function
does not exist.
Exampl
e
• 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 it is, what is its inverse?
Working Rule to Find Inverse
• Let f: X →Y be a one-to-one correspondence defined by
Function
the formula f(x) = y.
1. Solve the equation f(x) = y for x in terms of y.
−𝟏
2. f (y) equals the right hand side of the equation found
in step 1.
Exampl
e
Let f : Z → Z be such that f (x) = x + 1. Is f invertible, and
if
it is, what is its inverse?
Compositions of
Functions
• Let g be a function from the set A to the set B and let f be

the functions f and g, denoted by f °g, is defined by


a function from the set B to the set C. the compositions of

(f °g)(𝒂) = f (g(a))
Compositions of
Functions
(f °g)(a) =
f(g(a))
A f °g C
B f
g
g(a) f(b)
a f(g(a))
b = g(a)

(f °g)
(a)
Compositions of
Functions

Let f(x) = 2x+3 Let g(x) = 3x+2

R g
R
g R f

g(1) f(5)
f(g(1))=13
1
g(1)=5

(f ° g)
(1)
Compositions of
Functions
Does f(g(x)) = g(f(x))?

Let f(x) = 2x+3 Let g(x) = 3x+2

f(g(x)) = 2(3x+2)+3 = 6x+7


g(f(x)) = 3(2x+3)+2 = 6x+11 Not equal!

Function composition is not commutative!


Compositions of
Functions
• Let A = {1,2,3,4,5}
f : A → A and g : A → A
f(1) = 3, f(2) = 5, f(3) = 3, f(4) = 1, f(5) = 2
g(1) = 4, g(2) = 1, g(3) = 1, g(4) = 2, g(5) = 3
Find the composition functions f ◦ g and g ◦ f .
f◦g g◦f
(f ◦ g ) (1) = f(g(1)) = f(4) =1 (g ◦ f ) (1) = g(f(1)) = g(3) = 1
(f ◦ g ) (2) = ? (g ◦ f ) (2) = ?
(f ◦ g ) (3) = ? (g ◦ f ) (3) = ?
(f ◦ g ) (4) = ? (g ◦ f ) (4) = ?
(f ◦ g ) (5) = ? (g ◦ f ) (5) = ?
Compositions of
Let g : A → A be the function, Set A = {a, b, c} such that g(a) = b,
Functions
g(b) = c, and g(c) = a.

Let f : A → B be the function, Set A = {a, b, c} to the set B = {1,


2,
3} such that f (a) = 3, f (b) = 2, and f (c) = 1.

What is the composition of f and g, and what is the composition


of g and f?
Solution:
The composition f ◦ g is defined by
(f ◦ g)(a) = f (g(a)) = f (b) = 2,
(f ◦ g) (b) = f (g(b)) = f (c) = 1,
(f ◦ g)(c) = f (g(c)) = f (a) = 3.
g ◦ f is not defined, because the range of f is not a subset of the
domain of g.
Exercise
Questions

Chapter # 2
Topic # 2.3
Q#1-40(Odd)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy