Functions Representations
CMSC 56 | Discrete Mathematical Structure for Computer Science
October 13, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
3. Definition 1
Let A and B be two sets. A function f from A to B, denoted f : A
→ 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.
Functions
4. Definition 1
Let A and B be two sets. A function f from A to B, denoted f : A
→ 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.
Functions are sometimes also called mappings or transformations
Functions
7. Definition 2
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, or image, 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.
Functions
8. What are the domain, codomain, and range of the function that
assigns grades to students in a discrete mathematics class. Suppose
that the grades are 1.00 for Ronn, 3.00 for Ricca, 1.75 for Robien,
2.50 for Zin, 3.00 for Angelique, and 1.50 for Mace.
Example
9. If f is a function specified by R, then
f(x) is the grade of x, where x is a student.
Solution
10. If f is a function specified by R, then
f(x) is the grade of x, where x is a student.
f(Ronn) = 1.00
f(Ricca) = 3.00
f(Robien) = 1.75
f(Zin) = 2.50
f(Mace) = 1.50
f(Angelique) = 3.00
Solution
11. If f is a function specified by R, then
f(x) is the grade of x, where x is a student.
f(Ronn) = 1.00 Ronn •
f(Ricca) = 3.00 Ricca •
f(Robien) = 1.75 Robien •
f(Zin) = 2.50 Zin •
f(Mace) = 1.50 Mace •
f(Angelique) = 3.00 Angelique •
Solution
• 1.00
• 1.25
• 1.50
• 1.75
• 2.00
• 2.25
• 2.50
• 2.75
• 3.00
12. Set A (Domain)
{Ronn, Ricca, Robien, Zin, Angelique, Mace}
Set B (Codomain)
{1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.0}
Range
{1.00, 1.50, 1.75, 2.50, 3.0}
Solution
13. Let R be the relation with ordered pairs (Chloei, 21), (Ezekiel, 22),
(Hannah, 24), (Jasper, 21), (Jayven, 23), (Kent, 22), (Maren, 23),
(Robyn, 24), (Sean, 22), and (Vinze, 25). Here each pair consists of a
graduate student and their age. Specify a function determined by
this relation.
Challenge (1/4 Sheet Paper)
14. If f is a function specified by R, then
f(x) is the age of x, where x is a student.
Solution
15. If f is a function specified by R, then
f(x) is the age of x, where x is a student.
f(Chloei) = 21 f(Ezekiel) = 22 f(Hannah) = 24
f(Jasper) = 21 f(Jayven) = 23 f(Kent) = 22
f(Maren) = 23 f(Robyn) = 24 f(Sean) = 22
f(Vinze) = 25.
Solution
16. If f is a function specified by R, then
f(x) is the age of x, where x is a student.
Set A (Domain) = { Chloei, Ezekiel, Hannah, Jasper, Jayven, Kent, Maren,
Robyn, Sean, Vinze }
Solution
17. If f is a function specified by R, then
f(x) is the age of x, where x is a student.
Set A (Domain) = { Chloei, Ezekiel, Hannah, Jasper, Jayven, Kent, Maren,
Robyn, Sean, Vinze }
Set B (Codomain) = { Z+ | f(x) < 100 }
Solution
18. If f is a function specified by R, then
f(x) is the age of x, where x is a student.
Set A (Domain) = { Chloei, Ezekiel, Hannah, Jasper, Jayven, Kent, Maren,
Robyn, Sean, Vinze }
Set B (Codomain) = { Z+ | f(x) < 100 }
Range = { 21, 22, 23, 24, 25 }
Solution
19. Definition 3
If f1 and f2 be functions from A to R. Then f1 + f2 and f1 f2 are
also functions from A to R defined for all x ϵ A by
( f1 + f2 )(x) = f1(x) + f2 (x)
( f1 f2 )(x) = f1(x) f2 (x)
Functions
20. Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) =
x – x2. What are the functions f1 + f2 and f1 f2 ?
Example
21. Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) =
x – x2. What are the functions f1 + f2 and f1 f2 ?
( f1 + f2 )(x) = f1(x) + f2 (x) = x2 + (x – x2) = x
Solution
22. Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) =
x – x2. What are the functions f1 + f2 and f1 f2 ?
( f1 + f2 )(x) = f1(x) + f2 (x) = x2 + (x – x2) = x
( f1 f2 )(x) = f1(x) f2 (x) = x2 (x – x2) = x3 – x4
Solution
23. Definition 4
Let f be a function from A to 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 | Ǝs ϵ S ( t = f(s) ) }
Functions
24. Definition 4
Let f be a function from A to 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 | Ǝs ϵ S ( t = f(s) ) }
We also use the shorthand { f(s) | s ϵ S } to denote this set.
Functions
26. Definition 5
A function f is said to be one-to-one, or an injunction, 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 injective if it is one-to-one.
Injuction Functions
27. Definition 5
A function f is said to be one-to-one, or an injunction, 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 injective if it is one-to-one.
We can express that f is one-to-one using quantifiers as ꓯaꓯb( f(a)
= f(b) → a = b ) or equivalent ꓯaꓯb( a ≠ b → f(a) ≠ f(b) ), where
the universe of discourse is the domain of the function.
Injuction Functions
28. Determine whether the function f from { a, b, c, d } to { 1, 2, 3, 4, 5 }
with f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3 is one-to-one.
Example
29. Determine whether the function f from { a, b, c, d } to { 1, 2, 3, 4, 5 }
with f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3 is one-to-one.
a • • 1
b • • 2
c • • 3
d • • 4
• 5
Solution
30. Determine whether the function f from { a, b, c, d } to { 1, 2, 3, 4, 5 }
with f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3 is one-to-one.
a • • 1
b • • 2
c • • 3
d • • 4
• 5
Solution
The function f is one-to-one
because f takes on different
values at the four elements
of its domain.
31. Definition 6
A function f whose domain and codomain are subsets of the
set of real numbers is called increasing if f(x) ≤ f(y), and strictly
increasing if f(x) < f(y), whenever x < y and x and y are in the
domain of f.
Increasing & Decreasing Functions
32. Definition 6
Similarly, f is called decreasing if f(x) ≥ f(y), and strictly
decreasing if f(x) > f(y), whenever x < y and x and y are in the
domain of f.
Increasing & Decreasing Functions
33. Definition 6
Similarly, f is called decreasing if f(x) ≥ f(y), and strictly
decreasing if f(x) > f(y), whenever x < y and x and y are in the
domain of f.
NOTE:
Strictly increasing and strictly decreasing functions are one-to-one.
Increasing & Decreasing Functions
34. Definition 7
A function f from A to B is called onto, or a surjection, if and
only if for every element b ϵ B there is an element a ϵ A with f(a) =
b. A function f is called surjective if it is onto.
Surjection Functions
35. Definition 7
A function f from A to B is called onto, or a surjection, if and
only if for every element b ϵ B there is an element a ϵ A with f(a) =
b. A function f is called surjective if it is onto.
Remark: A function f is onto if ∀y∃x( f(x) = y ), where the domain
for x is the domain of the function and the domain for y is the
codomain of the function.
Surjection Functions
36. 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?
Example
37. 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?
a • • 1
b • • 2
c • • 3
d •
Solution
38. 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?
a • • 1
b • • 2
c • • 3
d •
Solution
Since all three elements of
the codomain are images of
elements in the domain, we
see that f is onto.
39. Definition 8
The function f is a one-to-one correspondence, or a bijection,
if it is both one-to-one and onto. We also say that such a function is
bijective.
Bijective Functions
40. Let f be the function from { a, b, c, d } to { 1, 2, 3, 4 } with f(a) = 4,
f(b) = 2, f(c) = 1, and f(d) = 3. Is f a bijection?
Example
41. Let f be the function from { a, b, c, d } to { 1, 2, 3, 4 } with f(a) = 4,
f(b) = 2, f(c) = 1, and f(d) = 3. Is f a bijection?
a • • 1
b • • 2
c • • 3
d • • 4
Example
42. Let f be the function from { a, b, c, d } to { 1, 2, 3, 4 } with f(a) = 4,
f(b) = 2, f(c) = 1, and f(d) = 3. Is f a bijection?
a • • 1
b • • 2
c • • 3
d • • 4
Example
Since the function f is one-to-one
and onto, then function f is a
bisection.
43.
44. Let A be a set. The identity function on A is the function ιA : A → A,
where
ιA(x) = x
for all x ϵ A. In other words, the identity function ιA is the function
that assigns each element to itself. The function ιA is one-to-one
and onto, so it is a bijection.
Identity Function
45. Let A = { 1, 2, 3 }, what is ιA(1)? ιA(2)? ιA(3)?
Example
46. Let A = { 1, 2, 3 }, what is ιA(1)? ιA(2)? ιA(3)?
ιA(1) = 1
ιA(2) = 2
ιA(3) = 3
Solution
49. Definition 9
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 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.
Inverse Functions
50. Be sure not to confuse the function f -1 with the function 1 / f , which is
the function that assigns to each x in the domain the value 1 / f(x). Notice
that the latter makes sense only when f(x) is a non-zero real number.
Inverse Functions
51. Be sure not to confuse the function f -1 with the function 1 / f , which is
the function that assigns to each x in the domain the value 1 / f(x). Notice
that the latter makes sense only when f(x) is a non-zero real number.
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.
Inverse Functions
52. 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?
Example
53. 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?
a • • 1
b • • 2
c • • 3
Solution
54. 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?
a • • 1 f -1(1) = c
b • • 2 f -1(2) = a
c • • 3 f -1(3) = b
Solution
55. 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?
a • • 1 f -1(1) = c
b • • 2 f -1(2) = a
c • • 3 f -1(3) = b
Solution
The function f is invertible because it is a one-to-one correspondence.
56. Let f be the function from R to R with f(x) = x2. Is f invertible?
Example
57. Let f be the function from R to R with f(x) = x2. Is f invertible?
Because f(-2) = f(2) = 4, f is not one-to-one. If an inverse function were
defined, it would have to assign two elements to 4. Hence, f is not invertible.
Solution
59. Definition 10
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 for all a ϵ A by f ◦ g, is defined by
(f ◦ g)(a) = f(g(a))
Composition of Functions
60.
61. Let g be the function from the set { a, b, c } to itself such that g(a) =
b, g(b) = c, and g(c) = a. Let f be the function from the set { a, b, c }
to the set { 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?
Example
62. Let g be the function from the set { a, b, c } to itself such that g(a) =
b, g(b) = c, and g(c) = a. Let f be the function from the set { a, b, c }
to the set { 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?
Composition of f and g:
(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
Solution
63. Let g be the function from the set { a, b, c } to itself such that g(a) =
b, g(b) = c, and g(c) = a. Let f be the function from the set { a, b, c }
to the set { 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?
Composition of f and g: Composition of g and f:
(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
Solution
g ◦ f is not defined, because the
range of f is not a subset of the
domain g.
64. Let f and g be the 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?
What is the composition of g and f?
Challenge (1/4 Sheet Paper)
65. Let f and g be the 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?
What is the composition of g and f?
Composition of f and g:
(f ◦ g)(x) = f(g(x)) = f(3x + 2) = 2(3x + 2) + 3 = 6x + 7
Composition of g and f:
(g ◦ f)(x) = g(f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11
Solution
68. 46
37
42
2
35
7
A B C D E F
88.85%
70.52%
82.92%
28.13%
71.88%
36.11%
A B C D E F
Passed,…
Failed,
17.02%
Best Student Performance with only
11.15% FAILURE
Lowest Student Performance with almost
72% FAILURE
CMSC 56
1st Long Exam| AY 2018 – 2019
EXAM PARTSHistogram
Students passed in Part
A
08Students failed
39Students passed
Students failed in Part
D
46
45
PARTA
PARTD
69. ANSWER KEYON SELECTED PARTS
PARTD
1. Thereissomeoneinthis classwhodoesnothavea
goodattitude.
x = “studentinthisclass”
A(x)= “x hasagoodattitude”
a. Ǝx ~A(x)OriginalStatement
b. ~(Ǝx~A(x))= ꓯxA(x)
“Everyoneinthisclasshasa goodattitude.”
2. Norabbitknows Calculus.
x = “rabbit”
C(x)= “x knowscalculus”
a.~ƎxC(x)OriginalStatement
b. ~(~ƎxC(x)) = Ǝx A(x)
“Thereisa rabbitthat knows Calculus.”
PARTF
1. I driveifit istoo dangerousortoo fartobike.
p = “Idrive”
q = “Itistoo dangerous”
r = “Itistoo fartobike”
(qV r)→ p OriginalStatement
a. p → (qV r)Converse
“IfI drive,thenit istoo dangerousor too
fartobike.”
“Itistoo dangerousortoo fartobike ifI
drive.”
b. ~p→~(qV r)Contrapositive
“IfI don’t drive,thenitisnottoo
dangerousortoo fartobike.”
“IfI don’t drive,thenitisnottoo
dangerousandnottoofartobike.”
“Itisnottoodangerousortoo farto bike
ifIdon’t drive.”
“Itisnottoodangerousand nottoo farto
bike if I don’tdrive.”
2.
a. Nostudentinyourclasshastaken acourseinlogic
programming.
x = “studentsinthisclass”
L(x)= “x hastakena coursein
logicprogramming”
ꓯx~L(x)
b. ComputerScienceis easyorcampingisfun, aslong
asitissunnyand thehomework isdone.
m =“computerscienceiseasy”
c = “campingisfun”
s = “itissunny”
h = “homeworkisdone”
(sꓥ h) ↔ ( m V c )
(sꓥ h) → ( m V c )
70. 100.0% Garcia, Patricia Marie
96.0% Samson, Aron Miles
93.0% Honeyman, John
91.0% Jomoc, Gracielou
Patot, Oliver
90.0% Garcia, Michael John
CMSC 56 1st LE Top 5 Scorers
Hinweis der Redaktion
Note that the functions f1 + f2 and f1f2 have been defined by specifying their values at x in
terms of the values of f1 and f2 at x.
The notation f(S) for the image of the set S under the function f is potentially
ambiguous. Here, f(S)denotes a set, and not the value of the function f for the set S.
Why? One-to-one function: A function is one-to-one if and only if f(x) f(y), whenever x y.
ι = Greek letter iota
ι = Greek letter iota
ι = Greek letter iota
Function f is not onto.
In other words, f ◦ g is the function that assigns to the element a of A the element assigned by f to g(a). That is, to find (f ◦ g)(a) we first apply the function g to a to obtain g(a) and then we apply the function f to the result g(a) to obtain (f ◦ g)(a) = f(g(a)). Note that the composition f◦ g cannot be defined unless the range of g is a subset of the domain of f . In Figure 7 the composition of functions is shown.
Remark: Note that even though f ◦ g and g ◦ f are defined for the functions f and g in Example 23, f ◦ g and g ◦ f are not equal. In other words, the commutative law does not hold for the composition of functions.