Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Mathematics of radio engineering wikipedia , lookup
Functional decomposition wikipedia , lookup
Big O notation wikipedia , lookup
Principia Mathematica wikipedia , lookup
Proofs of Fermat's little theorem wikipedia , lookup
Continuous function wikipedia , lookup
Dirac delta function wikipedia , lookup
Non-standard calculus wikipedia , lookup
History of the function concept wikipedia , lookup
CSE 215: Foundations of Computer Science Unit 16: Functions Defined on General Sets Kevin McDonnell Stony Brook University – CSE 215 1 Functions • A function f from a set X to a set Y, denoted : → , is a relation from X, the domain, to Y, the co-domain, that satisfies two properties: 1. Every element in X is related to some element in Y 2. No element in X is related to more than one element in Y • For any element ∈ , there is a unique element ∈ such that ( ) = • The range of f (also called the image of X under f ) ∈ = for some ∈ } = • The inverse image of y = ∈ ( )= } Kevin McDonnell Stony Brook University – CSE 215 2 Arrow Diagrams • If X and Y are finite sets, you can define a function f from X to Y by drawing an arrow diagram • You make a list of elements in X and a list of elements in Y, and draw an arrow from each element in X to the corresponding element in Y, as shown below Kevin McDonnell Stony Brook University – CSE 215 3 Arrow Diagrams • This arrow diagram does define a function because 1. Every element of X has an arrow coming out of it. 2. No element of X has two arrows coming out of it that point to two different elements of Y. Kevin McDonnell Stony Brook University – CSE 215 4 Arrow Diagrams • For each arrow diagram below, indicate whether the diagram depicts a function No Kevin McDonnell No Stony Brook University – CSE 215 Yes 5 Example: Arrow Diagrams • Let X = {a, b, c} and Y = {1, 2, 3, 4}. Define a function f from X to Y by the arrow diagram below. a. Write the domain and co-domain of f. • Answer: domain: { , , } co-domain: {1, 2, 3, 4} b. Find f(a), f(b), and f(c). • Answer: = 2, = 4, =2 c. What is the range of f? • Answer: {2,4} Kevin McDonnell Stony Brook University – CSE 215 6 Example: Arrow Diagrams • Let X = {a, b, c} and Y = {1, 2, 3, 4}. Define a function f from X to Y by the arrow diagram below. d. Is c an inverse image of 2? Is b an inverse image of 3? • Answer: Yes, No e. Find the inverse images of 2, 4, and 1. • Answer: , , ,∅ f. Represent f as a set of ordered pairs. • Answer: { , 2 , , 4 , , 2 } Kevin McDonnell Stony Brook University – CSE 215 7 Arrow Diagrams • For this function there are no arrows pointing to the 1 or the 3. • This illustrates the fact that although each element of the domain of a function must have an arrow pointing out from it, there can be elements of the co-domain to which no arrows point. • Note also that there are two arrows pointing to the 2: one coming from a and the other from c. Kevin McDonnell Stony Brook University – CSE 215 8 Function Equality • If : → and : → are functions, then = if, and only if, ( ) = ( ) for all ∈ . • Example: Let J3 = {0, 1, 2}, and define functions f and g from = + + 1 mod 3 J3 to J3 as follows: For all x in J3, and # = + 2 mod 3 • Does = #? • Yes, the table of values shows that f(x) = g(x) for all x in J3. x $ % = %& + % + ' ()* + , % = % + & 0 1 2 Kevin McDonnell 1 -./ 3 = 1 3 -./ 3 = 0 7 -./ 3 = 1 & ()* + 4 -./ 3 = 1 9 -./ 3 = 0 16 -./ 3 = 1 Stony Brook University – CSE 215 9 Example: Function Equality • Let F: ℝ → ℝ and G: ℝ → ℝ be functions. • Define new functions F + G: ℝ → ℝ and G + F: ℝ → ℝ as follows: for all x ∈ ℝ, + = + ( ) and + = + . • Does F + G = G + F ? • Yes. For all real numbers x: + = + ( ) by definition of + + ( ) by the commutative law = = + by definition of + Kevin McDonnell Stony Brook University – CSE 215 10 The Identity Function • Given a set X, define a function IX from X to X by 56 ( ) = for all x in X. • The function IX is called the identity function on X because it sends each element of X to the element that is identical to it. • Thus the identity function can be pictured as a machine that sends each piece of input directly to the output chute without changing it in any way. Kevin McDonnell Stony Brook University – CSE 215 11 Logarithmic Functions • Let x be a positive real number with ≠ 1. For each positive real number x, the logarithm with base b of x, written log : , is the exponent to which b must be raised to obtain x. Symbolically, log : = ⇔ <= . • The logarithm function with base b is the function from ℝ= to ℝ that takes each positive real number x to log : . • Examples: evaluate each of the following: a. log > 9 = 2 b. log ? = −1 c. log?@ 1 = 0 d. log 2A = m e. 2 BCDE A Kevin McDonnell ->0 = m This is equivalent to saying log - = log -. Then by definition, 2BCDE A = -. Stony Brook University – CSE 215 12 Sec. 7.1, p. 303: #23 • If b and y are positive real numbers such that log : what is log H ? = 3, I = 3, then • If log : • > = = = = = > by definition of log. ? :KL ? H IL ? H L I ? M> : So • By definition of log, log Kevin McDonnell = H I ? M> : = −3 Stony Brook University – CSE 215 13 Function Defined on a Power Set • Define a function : N each ∈ N , , , Kevin McDonnell , , → ℤPQPPRS as follows: for = the number of elements in X. Stony Brook University – CSE 215 15 Function for a Sequence • Suppose we are given this sequence: ? ? ? ? M? P 1, − , , − , , … , ,… P=? > T U • We can think of this sequence as a function from the nonnegative integers to real numbers as follows: ? 0 → 1, 1 → − , 2 → ? , > 3 → ? − , T 4 → ? , …, W U → M? P P=? • This can be written formally as a function: : ℕ → ℝ, for each integer W ≥ 0, W = M? Z (P=?) #: ℤ= → ℝ, for each integer W ≥ 1, # W = or as M? Z[H P • Many functions can be used to define a given sequence Kevin McDonnell Stony Brook University – CSE 215 16 Function for a Cartesian Product • Define functions \: ℝ × ℝ → ℝ and ^: ℝ × ℝ → ℝ × ℝ as follows. For all ordered pairs , of integers, and ^ , = (− , ). \ , = • M is called the multiplication function • R is called the reflection function • Evaluate each of the following: a. \ −1, −1 = 1 b. \ ? ? , = ? T c. ^ −2,5 = 2,5 d. ^ 3, −4 = −3, −4 Kevin McDonnell Stony Brook University – CSE 215 17 The Hamming Distance Function • Let `P be the set of all strings of 0’s and 1’s of length n. a: `P × `P → ℤPQPPRS • For each pair of strings (b, c) ∈ `P × `P , a(b, c) = the number of positions in which s and t differ • For W = 5, a 11111, 00000 = 5 a(10101, 01101) = 2 a(01010, 11100) = 3 • The Hamming distance function is used in certain error correction and error detection algorithms Kevin McDonnell Stony Brook University – CSE 215 18 Well-defined Functions • Sometimes what appears to be a function defined by a rule is not really a function at all • Consider this sentence: “Define a function f : ℝ → ℝ by specifying that for all real numbers x, ( ) is = 1.” the real number y such that + • There are two problems with this purported function. For almost all values of x, either 1. there is no y that satisfies the given equation (try = 2), or 2. there are two different values of y that satisfy the equation (try = 0). Kevin McDonnell Stony Brook University – CSE 215 19 Example: Non-well-defined Function • Suppose you read that a function f : ℚ → ℤ is to be defined A by the formula = - for all integers m and n with P W ≠ 0. • That is, the integer associated by f to the A number P is m. • Is f a well-defined function? ? • Answer: No. Consider and > . Now if f were e a function, then the definition of a function would imply that • But ? = 1 and > e ? = > e . = 3 and 1 ≠ 3. So f is not a function. Kevin McDonnell Stony Brook University – CSE 215 20 Functions Acting on Sets • If : → is a function and f ⊆ and h ⊆ , then f = ∈ = ( for some in f and M? h = ∈ ( ) ∈ h} • (f) is called the image of A, and M? h is called the inverse image of C. Kevin McDonnell Stony Brook University – CSE 215 21 Example: Functions Acting on Sets • Let X = {1, 2, 3, 4} and Y = {a, b, c, d, e}, and define F : X → Y by the following arrow diagram: Let A = {1, 4}, C = {a, b}, and D = {c, e}. • Find each of the following: • f = {b} • = {a, b, d} • M? h = {1, 2, 4} • M? k = Ø Kevin McDonnell Stony Brook University – CSE 215 22 Example: Functions Acting on Sets • Let X and Y be sets, let F: X → Y be a function. Prove that if f ⊆ and l ⊆ , then (f ∪ l) ⊆ (f) ∪ (l) • Proof. Suppose ∈ f ∪ l . • This means = ( ) for some ∈ f ∪ l. • By definition of union, ∈ f or ∈ l. • Case 1, ∈ f. In this case, = ( ) for some in A. • Hence, ∈ f , and so by definition of union, ∈ (f) ∪ (l). • Case 2, ∉ f, which means ∈ l. In this case, = ( ) for some in B. • Hence, ∈ l , and so by definition of union, ∈ (f) ∪ (l). Thus, in either case, ∈ (f) ∪ (l). Kevin McDonnell Stony Brook University – CSE 215 23 Sec. 7.1, p. 304: #36 • True or false: for sets A and B, which are subsets of a set X, and for a function F from X to another set Y, f ∩ (l) ⊆ f∩l ? • This is false. • Counterexample: Let = {1,2,3}, = { , }, f = 1,2 , l = {1,3}. • Let 1 = { }, 2 = { }, 3 ={ } • Let f = { , }, l = , • Then f ∩ l = { , } • f ∩ l = {1}, so f ∩ l = { } • Thus, f ∩ l ⊈ f ∩ l Kevin McDonnell Stony Brook University – CSE 215 25 Sec. 7.1, p. 304: #38 • True or false: for sets C and D, which are subsets of set Y, and for a function F from X to Y, if h ⊆ k, then M? h ⊆ M? (k)? • This is true. • Suppose ∈ M? h . • Then ∈ h. • Since h ⊆ k, ∈ k also. • This means that ∈ M? k . • Therefore, M? h ⊆ M? k . Kevin McDonnell Stony Brook University – CSE 215 27