• 沒有找到結果。

Partial Functions

A program designed to evaluate a function may not produce the correct value of the function for all elements in the domain of this function. For example, a program may not produce a correct value because evaluating the function may lead to an infinite loop or an overflow. Similarly, in abstract mathematics, we often want to discuss functions that are defined only for a subset of the real numbers, such as 1/x,

x, and arcsin (x). Also, we may want to use such notions as the “youngest child” function, which is undefined for a couple having no children, or the “time of sunrise,” which is undefined for some days above the Arctic Circle. To study such situations, we use the concept of a partial function.

DEFINITION 13 A partial functionf from a set A to a set B is an assignment to each element a in a subset ofA, called the domain of definition of f , of a unique element b in B. The sets A and B are called the domain and codomain off , respectively. We say that f is undefined for elements inA that are not in the domain of definition of f . When the domain of definition of f equals A, we say that f is a total function.

Remark: We writef : A → B to denote that f is a partial function from A to B. Note that this is the same notation as is used for functions. The context in which the notation is used determines whetherf is a partial function or a total function.

EXAMPLE 32 The functionf : Z → R where f (n) =

n is a partial function from Z to R where the domain of definition is the set of nonnegative integers. Note thatf is undefined for negative integers.

Exercises

2. Determine whetherf is a function from Z to R if a) f (n) = ±n.

b) f (n) =n2+ 1.

c) f (n) = 1/(n2− 4).

3. Determine whetherf is a function from the set of all bit strings to the set of integers if

a) f (S) is the position of a 0 bit in S.

b) f (S) is the number of 1 bits in S.

c) f (S) is the smallest integer i such that the ith bit of S is 1 and f (S) = 0 when S is the empty string, the string with no bits.

4. Find the domain and range of these functions. Note that in each case, to find the domain, determine the set of elements assigned values by the function.

a) the function that assigns to each nonnegative integer its last digit

b) the function that assigns the next largest integer to a positive integer

c) the function that assigns to a bit string the number of one bits in the string

d) the function that assigns to a bit string the number of bits in the string

5. Find the domain and range of these functions. Note that in each case, to find the domain, determine the set of elements assigned values by the function.

a) the function that assigns to each bit string the number of ones in the string minus the number of zeros in the string

b) the function that assigns to each bit string twice the number of zeros in that string

c) the function that assigns the number of bits left over when a bit string is split into bytes (which are blocks of 8 bits)

d) the function that assigns to each positive integer the largest perfect square not exceeding this integer 6. Find the domain and range of these functions.

a) the function that assigns to each pair of positive inte-gers the first integer of the pair

b) the function that assigns to each positive integer its largest decimal digit

c) the function that assigns to a bit string the number of ones minus the number of zeros in the string d) the function that assigns to each positive integer the

largest integer not exceeding the square root of the integer

e) the function that assigns to a bit string the longest string of ones in the string

7. Find the domain and range of these functions.

a) the function that assigns to each pair of positive inte-gers the maximum of these two inteinte-gers

b) the function that assigns to each positive integer the number of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 that do not appear as decimal digits of the integer

c) the function that assigns to a bit string the number of times the block 11 appears

d) the function that assigns to a bit string the numerical position of the first 1 in the string and that assigns the value 0 to a bit string consisting of all 0s

8. Find these values.

10. Determine whether each of these functions from {a, b, c, d} to itself is one-to-one.

a) f (a) = b, f (b) = a, f (c) = c, f (d) = d b) f (a) = b, f (b) = b, f (c) = d, f (d) = c c) f (a) = d, f (b) = b, f (c) = c, f (d) = d 11. Which functions in Exercise 10 are onto?

12. Determine whether each of these functions from Z to Z is one-to-one.

a) f (n) = n − 1 b) f (n) = n2+ 1 c) f (n) = n3 d) f (n) = n/2

13. Which functions in Exercise 12 are onto?

14. Determine whetherf : Z × Z → Z is onto if

16. Consider these functions from the set of students in a discrete mathematics class. Under what conditions is the function one-to-one if it assigns to a student his or her a) mobile phone number.

b) student identification number.

c) final grade in the class.

d) home town.

17. Consider these functions from the set of teachers in a school. Under what conditions is the function one-to-one if it assigns to a teacher his or her

a) office.

b) assigned bus to chaperone in a group of buses taking students on a field trip.

c) salary.

d) social security number.

18. Specify a codomain for each of the functions in Exercise 16. Under what conditions is each of these functions with the codomain you specified onto?

19. Specify a codomain for each of the functions in Exercise 17. Under what conditions is each of the functions with the codomain you specified onto?

20. Give an example of a function from N to N that is a) one-to-one but not onto.

b) onto but not one-to-one.

c) both onto and one-to-one (but different from the iden-tity function).

d) neither one-to-one nor onto.

21. Give an explicit formula for a function from the set of integers to the set of positive integers that is

a) one-to-one, but not onto.

b) onto, but not one-to-one.

c) one-to-one and onto.

d) neither one-to-one nor onto.

22. Determine whether each of these functions is a bijection from R to R.

a) f (x) = −3x + 4 b) f (x) = −3x2+ 7 c) f (x) = (x + 1)/(x + 2) d) f (x) = x5+ 1

23. Determine whether each of these functions is a bijection from R to R. that f (x) is strictly increasing if and only if the func-tiong(x) = 1/f (x) is strictly decreasing.

25. Let f : R → R and let f (x) > 0 for all x ∈ R. Show thatf (x) is strictly decreasing if and only if the func-tiong(x) = 1/f (x) is strictly increasing.

26. a) Prove that a strictly increasing function from R to it-self is one-to-one.

b) Give an example of an increasing function from R to itself that is not one-to-one.

27. a) Prove that a strictly decreasing function from R to itself is one-to-one.

b) Give an example of a decreasing function from R to itself that is not one-to-one.

28. Show that the functionf (x) = ex from the set of real numbers to the set of real numbers is not invertible, but if the codomain is restricted to the set of positive real numbers, the resulting function is invertible.

29. Show that the function f (x) = |x| from the set of real numbers to the set of nonnegative real numbers is not invertible, but if the domain is restricted to the set of non-negative real numbers, the resulting function is invertible.

30. LetS = {−1, 0, 2, 4, 7}. Find f (S) if

a) Show that if bothf and g are one-to-one functions, thenf ◦ g is also one-to-one.

b) Show that if bothf and g are onto functions, then f ◦ g is also onto. and d are constants. Determine necessary and suffi-cient conditions on the constantsa, b, c, and d so that f ◦ g = g ◦ f .

39. Show that the functionf (x) = ax + b from R to R is invertible, wherea and b are constants, with a = 0, and find the inverse off .

40. Letf be a function from the set A to the set B. Let S and T be subsets of A. Show that

a) f (S ∪ T ) = f (S) ∪ f (T ).

b) f (S ∩ T ) ⊆ f (S) ∩ f (T ).

41. a) Give an example to show that the inclusion in part (b) in Exercise 40 may be proper.

b) Show that iff is one-to-one, the inclusion in part (b) in Exercise 40 is an equality.

Letf be a function from the set A to the set B. Let S be a subset ofB. We define the inverse image of S to be the subset ofA whose elements are precisely all pre-images of all ele-ments ofS. We denote the inverse image of S by f−1(S), so f−1(S) = {a ∈ A | f (a) ∈ S}. (Beware: The notation f−1is used in two different ways. Do not confuse the notation intro-duced here with the notationf−1(y) for the value at y of the

inverse of the invertible functionf . Notice also that f−1(S), the inverse image of the setS, makes sense for all functions f , not just invertible functions.)

42. Letf be the function from R to R defined by f (x) = x2. Find except whenx is midway between two integers, when it is the larger of these two integers.

47. Show thatx − 12 is the closest integer to the number x, except whenx is midway between two integers, when it is the smaller of these two integers.

48. Show that ifx is a real number, then x − x = 1 if x is not an integer andx − x = 0 if x is an integer.

49. Show that ifx is a real number, then x − 1 < x ≤ x ≤

x < x + 1.

50. Show that ifx is a real number and m is an integer, then

x + m = x + m.

51. Show that ifx is a real number and n is an integer, then a) x < n if and only if x < n.

b) n < x if and only if n < x.

52. Show that ifx is a real number and n is an integer, then a) x ≤ n if and only if x ≤ n.

55. The function INT is found on some calculators, where INT(x) = x when x is a nonnegative real number and INT(x) = x when x is a negative real number. Show that this INT function satisfies the identity INT(−x) =

−INT(x).

56. Leta and b be real numbers with a < b. Use the floor and/or ceiling functions to express the number of inte-gersn that satisfy the inequality a ≤ n ≤ b.

57. Leta and b be real numbers with a < b. Use the floor and/or ceiling functions to express the number of inte-gersn that satisfy the inequality a < n < b.

58. How many bytes are required to encoden bits of data wheren equals

a) 4? b) 10? c) 500? d) 3000?

59. How many bytes are required to encode n bits of data wheren equals

a) 7? b) 17? c) 1001? d) 28,800?

60. How many ATM cells (described in Example 28) can be transmitted in 10 seconds over a link operating at the fol-lowing rates?

a) 128 kilobits per second (1 kilobit= 1000 bits) b) 300 kilobits per second

c) 1 megabit per second (1 megabit= 1,000,000 bits) 61. Data are transmitted over a particular Ethernet network

in blocks of 1500 octets (blocks of 8 bits). How many blocks are required to transmit the following amounts of data over this Ethernet network? (Note that a byte is a synonym for an octet, a kilobyte is 1000 bytes, and a megabyte is 1,000,000 bytes.)

67. Draw graphs of each of these functions.

a) f (x) = x +12 b) f (x) = 2x + 1

c) f (x) = x/3 d) f (x) = 1/x

e) f (x) = x − 2 + x + 2

f ) f (x) = 2xx/2 g) f (x) = x −12 +12 68. Draw graphs of each of these functions.

a) f (x) = 3x − 2 b) f (x) = 0.2x

c) f (x) = −1/x d) f (x) = x2

e) f (x) = x/2x/2 f ) f (x) = x/2 + x/2

g) f (x) = 2 x/2 +12

69. Find the inverse function off (x) = x3+ 1.

70. Suppose that f is an invertible function from Y to Z and g is an invertible function from X to Y . Show that the inverse of the composition f ◦ g is given by (f ◦ g)−1= g−1◦ f−1.

71. LetS be a subset of a universal set U. The characteristic functionfSofS is the function from U to the set {0, 1} are finite sets with|A| = |B|. Show that f is one-to-one if and only if it is onto.

73. Prove or disprove each of these statements about the floor and ceiling functions.

74. Prove or disprove each of these statements about the floor and ceiling functions.

x  for all positive real numbers x.

e) x + y + x + y ≤ 2x + 2y for all real numbersx and y.

75. Prove that ifx is a positive real number, then a) √

77. For each of these partial functions, determine its domain, codomain, domain of definition, and the set of values for which it is undefined. Also, determine whether it is a total function. 78. a) Show that a partial function fromA to B can be viewed

as a functionffromA to B ∪ {u}, where u is not an

b) Using the construction in (a), find the functionf corresponding to each partial function in Exercise 77.

79. a) Show that if a setS has cardinality m, where m is a positive integer, then there is a one-to-one correspon-dence betweenS and the set {1, 2, . . . , m}.

b) Show that ifS and T are two sets each with m ele-ments, wherem is a positive integer, then there is a one-to-one correspondence betweenS and T .

∗80. Show that a set S is infinite if and only if there is a proper subsetA of S such that there is a one-to-one correspon-dence betweenA and S.

2.4 Sequences and Summations

Introduction

Sequences are ordered lists of elements, used in discrete mathematics in many ways. For ex-ample, they can be used to represent solutions to certain counting problems, as we will see in Chapter 8. They are also an important data structure in computer science. We will often need to work with sums of terms of sequences in our study of discrete mathematics. This section reviews the use of summation notation, basic properties of summations, and formulas for the sums of terms of some particular types of sequences.

The terms of a sequence can be specified by providing a formula for each term of the sequence. In this section we describe another way to specify the terms of a sequence using a recurrence relation, which expresses each term as a combination of the previous terms. We will introduce one method, known as iteration, for finding a closed formula for the terms of a sequence specified via a recurrence relation. Identifying a sequence when the first few terms are provided is a useful skill when solving problems in discrete mathematics. We will provide some tips, including a useful tool on the Web, for doing so.

Sequences

A sequence is a discrete structure used to represent an ordered list. For example, 1, 2, 3, 5, 8 is a sequence with five terms and 1, 3, 9, 27, 81, . . . , 3n, . . . is an infinite sequence.

DEFINITION 1 A sequence is a function from a subset of the set of integers (usually either the set{0, 1, 2, . . .}

or the set{1, 2, 3, . . .}) to a set S. We use the notation anto denote the image of the integern.

We callana term of the sequence.

We use the notation{an} to describe the sequence. (Note that an represents an individual term of the sequence{an}. Be aware that the notation {an} for a sequence conflicts with the notation for a set. However, the context in which we use this notation will always make it clear when we are dealing with sets and when we are dealing with sequences. Moreover, although we have used the lettera in the notation for a sequence, other letters or expressions may be used depending on the sequence under consideration. That is, the choice of the lettera is arbitrary.) We describe sequences by listing the terms of the sequence in order of increasing subscripts.

EXAMPLE 1 Consider the sequence{an}, where an= 1

n.

The list of the terms of this sequence, beginning witha1, namely, a1, a2, a3, a4, . . . ,

starts with 1,1

2,1 3,1

4, . . . .

DEFINITION 2 A geometric progression is a sequence of the form a, ar, ar2, . . . , arn, . . .

where the initial terma and the common ratio r are real numbers.

Remark: A geometric progression is a discrete analogue of the exponential functionf (x) = arx.

EXAMPLE 2 The sequences{bn} with bn = (−1)n,{cn} with cn = 2 · 5n, and{dn} with dn = 6 · (1/3)n are geometric progressions with initial term and common ratio equal to 1 and−1; 2 and 5; and 6 and 1/3, respectively, if we start at n = 0. The list of terms b0, b1, b2, b3, b4, . . . begins with

1, −1, 1, −1, 1, . . . ;

the list of termsc0, c1, c2, c3, c4, . . . begins with 2, 10, 50, 250, 1250, . . . ;

and the list of termsd0, d1, d2, d3, d4, . . . begins with 6, 2,2

3,2 9, 2

27, . . . .

DEFINITION 3 An arithmetic progression is a sequence of the form a, a + d, a + 2d, . . . , a + nd, . . .

where the initial terma and the common difference d are real numbers.

Remark: An arithmetic progression is a discrete analogue of the linear functionf (x) = dx + a.

EXAMPLE 3 The sequences{sn} with sn= −1 + 4n and {tn} with tn = 7 − 3n are both arithmetic progres-sions with initial terms and common differences equal to−1 and 4, and 7 and −3, respectively, if we start atn = 0. The list of terms s0, s1, s2, s3, . . . begins with

−1, 3, 7, 11, . . . ,

and the list of termst0, t1, t2, t3, . . . begins with

7, 4, 1, −2, . . . .

Sequences of the form a1, a2, . . . , an are often used in computer science. These finite sequences are also called strings. This string is also denoted by a1a2. . . an. (Recall that bit strings, which are finite sequences of bits, were introduced in Section 1.1.) The length of a string is the number of terms in this string. The empty string, denoted byλ, is the string that has no terms. The empty string has length zero.

EXAMPLE 4 The stringabcd is a string of length four.