1 / 64

Summations

Summations. Recall: Insertion Sort. Arithmetic Sum. ∑ i=1..n i = 1 + 2 + 3 + . . . + n = ?. 1 + 2 + 3 + . . . + n-1 + n = S n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S. 1. +.

sarahlsmith
Télécharger la présentation

Summations

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. Summations

  2. Recall: Insertion Sort COSC 3101B, PROF. J. ELDER

  3. Arithmetic Sum ∑i=1..ni = 1 + 2 + 3 + . . . + n = ? COSC 3101B, PROF. J. ELDER

  4. 1 + 2 + 3 + . . . + n-1 + n = S n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S COSC 3101B, PROF. J. ELDER

  5. 1 + 2 + 3 + . . . + n-1 + n = S n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S Algebraic argument Let’s restate this argument using a geometric representation COSC 3101B, PROF. J. ELDER

  6. = number of blue dots. 1 + 2 + 3 + . . . + n-1 + n = S n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S 1 2 . . . . . . . . n COSC 3101B, PROF. J. ELDER

  7. = number of blue dots 1 + 2 + 3 + . . . + n-1 + n = S = number of black dots n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S n . . . . . . . 2 1 1 2 . . . . . . . . n COSC 3101B, PROF. J. ELDER

  8. = number of blue dots 1 + 2 + 3 + . . . + n-1 + n = S = number of black dots n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S n n There are n(n+1) dots in the grid n n n n n+1 n+1 n+1 n+1 n+1 COSC 3101B, PROF. J. ELDER

  9. + n (n 1) = S 2 = number of blue dots 1 + 2 + 3 + . . . + n-1 + n = S = number of black dots n + n-1 + n-2 + . . . + 2 + 1 = S (n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S n (n+1) = 2S n n n n n n Note = Q(# of terms · last term)) n+1 n+1 n+1 n+1 n+1 COSC 3101B, PROF. J. ELDER

  10. Arithmetic Sum ∑i=1..ni = 1 + 2 + 3 + . . . + n = Q(# of terms · last term) True whenever terms increase slowly COSC 3101B, PROF. J. ELDER

  11. Geometric Sum ∑i=0..n2i = 1 + 2 + 4 + 8 +. . . + 2n = ? COSC 3101B, PROF. J. ELDER

  12. Geometric Sum COSC 3101B, PROF. J. ELDER

  13. Geometric Sum ∑i=0..n2i = 1 + 2 + 4 + 8 +. . . + 2n = 2 · last term - 1 COSC 3101B, PROF. J. ELDER

  14. Geometric Sum ∑i=0..nri = r0 + r1 + r2 +. . . + rn = ? COSC 3101B, PROF. J. ELDER

  15. + + + + + 2 3 n 1 r r r . . . r Geometric Sum = S + = + + + + + 2 3 n n 1 Sr r r r . . . r r + - = - n 1 S Sr 1 r + - n 1 r 1 = S - r 1 COSC 3101B, PROF. J. ELDER

  16. Geometric Sum When r>1 + - n 1 r 1 Biggest Term ∑i=0..nri = =θ(rn) - r 1 COSC 3101B, PROF. J. ELDER

  17. Geometric Increasing ∑i=0..nri = r0 + r1 + r2 +. . . + rn = Q(biggest term) True whenever terms increase quickly COSC 3101B, PROF. J. ELDER

  18. + n 1 Geometric Sum When r<1? 1 r - ∑i=0..nri = - 1 r COSC 3101B, PROF. J. ELDER

  19. + n 1 Geometric Sum When r<1 1 r - ∑i=0..nri = Biggest Term =θ(1) - 1 r COSC 3101B, PROF. J. ELDER

  20. Bounded Tail ∑i=0..nri = r0 + r1 + r2 +. . . + rn = Q(1) True whenever terms decrease quickly COSC 3101B, PROF. J. ELDER

  21. Sum of Shrinking Function n f(i) = 1 ∑i=1..n f(i) = n COSC 3101B, PROF. J. ELDER

  22. Sum of Shrinking Function ¥ f(i) = 1/2i COSC 3101B, PROF. J. ELDER

  23. Sum of Shrinking Function n f(i) = 1/i ∑i=1..n f(i) = ? COSC 3101B, PROF. J. ELDER

  24. Harmonic Sum ∑i=1..n1/i = 1/1+1/2+1/3+1/4+1/5+…+1/n = ? COSC 3101B, PROF. J. ELDER

  25. Harmonic Sum

  26. Harmonic Sum ∑i=1..n1/i = 1/1+1/2+1/3+1/4+1/5+…+1/n = Q(log(n)) COSC 3101B, PROF. J. ELDER

  27. Approximating Sum by Integrating ∑i=1..n f(i) ≈ ∫x=1..n f(x) dx The area under the curve approximates the sum COSC 3101B, PROF. J. ELDER

  28. Approximating Sums by Integrating: Arithmetic Sums COSC 3101B, PROF. J. ELDER

  29. Approximating Sums by Integrating: Geometric Sums COSC 3101B, PROF. J. ELDER

  30. Approximating Sum by Integrating Harmonic Sum COSC 3101B, PROF. J. ELDER

  31. Adding Made Easy We will now classify (most) functions f(i) into four classes: • Geometric Like • Arithmetic Like • Harmonic • Bounded Tail For each class, we will give an easy rule for approximating its sum θ( ∑i=1..nf(i) ) COSC 3101B, PROF. J. ELDER

  32. Adding Made Easy f(n) n COSC 3101B, PROF. J. ELDER

  33. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=0..nf(i) = θ(f(n)) If the terms f(i) grow sufficiently quickly, then the sum will be dominated by the largest term. Classic example: ∑i=0..n 2i = 2n+1-1≈2 f(n) COSC 3101B, PROF. J. ELDER

  34. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) If the terms f(i) grow sufficiently quickly, then the sum will be dominated by the largest term. For which functions f(i) is this true? How fast and how slow can it grow? COSC 3101B, PROF. J. ELDER

  35. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) ∑i=1..n (1000)i≈1.001(1000)n = 1.001 f(n) Even bigger? COSC 3101B, PROF. J. ELDER

  36. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) 2i 2n ∑i=1..n 22≈22= 1f(n) No Upper Extreme: Even bigger! COSC 3101B, PROF. J. ELDER

  37. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) COSC 3101B, PROF. J. ELDER

  38. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) COSC 3101B, PROF. J. ELDER

  39. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) Do All functions in 2Ω(n)have this property? Maybe not. COSC 3101B, PROF. J. ELDER

  40. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) Functions that oscillate with exponentially increasing amplitude do not have this property. COSC 3101B, PROF. J. ELDER

  41. Geometric Like: f(n) ³ 2Ω(n)Þ ∑i=1..nf(i) = θ(f(n)) Functions expressed with +, -, ×,  , exp, log do not oscillate continually. They are well behaved for sufficiently large n. These do have this property. COSC 3101B, PROF. J. ELDER

  42. Adding Made Easy f(n) n COSC 3101B, PROF. J. ELDER

  43. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) If the terms f(i) are increasing or decreasing relatively slowly, then the sum is roughly the number of terms, n, times the final value. Example 1: ∑i=1..n1 =n · 1 COSC 3101B, PROF. J. ELDER

  44. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) If the terms f(i) are increasing or decreasing relatively slowly, then the sum is roughly the number of terms, n, times the final value. Example 2: ∑i=1..ni = 1 + 2 + 3 + . . . + n COSC 3101B, PROF. J. ELDER

  45. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) Half the terms are roughly the same and the sum is roughly the number of terms, n, times this value ∑i=1..ni = 1 + . . . + n/2 + . . . + n ∑i=1..n i = θ(n · n) COSC 3101B, PROF. J. ELDER

  46. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) Is the statement true for this function? ∑i=1..ni2 = 12 + 22 + 32 + . . . + n2 COSC 3101B, PROF. J. ELDER

  47. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) Again half the terms are roughly the same. ∑i=1..ni = 12 + . . . + (n/2)2 + . . . + n2 1/4 n2 ∑i=1..n i2 = θ(n · n2) COSC 3101B, PROF. J. ELDER

  48. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) area of small square £∑i=1..n f(i) ≈area under curve £area of big square = n/2· f(n/2) =n · f(n) COSC 3101B, PROF. J. ELDER

  49. Arithmetic Like: f(n) = nθ(1)-1 Þ ∑i=1..nf(i) = θ(n·f(n)) The key property is f(n/2) = θ(f(n)) f(n) = n2 ∑i=1..ni2 = 12 + 22 + 32 + . . . + n2 = ? COSC 3101B, PROF. J. ELDER

  50. Adding Made Easy f(n) Half done n COSC 3101B, PROF. J. ELDER

More Related