1 / 18

Section 1.8: Functions

Section 1.8: Functions. A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping and then refine this notion to arrive at the definition of a function.

warner
Télécharger la présentation

Section 1.8: Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping and then refine this notion to arrive at the definition of a function.

  2. Def: Let A and B be sets. A mapping m from A to B is a subset of A  B. We denote that m is a mapping from A to B by m: A  B. Ex: Let A = {1, 2, 3} and B = {a, b, c}. Then A  B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c), (3, a), (3, b), (3, c)}. So m = {(1, a), (1, b), (2, a), (2, c)} is a mapping from A to B. Note that this is just one possible mapping from A to B. [How many poss.?] Since a mapping from A to B is a subset of A  B then it is a member of P(A  B). So we can reduce this question to “what is |P(A  B)|?”. |P(A  B)| = 2|A  B| = 29 = 512. [Pictorial representation of m …] A B 1 a 2 b 3 c There are 9 possible arrows that could be drawn. They correspond to the 9 members of A  B. A map is very general. We place no restrictions on what arrows can be drawn.

  3. Def: Let A and B be sets. A function f from A to B is a mapping from A to B such that for each x  A, exactly one ordered pair of the form (x, y) appears in f, for some y  B. That is, each element of A is mapped to exactly one element of B. We use the notation f: A  B to denote that f is a function from A to B. Ex: Let A = {1, 2, 3} and B = {a, b, c} as before. Then f = {(1, a), (2, b), (3, a)} is a function from A to B. Note that this is just one possible function from A to B. [How many poss.?] We have 3 possible choices of where to map each element of A (to a, b, or c). So there are 3 choices for 1, 3 for 2, and 3 for 3. 3*3*3= 27. A B 1 a 2 b 3 c We must draw exactly 1 arrow from each member of A. Each of the 3 arrows we must draw must go to 1 of the 3 possible destinations in the set B. We do allow more than 1 arrow to have the same dest.

  4. Def: Let f be a function from A to B. The set A is called the domain of f and the set B is called the codomain of f. For each x  A, the y  B for which (x, y)  f (there must be exactly one such y for each x) is called the value of f(x). We denote this as f(x) = y. We also say that y is the image of x under f. The element x is called apre-image of y. The range of f is the set of all images of elements of A under f. Ex: Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, a), (2, b), (3, a)}. Then {1, 2, 3} is the domain of f and {a, b, c} is the codomain of f. We can see that f(1) = a, f(2) = b, and f(3) = a. So a is the image of 1 under f, b is the image of 2 under f, and a is the image of 3 under f. We find that 1 is a pre-image of a under f. It turns out that 3 is also a pre-image of a under f. So a has two pre-images under f, namely 1 and 3. Finally, 2 is a pre-image of b under f. The range of f is {a, b}. This is the set of all images of elements of A. The range of f is always a subset of the codomain of f.

  5. Ex: Let f: Z Z assign the square of an integer to the integer. That is, for each x  Z, f(x) = x2. Both the domain and codomain of f are the set of integers. We can see that f(-5) = 25, f(7) = 49, f(0) = 0, and f(-1) = 1. The range of f turns out to be {0, 1, 4, 9, 16, 25, 36, 49, … }. That is, the set of all integers that are perfect squares. Def: Let f: A  B and let S  A. We define the image of S to be the subset of B that consists of the images of the elements of S. We denote the image of S by f(S) so we have f(S) = { y  B | y = f(x) for some x  S}. Note that by using this definition, we can denote the range of f as f(A). Ex: 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 f({b, c, d})? f({b, c, d}) = {1, 4, 1} = {1, 4}.

  6. Def: A function f: A  B is said to be one-to-one (or injective) if and only if f(x) = f(y) implies x = y for all x and y in A. That is, for each element b  B, there is at most one element from A that maps to it. Ex: Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, a), (2, b), (3, a)}. This function is not one-to-one since more that one element maps to a. Ex: Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, b), (2, c), (3, a)}. This function is one-to-one. Contrast one-to-one with many-to-one. A B 1 a 2 b 3 c The requirement for a function to be one-to-one is that no arrows in the diagram point to the same element of B. If A and B are finite sets then for f: A  B to be 1-1 it is necessary for |A|  |B|. Ex: Let A = {a, b, c, d} and B = {1, 2, 3, 4, 5} and f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3. This function is one-to-one.

  7. Def: A function f: A  B is said to be onto (or surjective) if and only if for every element b  B, there is at least one element from A that maps to it. That is, f: A  B is onto iff yBxA[f(x) = y]. Ex: Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, a), (2, b), (3, a)}. This function is not onto since there is no element that maps to c. Ex: Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, b), (2, c), (3, a)}. This function is onto. A B 1 a 2 b 3 c The requirement for a function to be onto is that each element of B has at least one arrow pointing into it. If A and B are finite sets then for f: A  B to be onto it is necessary for |A|  |B|. Ex: Let A = {a, b, c, d} and B = {1, 2, 3, 4, 5} and f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3. This function is not onto (nothing maps to 2).

  8. Remark: Let f be a function from A to B. The condition that f is onto is equivalent to the condition that the range of f equals the codomain B. Ex: Let f: Z Z be defined by f(x) = x2. [Is it 1-1? Is it onto?] f is not 1-1 since f(1) = f(-1) = 1, but 1  -1. f is not onto since no element maps to 2. We’ve also seen f(Z)  Z. Ex: Let f: Z Z be defined by f(x) = x + 1. [Is it 1-1? Is it onto?] f is 1-1: Let j, k  Z such that f(j) = f(k). Then j + 1 = k + 1. So j = k. f is onto: Let k  Z. Then f(k – 1) = k – 1 + 1 = k. Since k  Z then k – 1  Z. So we found a member of the domain that maps to k. Def: A function f: A  B is said to be one-to-one correspondence (or a bijection) if and only if f is both one-to-one and onto. Ex: We have seen that f: Z Z defined by f(x) = x + 1 is a bijection.

  9. Remark: Consider the case where f is a function from A to B and A and B are finite sets such that |A| = |B|. In this very special case f is one-to-one if and only if f is onto. Proof: Let A and B be finite sets with |A| = |B| = n. Let f: A  B. () Assume that f is one-to-one. Then for each y  B there is at most one x  A such that f(x) = y. Since f is a function, then each x  A maps to exactly one y  B. So there are n elements in A, each of which maps to exactly one of the n elements of B. Since each of the n elements of A must map to a different element of B, then we must use all n elements of B. So each element of B is mapped to by an element of A. So f is onto. () Assume that f is onto. Then for each y  B there is at least one x  A such that f(x) = y. And since f is a function, then each x  A maps to exactly one y  B. So there are n elements in A, each of which maps to exactly one of the n elements of B. Since all elements of B are mapped to, then each element of A must map to a different element of B. So f is one-to-one.

  10. Def: Let A be a set. The identity function on A is the function iA: A  A defined by iA(x) = x for all x  A. That is, the identity function on the set A maps each element of A to itself. Remark: The identity function on any set A is always a bijection. Clearly the identity function is onto since for any element x in A, the element x maps to it. Also the function is easily seen to be 1-1 for if we have two members x and y from the set A such that iA(x) = iA(y) then x = y. Remark: Note that we have subscripted the identity function on a set with the set’s name, A. We do this to remind ourselves that a function is not only defined by the rule of how to map an element from the domain to its value in the range, but also by the domain and codomain. Ex: The function f: Z Z defined by f(x) = x2 is a different function from the function f: Z {0, 1, 4, 9, 16, 25, …} defined by f(x) = x2. Indeed, the second function f is onto whereas the first is not.

  11. Consider a bijection f: A  B. Since f is one-to-one then each element y  B has at most one element from A that maps to it. Since f is onto, then each element y  B has at least one element from A that maps to it. Hence each element y  B has exactly one element from A that maps to it. In such a case, we can define a new function from B to A by simply reversing the arrows. That is we define f-1: B  A by f-1(y) = x where x is the unique element of A that maps to y under the bijection f. This new function is called the inverse function of f. Note that the above construction is only possible if the original function f is a bijection. If we attempt to form the inverse of a function which is not a bijection, the resulting map will not be a function. That is, we can always draw the original function with sets and arrows and just reverse the arrows to construct an inverse map, but this map will be a function if and only if the original function was a bijection. [What happens if f wasn’t onto?] [What if f wasn’t 1-1?]

  12. Inverse functions are often important. They are so important that we often wish to construct an inverse function even when we are thwarted by the original function not being a bijection. Is there some way that we could (very naturally) take a function that is not a bijection but construct an “inverse” function for it? There are two things to consider: If the function is not 1-1 or if the function is not onto. If the original function is not 1-1 then there is not much we can do. However, if the original function is 1-1 but not onto then we do have a nice alternative. Let f: A  B be a 1-1 function. Then if f is not already onto, we can construct an onto function that does the same thing as f, by simply restricting the codomain B to the range f(A). That is, f: A  B is not onto simply because there are some elements in B which are not mapped to by any elements of A under f. So simply throw those elements out to form the new function f: A  f(A). Now f is onto. Also f is clearly 1-1 since the original f was. So f is a bijection and we can now form the inverse of f.

  13. Ex: Let f: {a, b, c}  {1, 2, 3} be defined by f(a) = 2, f(b) = 3, f(c) = 1. Then f is a bijection and hence f is invertible. The inverse of f is given f-1: {1, 2, 3}  {a, b, c} where f-1(1) = c, f-1(2) = a, and f-1(3) = b. Remark: Note that a function f from A to B where A and B are both finite sets can only be a bijection if |A| = |B|. This follows from our previous observations that such a function between finite sets can only be 1-1 if |A|  |B|. And such a function can only be onto if |A|  |B|. Hence such a function can only be both 1-1 and onto (and hence a bijection) if |A| = |B|. So |A| = |B| is a necessary (but not sufficient) condition for a function f between finite sets to be a bijection. That is, you can never find a bijection between finite sets that have different cardinalities. That it is not a sufficient condition means that simply knowing that |A| = |B| does not mean that any function from A to B is a bijection. Consider f: {a, b, c}  {1, 2, 3} defined by f(a) = 1, f(b) = 1, f(c) = 2, for example.

  14. Ex: Let f: Z Z be defined by f(x) = x + 1 for all x  Z. We have seen that f is a bijection and hence f is invertible. The inverse of f is given f-1: Z  Z where f-1(x) = x – 1 for all x  Z. [Draw it] Def: Let g be a function from the set A to the set B and let f be a function from the set B to the set C. The composition of the functions f and g, denoted by f g, is defined by (f g)(a) = f(g(a)). Ex: Let g: {1, 2, 3}  {4, 5, 6} be defined g(1) = 4, g(2) =5, g(3) = 5. Let f: {4, 5, 6}  {7, 8, 9} be defined f(4) = 7, f(5) = 9, f(6) = 9. Then f g: {1, 2, 3}  {7, 8, 9} is (f g)(1) = f(g(1)) = f(4) = 7, (f g)(2) = f(g(2)) = f(5) = 9, and (f g)(3) = f(g(3)) = f(5) = 9. A g B f C 1 4 7 2 5 8 3 6 9 A f g C 1 7 2 8 3 9

  15. Ex: Let f: Z Z be defined by f(x) = 2x + 3 and let g: Z Z be defined by g(x) = 3x + 2. In this case we can define both f g and gf since A=B=C. Both f g and gf will be functions from Zto Z. f g(x) = f(g(x)) = f(3x + 2) = 2*(3x + 2) + 3 = 6x + 4 + 3 = 6x + 7. gf(x) = g(f(x)) = g(2x + 3) = 3*(2x + 3) + 2 = 6x + 9 + 2 = 6x + 11. Ex: Let f: A  B be a bijection. Then we can form the inverse of f, f-1: B  A. In this case we can define both f f-1 and f-1f. But this time f f-1 will go from B to B whereas f-1f will go from A to A. Let us consider how each of the compositions operates on an element. For this, we need to denote where an element is mapped to. So let a be an element of A such that f(a) = b. f f-1(b) = f(f-1(b)) = f(a) = b. So f f-1 sends b to b for any b  B. f-1f(a) = f-1(f(a)) = f-1(b) = a. So f-1f sends a to a for any a  A. Hence f f-1 = iB and f-1f = iA.

  16. Def: The floor function is the function from R to Z which assigns to a real number x, the largest integer that is less than or equal to x. The ceiling function is the function from R to Z which assigns to a real number x, the smallest integer that is greater than or equal to x. That is, the floor function rounds a real number down to an integer (by truncating at the decimal point) and the ceiling function rounds a real number up to an integer. The floor function applied to x is denoted as x whereas the ceiling function applied to x is denoted as x. Ex: 1.1 = 1 1/2 = 0 -1.1 = -2 -2.99 = -3 1.1 = 2 1/2 = 1 -1.1 = -1 -2.99 = -2 Remark: Sometimes it is helpful to draw a number line (top to bottom) in order to not get confused when dealing with negative numbers. Remark: The floor or ceiling of an integer x, is simply x. 1.0 = 1 1.0 = 1 10/5 = 2 10/5 = 2

  17. Ex: If we store data in units of bytes (8 bits) then how many bytes are required to store 100 bits of data? Since we have 100 bits of data to store, 12 bytes (which is 96 bits) isn’t quite enough. But 13 bytes (which is 104 bits) suffices. So we need 13 bytes. This sort of computation can be done using the ceiling function: 100/8 = 12.5 = 13. What if the smallest unit was a 16-bit word? 100/16 = 6.25 = 7. We would need 7 words to store 100 bits. Floor and ceiling functions arise often in such computations dealing with discrete data. For this reason, they are quite important to us. Another function we will use often is the factorial function. This function takes a natural number to a positive integer. The factorial of a natural number n is denoted as n! and it is equal to the product of the first n positive integers. 0! is defined to be 1. Ex: 0! = 1 1! = 1 2! = 1*2 = 2 3! = 1*2*3 = 6

  18. Problems from Section 1.8 The following problems will appear on HW5 from section 1.8: 1, 4, 7, 8, 12, 13, 14, 17, 22, 24, 28, 34

More Related