Chapter 6 - Functions
Chapter 6 - Functions
Note that if we
Discrete Structures I change either the domain or the codomain of a function, then we obtain a different
Functions function. If we change the mapping of elements, then we also obtain a different
Departement of Computer Science – IT College – University of Bahrain function.
Dr. Amine Mahjoub, – 2019/2020 – Semester 2
1 Introduction
In many instances we assign to each element of a set a particular element of a se-
cond set (which may be the same as the first). For example, suppose that each student
in a discrete mathematics class is assigned a letter grade from the set {A, B, C, D, F }.
Example : Let f : Z −→ Z assign the square of an integer to this integer. Then,
And suppose that the grades are A for Adams, C for Chou, B for Goodfriend, A for
f (x) = x2 , where the domain of f is the set of all integers, the codomain of f is
Rodriguez, and F for Stevens. This assignment of grades is illustrated in Figure 1.
the set of all integers, and the range of f is the set of all integers that are perfect
This assignment is an example of a function. The concept of a function is extremely
squares, namely, {0, 1, 4, 9, ...}.
important in mathematics and computer science. For example, in discrete mathema-
tics 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 Definition 3. A function f is said to be one − to − one , or an injunction, if and
problems of a given size. Many computer programs and subroutines are designed to only if f (a) = f (b) implies that a = b for all a and b in the domain of f . A function
calculate values of functions. is said to be injective if it is one-to-one.
1
Example 2 : values in the domain are assigned the same function value. It is onto because all
Determine whether the function f (x) = x2 from the set of integers to the set of four elements of the codomain are images of elements in the domain. Hence, f is a
integers is one-to-one. bijection.
Determine whether the function f (x) = x + 1 from the set of real numbers to itself
is one-toone. Example 2 :
Example 1 :
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 ?
Because all three elements of the codomain are images of elements in
the domain, we see that f is onto. This is illustrated in Figure 4.
Note that if the codomain were {1, 2, 3, 4}, then f would not be onto.
Definition 6. 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.
Example 2 :
Is the function f (x) = x2 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 x2 = −1, for
instance.
Example 3 :
Is the function f (x) = x + 1 from the set of integers to the set of integers onto ?
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. Example 1 :
Definition 5. The function f is a one-to-one correspondence, or a bijection, if it is Let f be the function from {a, b, c} to {1, 2, 3} such that f (a) = 2, f (b) = 3, and
both one-to-one and onto.We also say that such a function is bijective. f (c) = 1.
Is f invertible, and if it is, what is its inverse ?
Example 1 : The function f is invertible because it is a one-to-one correspondence. The inverse
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, function f −1 reverses the correspondence given by f , so f −1 (1) = c, f −1 (2) = a,
and f (d) = 3. Is f a bijection ? and f −1 (3) = b.
Solution : The function f is one-to-one and onto. It is one-to-one because no two
2
Example 2 : 10. f : R =⇒ R, f (x) = d0.5x − 1e.
Let f : Z → Zbe such that f (x) = x + 1. Is f invertible, and if it is, what is its
inverse ? 11. f : Z =⇒ Z+ , f (x) = bx + 0.5c + 1.
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
12. f : Z =⇒ R, f (x) = bx − 1c + 0.5.
x = y − 1. This means that y − 1 is the unique element of Z that is sent to y by f .
Consequently, f −1 (y) = y − 1.
13. f : Z+ =⇒ Z, f (x) = bx − 1c + 0.5.
Definition 7. The floor function assigns to the real number x the largest integer
that is less than or equal to x. The value of the floor function at bxc is denoted by x.
14. f : R =⇒ R, f (x) = 0.5dx − 5e − 0.5.
The ceiling function assigns to the real number x the smallest integer that is greater
than or equal to x. The value of the ceiling function at x is denoted by dxe.
15. f : R =⇒ R, show that f (x) = |2 − x| − 2.
x+1
18. f : R − {−2} =⇒ R, show that f (x) = .
Exercises x+2
2x − 1
Find if the given expression is a function, if so is it injective or subjective or 19. f : Z =⇒ Z, show that f (x) = .
3x + 4
bijective.
2x − 1
1. f : R =⇒ R, f (x) = 2x − 7. 20. f : Z =⇒ R − { 23 }, show that f (x) = .
3x + 4
2x + 1
2. f : R =⇒ Z, f (x) = 1 − x. 21. f : R− =⇒ R− , show that f (x) = .
x
3. f : Z =⇒ R+ , f (x) = x + 2.
4. f : R =⇒ R, f (x) = x2 − x − 2.
7. f : R− =⇒ R+ , f (x) = (x − 1)2 − 1.
8. f : R+ =⇒ R+ , f (x) = (x + 2)2 + 2.
9. f : R+ =⇒ N, f (x) = x2 − 2x + 1.
Discrete Structure I – Functions Generated by LATEX