1 / 66

2.3 Functions

2.3 Functions. A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map Examples:

rumor
Télécharger la présentation

2.3 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. 2.3 Functions • A function is an assignment of each element of one set to a specific element of some other set. • Synonymous terms: function, assignment, map • Examples: • Each pixel on this screen is assigned exactly one integer: its color as a mixture of various levels of red, green, and blue. • Each person is assigned exactly one birth mother. • Each non-negative real number is assigned exactly one square root.

  2. Notations and Drawings • If is a function from set to set , we state that fact with the symbolism . • For each element of set , we represent its assigned element of setas

  3. B A B A a 1 b a a a c 2 1 1 1 b b b d 3 3 c c c 2 2 2 d d d A A B B

  4. Terminology: Given • Domain and Codomain • Range • Image • Pre-image

  5. “Arithmetic” on Functions • If f1 and f2 are functions whose codomain is the real numbers, then we can define f1+ f2 and f1f2

  6. Image of a Set Suppose and Then Examples:

  7. One-to-One(Injective) Functions: is said to be one-to-one (injective) provided that for each whenever then Onto (Surjective) Functions: is said to be onto (surjective) provided that

  8. One-to-One Correspondences and Inverse Functions • A map that is 1-1 and onto, i.e. both injective and surjective, is called a • Inverse of (when it exists) is the function

  9. If is onto then If is 1-1 then If is both 1-1 and onto then

  10. Monotonic Functions on f is increasing provided whenever f is decreasing provided whenever f is strictly increasing provided whenever f is strictly decreasing provided whenever

  11. Examples: Proving functions are 1-1, onto and bijections 1. Show defined by is a bijection.

  12. 2. Let be the set of even integers and be the set of odd integers. Define by Determine if is a bijection.

  13. Composition of Functions

  14. The “Graph” of a Function • The graph of function is the set of all ordered pairs for which .

  15. Some Important Functions “floor” and “ceiling” functions

  16. 2.4 Sequences and Summations • Sequences and sequence notation

  17. Geometric progressions • Arithmetic progressions

  18. Finding the pattern… • Examples: • 3, 10, 31, 94, … • … • 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, …

  19. The sum of the first terms of is denoted Reindexing • Summations and Summation Notation

  20. Sum of a finite geometric series

  21. Summation over members of a set • Double summation

  22. Other useful sums

  23. Cardinality • Two sets A and B have the same cardinalityiff … • A set A is countable provided … • (“Aleph nought”)

  24. Countability of the Rationals

  25. 3.1 Algorithms “A precise set of written instructions for performing a computation or for solving a problem”

  26. Example: Algorithm 3.12. (x = π↓ x to π↑ x) • Step 1: Label the descending runs through , with the first on the left and the last on the right. • Step 2: Starting with , label the leftmost element of as . As a group, move all of the elements of leftward until you reach the largest element to the left of that is still smaller than (i.e. move all of directly to the right of the element where > such that j < i and there is no element with k < i such that < < ). Call the new permutation x(2). • Step 3: Repeat step 2 in x(2) with . • Step 4: Continue the process with right successive descending runs (i.e. repeat step 2 in x(i) with for successive i’s) until you create x(r). The permutation x(r) is the top element of the congruence class, x(r) = π↑x. x= π↓ x =219534768

  27. Pseudo-code • The style of the text is Pascal-like. Example: proceduremaxOf3(a, b, c: integers) max := a if b > max then max := b if c > max then max := c {max now contains the largest of a, b, and c}

  28. Properties of an Algorithm Input Output Definiteness Correctness Finiteness Effectiveness Generality

  29. Algorithm 1: Finding the Maximum Element in a Finite Sequence

  30. Greedy Algorithms • A greedy algorithm is a class of algorithm used when a problem can be solved by making a sequence of decisions, and each such decision moves us closer to an overall solution to the problem • The greedy algorithm, at any given stage, always makes the decision that moves us closest to that overall solution • Do greedy algorithms always produce the “best” solution?

  31. Greedy Algorithm for Travelling from one City to Another 12km start 13km 10km 6km finish 4km 7km 3km

  32. Example: Describe an algorithm that puts the first three terms of a sequence of integers of arbitrary length in increasing order

  33. Example: Describe an algorithm for determining whether a string of n characters is a palindrome.

  34. Example: Devise an algorithm that finds the first term of a sequence of integers that equals some previous term in the sequence.

  35. 3.2 The Growth of Functions • Suppose we have two functions and mapping into the set of real numbers, each of whose domain is some subset of the set of real numbers • We say that “” (“is big-oh of ”) provided there exists a positive constant and a positive real number for which, whenever , then

  36. The meaning of • How do we measure the “rate of growth” of a function? Not just the rate of growth at a single point, but over its entire domain? • When we say “we are saying that in some general way the rate of growth of is ultimately no worse than that of a constant multiple of

  37. Example • Show that is where and .

  38. Functions of the Same Order • Is it possible to have two functions and for which each is “big-oh” of the other? • Yes, and in that case we say the two functions are functions of the same order.

  39. Use a Simpler Function as a “Yardstick” • Whenever possible, we want to use as our g(x) function a relatively simple function whose behavior we are quite familiar with. • Examples: g(x) = 1 g(x) = x g(x) = x2 g(x) = log x etc.

  40. Theorem Suppose is a polynomial of degree , i.e. f(x) = anxn+an-1xn-1+…+a1x+a0 for some series of constants a0 , a1 , …, an . Then f(x)is

  41. Some Important “Ideal Functions” g(n) = 1 g(n) = n g(n) = n2 (and other polynomial functions n3, n4, etc.) g(n) = log n g(n) = n log n g(n) = 2n g(n) = an (any constant a > 1) g(n) = n! g(n) = nn

  42. Combinations If f(x) = f1(x)+f2(x) where f1(x) = O(g1(x)) and f2(x) = O(g2(x)), then f(x) is O(max(g1(x),g2(x)). Example: f(x) = 2x + log xis If f(x) = f1(x)f2(x) where f1(x) = O(g1(x)) and f2(x) = O(g2(x)), then f(x) is O(g1(x)g2(x)). Example: f(n) = (log n + 17)n2is

  43. More Examples • is • Find a big-oh upper bound for … (x3+1)log x + (x2+7)(log x)2

  44. Big- and Big- • We say that is (“big omega of ”) precisely when is • To say that is (“big theta of ”) is to say that is and is • In other words, big-theta is a symmetric relationship. It means and are functions of the same order

More Related