Discrete Structures Lecture 10
Discrete Structures Lecture 10
(Discrete Mathematics)
Fall 2016
Lecture - 10
Functions
Application of Functions
Ali A
Babar B
Umer C
Imran D
Hamza F
Functions
• Let A and B be nonempty sets.
f(4.3)
4.3 4
Babar B “bb“ 2
Chishti C “cccc” 3
Dawood D “dd” 4
Ammara F “e” 5
Range
a 1
e 2
i 3
o 4
u 5
Functions
“a” 1
“bb“ 2
“cccc” 3
“dd” 4
“e” 5
A B A B
• 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
• ∀𝑎∀𝑏 𝑓 𝑎 = 𝑓 𝑏 → 𝑎 = 𝑏 or equivalently
∀𝑎∀𝑏 𝑎 ≠ 𝑏 → 𝑓(𝑎) ≠ 𝑓 𝑏
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 function
• Determine whether the function 𝑓 from *𝑎, 𝑏, 𝑐, 𝑑+ 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
Example onto function
• Determine whether the function 𝑓 from *𝑎, 𝑏, 𝑐, 𝑑+ 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
correspondence, or a bijection. c 3
d 4
Example
• Determine whether the following functions are bijective or
not?
𝑓: 𝑅 → 𝑅; 𝑓 𝑥 = 𝑥 3
𝑥+1
𝑓: 𝑅 − *0+ → 𝑅; 𝑓 𝑥 =
𝑥
Floor and Ceiling
• floor(x) = X is the largest integer that is less than or
equal to x and ceiling(x) = X is the smallest integer that
is greater than or equal to x
• The floor and ceiling functions give you the nearest
integer up or down.
12/5 = 2.4 2 3
2.7 2 3
−2.7 −3 −2
−2 −2 −2
Identity Functions
• 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
If f(x) = y, then f-1(y) = x
Let f(x) = 2*x
f(x)=y
R f R
f-1
f(4.3)
4.3 8.6
f-1(8.6)
a 1 a 1
b 2 b 2
c 3 c 3
4 d
(f °g)(𝒂) = f (g(a))
Compositions of Functions
(f °g)(a) = f(g(a))
f °g
A B C
g f
g(a) f(b)
a f(g(a))
b = g(a)
(f °g)(a)
Compositions of Functions
g(1) f(5)
f(g(1))=13
1
g(1)=5
(f ° g)(1)
Chapter # 2
Topic # 2.3
Questions 1, 2, 8, 9,10,11,12, 22, 23, 36, 37