Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 2 - 2 Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess.

Similar presentations


Presentation on theme: "1 Chapter 2 - 2 Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess."— Presentation transcript:

1 1 Chapter 2 - 2 Facts about Functions

2 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one): Distinct elements in A map to distinct elements in B. In other words, x ≠ y implies ƒ(x) ≠ ƒ(y) or, equivalently, ƒ(x) = ƒ(y) implies x = y. Example. Let ƒ : N 8 → N be defined by ƒ(x) = 2x mod 8. ƒ is not injective. e.g., ƒ(0) = ƒ(4).

3 3 Quiz (1 minute) Quiz (1 minute). Let ƒ : Z → N be defined by ƒ(x) = x 2. Is ƒ injective? Answer. No. e.g., ƒ(2) = ƒ(–2). Quiz (1 minute). Are any of the three functions injective? log 2, floor, ceiling. Answer. log 2 is injective, but floor and ceiling are not.

4 4 Surjectivity Surjective (also called onto): The range is the codomain. In other words, each b ∊ B has the form b = ƒ(a) for some a ∊ A. Example. ƒ : Z → N defined by ƒ(x) = x 2 is not surjective. E.g., 2 is not a square. Example. ƒ : Z → N defined by ƒ(x) = | x | is surjective but not injective.

5 5 Bijectivity Bijective (also called one-to-one and onto): Both injective and surjective. Example. Let ƒ : N → {a}* by ƒ(n) = a n. Then ƒ is a bijection. Example. The function ƒ : (0, 1) → (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. Proof: If ƒ(x) = ƒ(y), then 3x + 2 = 3y + 2, which implies that x = y. So ƒ is injective. Let y ∊ (2, 5). Does y = ƒ(x) = 3x + 2 for some x ∊ (0, 1)? Solve the equation for x to get x = (y – 2)/3. Since y ∊ (2, 5), we have y – 2 ∊ (0, 3). So x = (y – 2)/3 ∊ (0, 1). Thus ƒ(x) = y. So ƒ is surjective. Thus ƒ is bijective. Quiz (2 minutes). Let ƒ : R → R by ƒ(x) = x 3. Is ƒ bijective?

6 6 Inverse Inverses: If ƒ : A → B is a bijection, then there is an inverse function g : B → A defined by g(b) = a iff ƒ(a) = b. The inverse of ƒ is denoted by ƒ –1. Example. We have observed that the function ƒ : (0, 1) → (2, 5) defined by ƒ(x) = 3x + 2 is a bijection. So ƒ –1 : (2, 5) → (0, 1) is defined by ƒ –1 (x) = (x– 2)/3.

7 7 Example ƒ : N 5 → N 5 defined by ƒ(x) = (4x + 1) mod 5 is a bijection (check each value). So it has an inverse. To see that it is a bijection (without listing the values) and to find a formula for the inverse, we can apply the theorem in the next slide.

8 8 mod and inverses Theorem (mod and inverses) Let n > 1 and ƒ : N n → N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ is bijective iff gcd(a, n) = 1. If so, then ƒ –1 (x) = (kx + c) mod n where ƒ(c) = 0 and 1 = ak + nm.

9 9 Example Let ƒ : N 5 → N 5 be defined by ƒ(x) = (4x + 1) mod 5. Since gcd(4, 5) = 1, the theorem says that ƒ is a bijection. We test values to find c such that ƒ(c) = 0. e.g., ƒ(1) = 0. We can use Euclid’s algorithm to verify that 1 = gcd(4, 5) and then work backwards through the equations to find that 1 = 4(–1) + 5(1). So k = –1. Thus ƒ –1 (x) = (–x + 1) mod 5. (Check it out).

10 10 Quiz (3 minutes) Quiz (3 minutes). Let ƒ : N 13 → N 13 be defined by ƒ(x) = (7x + 5) mod 13. Find ƒ –1 if it exists. Answer. gcd(7, 13) = 1. So ƒ is a bijection. ƒ(3) = 0 and 1 = 7(2) + 13(–1). So we can write ƒ –1 (x) = (2x + 3) mod 13.

11 11 Pigeon Hole Principle If m things are put into n places and m > n, then one place has two or more things. Another way to say this is that if A and B are finite sets with | A | > | B |, then there are no injections from A to B. Example. The function ƒ : N 7 → N 6 defined by ƒ(x) = x mod 6 has ƒ(0) = ƒ(6).

12 12 Example In Mexico City there are two people with the same number of hairs on their heads. Everyone has less than 10 million hairs on their head and the population of Mexico City is more than 10 million. So the pigeon hole principle applies.

13 13 Example If 11 numbers are chosen from S = {1, 2, 3, …, 19, 20}, then for two of the numbers chosen one divides the other. Proof: Each natural number x ≥ 1 has a factorization x = 2 k m for some k ≥ 0 where m is odd. So the numbers in S can be written in this form: 1 = 2 0 ·1, 2 = 2 1 ·1, 3 = 2 0 ·3, 4 = 2 2 ·1, 5 = 2 0 ·5, …, 12 = 2 2 ·3, …, 19 = 2 0 ·19, 20 = 2 2 ·5. Notice that the values of m are in the set {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, which has 10 elements. So by the pigeon hole principle two of the 11 chosen numbers, say x and y, must share the same m. i.e., x = 2 k m and y = 2 j m for k ≠ j. So either x | y or y | x. QED.

14 14 Quiz (2 minutes) Find 10 numbers in S that don’t divide each other. An answer: 6, 7, 8, 9, 11, 13, 15, 17, 19, 20.

15 15 Ciphers and the mod function (some cryptology) Let the letters from a to z be represented by 0, 1, …, 25, respectively. Now any bijection ƒ : N 26 → N 26 can act as a cipher and it’s inverse ƒ –1 can act as a decipher.

16 16 Examples Example (additive cipher). ƒ(x) = (x + 2) mod 26 and ƒ –1 (x) = (x + 24) mod 26. Example (multiplicative cipher). ƒ(x) = 3x mod 26 and ƒ –1 (x) = 9x mod 26. Example (affine cipher). ƒ(x) = (5x + 1) mod 26 and ƒ –1 (x) = (–5x +5) mod 26. Some ciphers keep one or more letters fixed. For example, the cipher ƒ(x) = 3x mod 26 has ƒ(0) = 0, so it sends the letter a to itself. The following theorem can be used to construct ciphers with no fixed letters.

17 17 Mod and Fixed Points Let n > 0 and let ƒ : N n → N n be defined by ƒ(x) = (ax + b) mod n. Then ƒ has no fixed points iff gcd(a – 1, n) does not divide b. Example. Both the additive and affine ciphers in the preceding examples have no fixed points.

18 18 Hash Functions The goal is to use a key of some kind to look up information in a table, but without searching. A hash function maps a set S of keys into a finite set N n of table indexes. The table is called a hash table. Collisions occur if the function is not injective. If there are no collisions, then any key in S is mapped to the index where the information is stored without any searching.

19 19 Example Let S be the students in a class and let h : S → N 366 be defined by letting h(x) be the birthday of x. If two people have the same birthday, then a collision occurs.

20 20 Resolving Collisions by Linear Probing If a collision occurs at index k, then some key is placed in location k and the other colliding keys must be located elsewhere. Linear probing is a technique to search (probe) for an open place in the table by looking linearly at the following places, where g is a fixed gap: (k + g) mod n, (k + 2g) mod n, …, (k + (n – 1)g) mod n.

21 21 Example Let S = {jan, feb, mar, apr, may, jun} and let h : S → N 6 be defined by h(xyz) = p(x) mod 6, where p(x) is the position of x in the alphabet (p(a) = 1, …, p(z) = 26). We’ll place the keys from S into a hash table by first placing jan, then feb, and so on. h(jan) = p(j) mod 6 = 10 mod 6 = 4. So place jan in position 4 of the table. Continue the process to get h(feb) = 0, h(mar) = 1, h(apr) = 1 (collision with mar), h(may) = 1 (collision with mar and apr), and h(jun) = 4 (collision with jan). The table shows the result of resolving collisions by linear probing with a gap of 1. feb mar apr may jan jun 0 1 2 3 4 5

22 22 Quizzes Quiz (2 minutes). Resolve collisions with gap = 2. Answer: feb, mar, jun, apr, jan, may. Quiz (2 minutes). Resolve collisions with gap = 3. Answer: feb, mar, blank, blank, jan, blank. (apr, may, and jun are not placed).

23 23 Property If n is the table size and g is a gap, then gcd(g, n) = 1 implies that all indexes are probed with gap g. So we were lucky to fill the table when the gap was 2. If the table size is a prime number p, then any gap other than p will insure that all keys are entered in the table.

24 24 Section 2.4 Countability We can compare the cardinality of two sets by properties of functions. | A | = | B | means there is a bijection between A and B. | A | ≤ | B | means there is an injection from A to B. | A | < | B | means | A | ≤ | B | and | A | ≠ | B |.

25 25 Example Let A = {3x + 4 | x ∊ N and 0 ≤ 3x + 4 ≤ 1000}. What is | A |? Solution. Notice that 0 ≤ 3x + 4 ≤ 1000 iff – 4/3 ≤ x ≤ 996/3 iff –4/3 ≤ x ≤ 332. So we can rewrite the definition of A = {3x + 4 | x ∊ N and 0 ≤ x ≤ 332}. Now we can define a function ƒ : {0, 1, …, 332} → A by ƒ(x) = 3x + 4. Notice that ƒ is a bijection. So | A | = 333.

26 26 A condition A set S is countable if | S | = | N n | for some n (i.e., S is finite) OR | S | = | N |. Otherwise S is uncountable. If | S | = | N | we sometimes say that S is countably infinite. Example. Z is countable. i.e., | Z | = | N |. To prove this we need to find a bijection between Z and N. Let ƒ : N → Z be defined by ƒ(2k) = k and ƒ(2k + 1) = – (k + 1). Check that ƒ is a bijection.

27 27 Some Countability Results 1. S ⊂ N implies S is countable. 2. S is countable iff | S | ≤ | N |. 3. Subsets and images of countable sets are countable. 4. N × N is countable. Use Cantor’s bijection to associate (x, y) with ((x + y) 2 + 3x + y)/2. 5. If each of the sets S 0, S 1, …, S n, … is countable, then so is S 0 ∪ S 1 ∪ … ∪ S n ….

28 28 Example Is N × N × N countable? Let S = {(x, y, z) ∊ N 3 | x + y + z = n}. Each of sets S 0, S 1, …, S n, … is countable (actually finite). So the union S 0 ∪ S 1 ∪ … ∪ S n … is also countable. But the union is N 3, so N 3 is countable.

29 29 Diagonalization Technique Given a countable listing of sequences S 0, S 1, …, S n, …, where each sequence has the form S n = (a n0, a n1, …, a nn, …) where each a ni ∊ A and | A | ≥ 2. Then there is a sequence over A that is not in the listing. A sequence S not in the listing can be defined by choosing two elements x, y ∊ A and letting S = (a 0, a 1, …, a n, …) where a n = if a nn = x then y else x.

30 30 Example The set of languages over the alphabet {a} is uncountable. Proof: Assume, BWOC, that L 0, L 1, …, L n, …, is a countable listing of all languages over {a}. We can represent each language L n by a sequence S n over {0, 1} as follows: S n = (a n0, a n1, …, a nn, …), where a ni = if a i ∊ L n then 1 else 0. But now the Diagonlization technique applies to tell us there is a sequence not listed. So there is a language that is not listed. So the set of languages is uncountable. QED.

31 31 Cantor’s Result | A | < | power(A) | for any set A. Example. Power(N) is uncountable because | N | < | power(N) |. Example. The closed interval [0, 1] is uncountable. Show that | [0, 1] | = | power(N) |. We can represent each x ∊ [0, 1] as a binary string 0.b 0 b 1 b 2 …. Then associate x with the set S x = {i | b i = 1}. e.g., 0.10101010… is associated with the set {0, 2, 4, 6, …}. This association is a bijection between [0, 1] and power(N).

32 32 The End of Chapter 2 - 2


Download ppt "1 Chapter 2 - 2 Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess."

Similar presentations


Ads by Google