Page 161 - Discrete Mathematics and Its Applications
P. 161
140 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
of a function, then we obtain a different function. If we change the mapping of elements, then
we also obtain a different function.
Examples 1–5 provide examples of functions. In each case, we describe the domain, the
codomain, the range, and the assignment of values to elements of the domain.
EXAMPLE 1 What are the domain, codomain, and range of the function that assigns grades to students
described in the first paragraph of the introduction of this section?
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 is the set {Adams, Chou, Goodfriend,
Rodriguez, Stevens}, and the codomain is the set {A, B, C, D, F}. The range of G is the set
{A, B, C, F}, because each grade except D is assigned to some student. ▲
EXAMPLE 2 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 this student’s
age. Specify a function determined by 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}. We also need to specify a codomain, which needs to contain all possible ages
of students. Because it is highly likely that all students are less than 100 years old, we can take
the set of positive integers less than 100 as the codomain. (Note that we could choose a different
codomain, such as the set of all positive integers or the set of positive integers between 10 and
90, but that would change the function. Using this codomain will also allow us to extend the
function by adding the names and ages of more students later.) The range of the function we
have specified is the set of different ages of these students, which is the set {21, 22, 24}. ▲
EXAMPLE 3 Let f be the function that assigns the last two bits of a bit string of length 2 or greater to that
string. For example, f (11010) = 10. Then, the domain of f is the set of all bit strings of length
2 or greater, and both the codomain and range are the set {00, 01, 10, 11}. ▲
2
EXAMPLE 4 Let f : Z → Z assign the square of an integer to this integer. Then, f(x) = x , where the domain
of f is the set of all integers, the codomain of f is the set of all integers, and the range of f is
the set of all integers that are perfect squares, namely, {0, 1, 4, 9,... }. ▲
EXAMPLE 5 The domain and codomain of functions are often specified in programming languages. For
instance, the Java statement
int floor(float real){...}
and the C++ function statement
int function (float x){...}
both tell us that the domain of the floor function is the set of real numbers (represented by
floating point numbers) and its codomain is the set of integers. ▲
A function is called real-valued if its codomain is the set of real numbers, and it is called
integer-valued if its codomain is the set of integers. Two real-valued functions or two integer-
valued functions with the same domain can be added, as well as multiplied.