L16 17 Functions
L16 17 Functions
(Discrete Mathematics)
Lecture # 16
Chapter 2.3
Functions
Lecture Outline
• Functions
– What is a function?
– Function Arithmetic
– One-to-one, Onto and Bijective Functions
– Identity and Inverse Function
– Composition of Functions
Ali A
Babar B
Umer C
Imran D
Hamza F
Functions
• Let A and B be nonempty sets.
2 12
The arrow diagram for a function f 3 20
has the following two properties: 4 24
5 8
• Every element of A has an arrow 6 16
coming out of it.
• No elements of A has two arrows
coming out of it that point to two
different elements of B.
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}.
A B A B
f(4.3)
4.3 4
Babar B “bb“ 2
Umer C “cccc” 3
Hamza D “dd” 4
Amir F “e” 5
Domain Range
a 1
e 2
i 3 Co-domain
o 4
u 5
Example
• 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
One-to-One Function-Injective
• 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 function that is
A one-to-one function not one-to-one
One-to-One Function-Injective
or equivalently
a 1
e 2
Note that there can be un-used i 3
elements in the co-domain o 4
5
A one-to-one function
Example - one-to-one (Injective)
a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
u 5
a 1
e 2
Note that there can be multiple i 3
used elements in the co-domain o 4
u
An onto function
Example onto (Surjective) 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
Example
• Determine whether the function f (x) = from the set
of integers to the set of integers is one-to-one.
Example
• Determine whether the function f (x) = from the set
of integers to the set of integers is onto.
Bijections OR One-to-One Correspondence
a) 7? b) 1001? c) 28,800?
Some Useful Function-Factorial
• Factorial is denoted by n!
• n! = n * (n-1) * (n-2) * … * 2 * 1
• Thus, 6! = 6 * 5 * 4 * 3 * 2 * 1 = 720
• f(x) = 1*x
• f(x) = x + 0
A B
f
a= f-1(b) f(a)=b
f-1
A=domain of f B=Co-domain of f
Inverse Functions
f-1
f(4.3)
4.3 8.6
f-1(8.6)
(f g)(a) = f(g(a))
fg
A B C
g f
g(a) f(b)
a f(g(a))
b = g(a)
(f g)(a)
Compositions of Functions
(f g)(1)
Do f(g(x)) = g(f(x))?
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.
Topic # 2.3
Questions 1, 2, 8, 9,10,11,12, 22, 23, 38, 39