Lecture 7 (I) CSC510 Functions
Lecture 7 (I) CSC510 Functions
FUNCTIONS
Example
Suppose that each student in a discrete mathematics class is
assigned a letter grade from the set {A,B,C,D, F}.
Adams – A
Chou – C
Goodfriend – B
Rodriguez – A
Stevens - F
FUNCTIONS
Example
Let A = {1, 2, 3 } and B = {A,B,C,D, F}
Assume f is defined as:
• 1 A
• 1 B
• 3 A
Is f a function?
NO – f(1) is assigned both A and B
Representing FUNCTIONS
Representing Functions
Explicitly state the assignments between
elements in the two sets. Roster notation.
Set builder notation
e.g F(x) = x2
Tabular
Digraph
Mathematical graph
Representing FUNCTIONS
Mathematical graph
Display the graph of the function f (x) = x2 from the set of integers to the set of
integers.
Solution: The graph of f is the set of ordered pairs of the form (x, f (x)) = (x,
x2), where x is an integer.
FUNCTIONS
Example
Let G be the function that assigns a grade to a student in our
discrete mathematics class.
For instance G(Adams) = A
Domain of G = {Adams, Chou, Goodfriend, Rodriguez,
Stevens}
Codomain = {A,B,C,D, F}
Range of G = {A,B,C, F}, because each grade except D is
assigned to some student.
Image of Subset
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)
f (S) = {t | ∃s ∈S (t = f (s))}.
We also use the shorthand {f (s) | s ∈ S} to denote this set.
Image of Subset
Example
Let A = {a, b, c, d, e} and B = {1, 2, 3, 4}
f (a) = 2, f (b) = 1, f (c) = 4, f (d) = 1,
f (e) = 1.
Injective
Surjective
Bijective
Identity
Inverse
Injective / one-to-one
Example
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.
Solution: The function f is one-to-one because f takes on different values at
the four elements of its domain.
Surjective / onto
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: Because all three elements of the codomain are images of elements
in the domain, we see that f is onto.
Bijective / one-to-one and onto
Example
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?
Solution: The function f is one-to-one and onto. It is one-to-one because no
two values in the domain are assigned the same function value.
It is onto because all four elements of the codomain are images of elements
in the domain. Hence, f is a bijection.
a 1
b 2
c 3
d 4
Tips
Suppose that f : A → B.
To show that f is injective Show that if f (x) = f (y) for arbitrary x, y ∈ A with
x = y,then x = y.
To show that f is not injective Find particular elements x, y ∈ A such that x =
y and f (x) = f (y).
To show that f is surjective Consider an arbitrary element y ∈ B and find an
element x ∈ A such that f (x) = y.
To show that f is not surjective Find a particular y ∈ B such that f (x) = y for
all x ∈ A.
Identity
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
Example
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?
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.
Composition
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
Example
Let A = {1,2,3} and B = {a,b,c,d}
f: A → A g: A → B
1→3 1→b
2→1 2→a
3→2 3→d
(f ◦ g)
1→d
2→b
3→a
Composition
Example
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?
(f ◦ g)(x) = f (g(x)) = f (3x + 2) = 2(3x + 2) + 3 = 6x + 7
Note: f ◦ g and g ◦ f are not equal, hence they are not commutative.