9. Functions for IT 1R4 Continuation
9. Functions for IT 1R4 Continuation
Introduction
The concept of a function is extremely important in mathematics and
computer science. In discrete mathematics, functions are used in the
definition of such discrete structures as sequences and strings.
Functions are also used to represent how long it takes a computer to
solve problems of a given size. Many computer programs and
subroutines are designed to calculate values of functions.
Introduction
For example, suppose that each student in a discrete mathematics class
is assigned a letter grade from the set {A,B,C,D,F}. And suppose that the
grades are A for Adams, C for Chou, B for Good friend, A for Rodriguez,
and F for Stevens. This assignment is an example of a function.
Domain Codomain
Solution:
Let G be the function that assigns a grade to a student in our discrete
mathematics class. Note that G(Adams) = A, for instance.
The domain of G = {Adams, Chou, Goodfriend, Rodriguez, Stevens}
The codomain of G = {A,B,C,D,F}.
The range of G = {A,B,C,F}.
Functions
Let R be the relation with ordered pairs (Abdul, 22), (Brenda, 24), (Carla, 21), (Desire, 22),
(Eddie, 24), and (Felicia, 22). Here each pair consists of a graduate student and student’s
age. Suppose that the age for graduate students is up to 50. Find the domain, codomain,
and range of this relation.
Solution:
If f is a function specified by R, then f(Abdul) =22, f(Brenda) =24, f(Carla) =21, f(Desire) =22,
f(Eddie) =24, and f(Felicia) =22.
(Here, f(x) is the age of x, where x is a student.)
For the domain, we take the set {Abdul, Brenda, Carla, Desire, Eddie, Felicia}.
For the codomain, we take the set of ages until 50.
For the range, we take the set of different ages of these students {21,22,24}.
Functions
Let f : Z → Z assign the square of an integer to this integer. In other words, f(x)= 𝑥 2 .
What is the domain? codomain? range?
Solution:
Let 𝑓1 and 𝑓2 be functions from R to R such that 𝑓1 (x) = 𝑥 2 and 𝑓2 (x) = 𝑥 − 𝑥 2 . What
are the functions 𝑓1 + 𝑓2 and 𝑓1 𝑓2 ?
Solution:
From the definition of the sum and product of functions, it follows that
𝑓1 𝑓2 (x) = 𝑥 2 + (𝑥 − 𝑥 2 ) = 𝒙𝟑 − 𝒙𝟒 .
Functions
Note: f(S) denotes a set, and not the value of the function f for the set S.
Let A ={a,b,c,d,e} and B ={ 1,2,3,4} with f(a) = 2, f(b) = 1, f(c) = 4, f(d) = 1, and f(e) = 1.
What is the image of the subset S ={b,c,d}?
f(S)={ 1,4}.
One-to-one Function
A One-to-One Function
One-to-one Function
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(x)= 𝑥 2 is not one-to-one because, for instance, f(1) = f(−1) = 1, but 1 ≠ −1.
Determine whether the function f(x)= x +1 from the set of real numbers to itself is one-to-one.
Solution:
Solution:
If every worker is assigned to different jobs (i.e. no two workers working a same job),
then this can become a one-to-one function.
Onto Function
Note: 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.
An Onto Function
Onto Function
Solution:
Because all three elements of the codomain are images
of elements in the domain, we see that f is onto.
Solution:
Because not all elements of the codomain are images of elements in the domain,
we see that f is not onto.
Onto Function
Is the function f(x) = 𝑥 2 from the set of integers to the set of integers onto?
Solution:
The function f is not onto because there is no integer x with 𝑥 2 = −1, for instance.
Is the function f(x)= x +1 from the set of integers to the set of integers onto?
Solution:
This function is onto, because for every integer y there is an integer x such that f(x)= y. To see
this, note that f(x)= y if and only if x +1= y, which holds if and only if x = y −1.
Onto Function
Suppose that each worker in a group of employees is assigned a job from a set of
possible jobs, each to be done by a single worker. When will this be an onto
function?
Solution:
If every job is assigned to different workers (i.e. no job is left unworked), then this
can become an onto function.
Bijection
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.
Identity Function
Correspondences Types
Solution:
The function f is invertible because it is a one-to-one correspondence. The inverse function
𝑓 −1 reverses the correspondence given by f, so 𝑓 −1 (1) = c, 𝑓 −1 (2) = a, and 𝑓 −1 (3) = b.
Let f :Z→Z be such that f(x)= x +1. Is f invertible, and if it is, what is its inverse?
Solution:
The function f has an inverse because it is a one-to-one correspondence. To reverse the
correspondence, suppose that y is the image of x, so that y = x +1. Then x = y −1. This means
that y −1 is the unique element of Z that is sent to y by f. Consequently, 𝑓 −1 (y) = y −1.
Inverse Functions
Let f be the function from R to R with f(x)= 𝑥 2 . Is f invertible?
Solution:
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. (Note we can also show that f
is not invertible because it is not onto.)
Note: Sometimes we can restrict the domain or the codomain of a function, or both, to obtain an invertible function
Show that if we restrict the function f(x)= 𝑥 2 in Example 20 to a function from the set of all
nonnegative real numbers to the set of all nonnegative real numbers, then f is invertible.
Because the function f(x)= 𝑥 2 from the set of nonnegative real numbers to the set of
nonnegative real numbers is one-to-one and onto, it is invertible. Its inverse is given by the
rule 𝑓 −1 (y) =√y.
Composition of Functions
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,
and (f ◦g)(c) = f(g(c))= f(a)=3.
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?
Solution:
Both the compositions f ◦g and g◦f are defined.