1 / 63

Chapter 7 Functions

Chapter 7 Functions. In Layman’s terms A function f from a set X to another set Y is a recipe that tells you how to convert an input number x to the output number y . Usually such a recipe is expressed in a formula, but we also have:. Function defined by arrow diagrams. f. X. Y.

elan
Download Presentation

Chapter 7 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. Chapter 7 Functions

  2. In Layman’s terms A function f from a set X to another set Y is a recipe that tells you how to convert an input number x to the output number y. Usually such a recipe is expressed in a formula, but we also have: Function defined by arrow diagrams f X Y a 1 2 b 3 c 4 Note: this method works only for finite sets.

  3. Arrow diagram of a function with animation. 2 3 a 5 b 8 c 13 d 19 e 26

  4. The following diagram does not represent a function, do you know why? 2 3 a 5 b 8 c 13 d 19 e 26

  5. Function as a set f 2 B A 3 a 5 b 8 c 13 The above function is defined as a set of ordered pairs:f = {(a, 5), (b, 26), (c, 2), (d,8), (e, 13)} and this set is a subset of A×B d 19 e 26

  6. 7.1 Functions Defined on General Sets Definition: Given any two sets X and Y, a function f from X to Y is a subset of the Cartesian product X ×Ysuch that (a) for every aX, there is one yY such that (a,y) f (b) if (a,y) f and (a,z) f , then y = z (in other words, there is one and only one output for each input) The set X is called the domain of f , Y is called the codomain, and range of f = {b  Y : b = f (a) for some a  X} Given any b  Y, inverse image of b =f -1(b) = {a  X : f (a) = b} and this set can be empty.

  7. Functions defined on the set of bit strings • Let Σ = {0, 1} and Σ* be the set of all finite strings over Σ. • Define g: Σ* → Σ* by • g(s) = the reverse of s from right to left. • eg. g(10111) = 11101 • (2) Define f: Σ* × Σ* → Σ* by • f(s, t) = the concatenation of s followed by t. • eg. f (000, 1101) = 0001101

  8. Check digit functions The last digit of each UPC or ISBN is always created to catch errors. In other words, there is a formula to compute the last digit using all but the last digit as input. If this last digit does not match the formula, we know that the number must be wrong. • Example: • In the UPC 0-53600-10054-0, the last digit 0 is chosen such that 0×3 + 5×1 + 3×3 + 6×1 + 0×3 + 0×1 + 1×3 + 0×1 + 0×3 + 5×1 + 4×3 + 0×1is divisible by 10. In dot product notation, this can be written as [(0,5,3,6,0,0,1,0,0,5,4,0)  (3,1,3,1,3,1,3,1,3,1,3,1)] MOD 10 = 0

  9. 2. Each ISBN is a 10 digit number such as 0-88385-720-0. The last digit a10 is chosen such that [(0,8,8,3,8,5,7,2,0,a10)  (10,9,8,7,6,5,4,3,2,1)]MOD 11 = 0 In this case, a10 = 0 will work. And if a10 = 10, we use the letter X instead. In both examples, we see that there is always at most one output from each input, these procedures of generating check digits are functions even though they cannot be easily described by formulas.

  10. Coding functions • A typical coding function usually assigns a unique numeric code (often a binary code) to each input. • The three common reasons for assigning codes are • secrecy (or privacy), • data compression, • error correction.

  11. Examples of Error correcting Codes. Hamming [7,4,3] binary linear code. (1950) This is the 1st error detecting code (cannot correct error yet). Each input is a binary sting of length 4, and the function will add 3 check digits at the end and make the output a string of length 7. inputoutput 0000  0000000 0001  0001011 0010  00101110100  01001011000  1000110 inputoutput 1100  1100011 1010  1010001 …. etc. It can detect 1 error out of the 7 bits, but cannot correct it.

  12. 7 6 5 4 3 2 1 0 -5 -4 -3 -2 -1 0 1 2 3 x -1 Functions defined by formulas Example: f(x) = 3x2 + 5 for every x in . g(x) = exsinx for every x in . These functions can also be (partially) represented by graphs instead of arrow diagrams.

  13. 1. This function is discontinuous everywhere. Examples In mathematical analysis, many functions are defined by descriptions rather than by formulas. All examples below are functions from  to . 1

  14. 2. This function is continuous only at 0. Examples But it is not differentiable anywhere.

  15. 3.This function is differentiable at 0 but is discontinuous elsewhere.

  16. 4.This function is continuous only at the irrationals. Remark: There is no function which is continuous only at the rational numbers.

  17. In 1872, Weierstrass published a paper that states that the following function is continuous but nowhere differentiable. (remark: He actually published a more general result.)

  18. Space Filling Curve In 1890, Giuseppe Peano discovered a continuous function from [0, 1] onto the unit square [0,1] ×[0,1]. However, this function cannot be one-to-one. The following function is due to David Hilbert, only the 1st 6 iterations are shown, the final function is the limit of these iterations.

  19. Equality of functions: Suppose that both f and g are functions from X to Y, then we say that f is equal to g, written f = g if and only if for every a X, f (a) = g(a) Example: f (x) = (x2 + x + 1) mod 3, g(x) = (x + 2)2mod 3They are equal on the domain of integers.

  20. Exercise Let f be a function from  to  such that whenever x  1. Find the value of

  21. Reed-Solomon Codes(1960) • The commercially used version for CD’s, DVD’s, • cellphones etc. is the [255,223,33]-code, in which • Every codeword is a 255-byte string, hence 2040 bits. • In each codeword, 223 bytes are from the original message (others are check digits) • It can correct up to 16 incorrect bytes (i.e. 16 bits in 16 different bytes in the worst case, and 16×8 bits in a row in the best case.)

  22. Finite-State Automata A finite state automaton is a machine that can make a few decisions, but it is much weaker than a computer because it does not have an expandable memory and it can only run one predetermined program. Examples: Vending machines,

  23. Definition: • A finite-state automaton consists of five objects • a set I called the input alphabet, of input symbol; • a set S of states the automaton can be in; • a designate state s0 , called the initial state; • a designate set of states called the set of accepting states • a next-state function N : S × I S

  24. Finite-State Automaton Simple Vending Machine – accepts only 25¢ or 50¢ - gives a bottle of soda for $1 - does not return changes 50¢ 25¢ desposited 75¢ desposited 25¢ 25¢ 25¢ 50¢ 25¢ 0¢ desposited 25¢ $1 or more desposited 50¢ 50¢ 50¢ desposited 50¢

  25. The Next-State Table Input Original State Next State in blue

  26. Examples: • Construct a finite state automaton that accepts exactly the set of strings of 0’s and 1’s that start with the pattern 110. • Construct a finite state automaton that accepts exactly the set of strings of 0’s and 1’s for which the number of 1’s is divisible by 3. • Construct a finite state automaton that accepts exactly the set of strings of 0’s and 1’s that do not contain the pattern 1011.

  27. Question For any given set A of strings of 0’s and 1’s, can we build a finite-state automaton that accepts exactly the strings in the set A? In particular, can we build one machine that accepts exactly those strings where the number of 0’s is equal to the number of 1’s? And can we build one machine that accepts exactly those strings that are palindromes? (eg. 0110110)

  28. 7.2 1-to-1, Onto, and Inverse functions Definition: Let F be a function from a set X to a set Y. F is one-to-one (or injective) if, for all elements x1 and x2 in X Or equivalently,

  29. Different ways to check that a function is one-to-one • Let f be a function from a connected interval in  to  . Then f is one-to-one if either of the following is true. • The graph of f passes the horizontal line test. • f is strictly increasing or strictly decreasing. • 3. If f is differentiable, then f is one-to-one if f ’(x) > 0 for all x or if f ’(x) < 0 for all x in the domain of f. If f is defined on other domains, we have to use the definition to prove “one-to-one”ness, or we can construct an inverse for f.

  30. 2 3 a 5 b 8 c 13 d 19 e 26 This is a one-to-one function. This is not a one-to-one function. 2 3 a 5 b 8 c 13 d 19 e 26 We can call this a many-to-one function.

  31. Examples 1. The identity function id:  defined by id (x) = x is one-to-one 2. Any linear function f(x) = ax + b with a ≠ 0 is one-to-one from  to .

  32. Examples 3. Show that the function is one-to-one throughout its domain. 4. Let S be the set of all finite strings of a’s, b’s and c’s. Define C: SS by C(s) = a*s for all sS C is called concatenation, i.e. C(bbc) = abbc . Show that C is one-to-one.

  33. Sets of Sequences • Notations • 2 is the set of all functions from Z+ to 2 (which is the set {0,1})This is identified with the set of all infinite sequences of 0’s and 1’s.such as 0,1,0,1,0,1,0,1, … or 0,1,0,1,1,0,1,1,1,0, … • 10 is the set of all functions from Z+ to 10 (which is the set {0,1, 2, 3, 4, 5, 6, 7, 8, 9})Similarly this is identified with the set of all infinite sequences of digits;such as 3,2,4,8,0,5,9,1, … or 4,2,4,2,4,2,4,2,4,2, …

  34. More examples • The embedding function I: 2 10 defined byI(s) = s for every s2is one-to-one. • We now try to construct a function G: 10 2which is one-to-one.

  35. Properties of one-to-one functions. 1. If f(x):    is one-to-one, and a, b, c are constants with a ≠ 0, b ≠ 0, then a·f(bx) + c is also one-to-one. 2. The composition of two or more one-to-one functions is also one-to-one. example: e sin(x) is one-to-one on the domain (-π/2, π/2).

  36. Onto functions Definition: Let F be a function from a set X to a set Y. F is onto (or surjective) if, range of F = Y Or equivalently,

  37. 2 3 a 5 b 8 c 13 d 19 e 26 This function is not onto. This function is onto (even though not one-to-one). 3 a b 8 c d 19 e

  38. Unfortunately there is no standard method to check whether a function is onto or not. Different functions may require different techniques. Whether a given function is onto or not onto depends on its co-domain as well. If we can reduce the co-domain, we can make a function onto. Examples The function f:  defined by f (x) = 4x + 1 is onto, butthe function f: Z+ Z+ defined by f (n) = 4n + 1 is not onto.

  39. More Examples c. The polynomial p(x) = x3 – 4x + 2 is onto but not one-to-one. d. There is an onto function H: 10 2 defined by for every f 10 but this function is not one-to-one. e. Challenge: Can you construct an onto function from 2 to 10 ?

  40. Theorem For any set S (finite or infinite), there is no onto function from S to (S). Proof: It is only necessary to consider the case where S is infinite, because if S is finite, we know that (S) has more elements. Assume to the contrary that there is a onto functionf : S → (S) We then consider the subset A = { xS : xf(x) }

  41. Inverse functions Definition: Let f be a function from a set X to a set Y. If f is both one-to-one and onto, then we say that f is a bijection or a one-to-one correspondence between X and Y. Theorem: Suppose that f : X Y is a bijection, then there is a function f -1 : Y  X defined by f -1 (y) = the unique element x in X such that f (x) = y Definition: The function f -1 defined above is called the inverse of f.

  42. Inverse functions Theorem: If X and Y are sets and f : XY is one-to-one and onto, thenf-1 : Y  X is also one-to-one and onto. The following theorem provides a very convenient way to prove that a function is one-to-one and onto. Theorem: If X and Y are sets and f : XY is a function. Suppose further that there is a function g: Y  X such that g◦f = IX : X  X then f is one-to-one and onto.

  43. Special cases • Suppose that both X and Y are finite sets and f : X → Y is a function, • if n(X) > n(Y), then f cannot be one-to-one, • if n(X) < n(Y), then f cannot be onto, • if n(X) = n(Y), and f is one-to-one, then f is also onto, • if n(X) = n(Y), and f is onto, then f is also one-to-one.

  44. Example Let f : R → R be a continuous but non-constant function that preserves addition and multiplication, i.e. f(x + y) = f(x) + f(y) and f(x · y) = f(x)f(y) Prove that fis one-to-one. • Solution: • We need to divide the proof into several steps. • prove that f(0) = 0 • prove that f(-x) = - f(x) • prove that f(x) = 0 implies that x = 0. • prove that f(x) = f(y) implies that x = y. In fact, we can prove (in exercise) that this fis actually the identity function, hence it is also onto.

  45. 7.4 Cardinality with Applications Definition: A set S is called finite if there is no bijection between S and a proper subset of S. A set is called infinite if it is not finite. (In other words, a set S is infinite if we can construct a bijection from S to a proper subset of S. Example:The set of natural numbers N is infinite because we can construct the bijective function f(n) = n + 1 from N to a proper subset {1, 2, 3, 4, ··· } of Nitself.

  46. Theorem: For any function f from a finite set X to a finite set Y, if n(X) > n(Y), then f cannot be one-to-one. This theorem is called the Pigeon hole Principle or the Dirichlet box principle. We shall study this principle in section 9.4

  47. 7.4 Cardinality and Applications Definition: Two sets A and B are said to have the same cardinality i.e. card(A) = card(B) if and only if there is a bijection between them. Using the terminology of cardinality, we can redefine infinite sets. Definition: A set S is said to be infinite if S has at least one proper subset W such that card(W) = card(S) Examples card({0,1,2,3,4,5, ··· }) = card ({0,2,4,6,8, ···}) = card ()

  48. Exercises 1. Show that the interval (0, 1) has the same cardinality as the longer interval (5, 8). 2. Show that the interval (0, 1) has the same cardinality as the infinite interval (0, ∞). 3. Show that the interval (0, 1) has the same cardinality as the infinite interval (-∞, ∞). 4. Show that the closed interval [0, 1] has the same cardinality as the open interval (0, 1).

  49. 4. Show that the closed interval [0, 1] has the same cardinality as the open interval (0, 1). Solution: Consider the function It is not difficult to check that f is one-to-one and it maps [0, 1] onto (0, 1)

  50. Theorem There is a one-to-one correspondence between the closed interval [0,1] and the closed square [0,1]×[0,1]. Proof: Let f : [0,1] → [0,1]×[0,1] be defined by f (0.a1a2a3a4a5a6…) = (0.a1a3a5…, 0.a2a4a6…) then f is bijective because it has an obvious inverse. (remark: we use infinite decimal expansion for every real number, i.e. 0.5 = 0.49999··· )

More Related