This preview shows page 1. Sign up to view the full content.
Unformatted text preview: • Given a sequence of numbers a1, a2, . . . , an, the ﬁnite sum of those numbers n can be written as ak (if n = 0, the summation is deﬁned to be 0).
k =1 • The inﬁnite sum of a sequence of numbers a1, a2, . . . is written as with the interpretation limn→∞ ak . If the limit doesn’t exist, the series k =1 diverges; otherwise, it converges. • The terms of a convergent series cannot always be added in any order, but the terms of an absolutely convergent series can be rearranged. A series is ∞ ∞ absolutely convergent when ak  converges in addition to ak .
k =1 k =1 n k =1 ∞ ak , • The ﬁnite product of a1, a2, . . . , an is written as is deﬁned to be 1).
k =1 n ak (if n = 0, the product EE 608: Computational Models and Methods Lecture 3: Summations Read Appendix A of Introduction to Algorithms • Linearity: For any real number c and ﬁnite sequences, a1, a2, . . . , an and b1 , b2 , . . . , bn :
n k =1 k =1 k =1 (c ∗ ak + bk ) = c ak + bk n n Linearity can also be used to manipulate summations with asymptotics (e.g., n n Θ(f (k )) = Θ( f (k ))).
k =1 k =1 • Manipulating Indices: Sometimes it useful to manipulate the limits of the summation. For example,
n k =1 l=2 ak+1 = al n+1 Let l = k + 1, so k = l − 1. Because 1 ≤ k ≤ n, 1 ≤ (l − 1) ≤ n, so 2 ≤ l ≤ n + 1. ECE 608, Fall 2007 [ 2 ] Use of Summations Summations can be used: • To compute the complexity (i.e., the running time) of loop constructs (e.g., for or while loops). • To determine closed forms of recurrences. For example: x1 = 1; xi = xi−1 + i ⇒ xn = • As a notation for: – polynomials: – series: ex =
n i=0 ∞ k =0 n i=1 i aixi xk k! continued • Integration and Diﬀerentiation of Series: By diﬀerentiating both sides of the inﬁnite geometric series formula and multiplying by x, we get: ∞ ∞ x (1 − x)2
k =0 k ∗ xk−1 ∗ x = k =0 k ∗ xk = Similarly for the geometric series:
n (x − 1)(n + 1)xn − 1(xn+1 − 1) k ∗ xk−1 ∗ x = x (x − 1)2 k =0 xn+1(x − 1)(n + 1) − xn+2 + x = (x − 1)2 xn+1(xn − n − 1 + x − x) + x = (x − 1)2 xn+1(xn − n − 1) + x (x − 1)2 = ECE 608, Fall 2007 [ 4 ] Summation Formulas and Properties continued • Arithmetic Series: Constant diﬀerences ak − ak−1.
n k =1 k= n(n + 1) = Θ(n2) 2
ak ak−1 . n • Geometric Series: Constant ratio xk =
k =0 For real x = 1, xn+1 − 1 x−1 1 1−x
∞ k =0 Inﬁnite decreasing geometric series if x < 1: xk = • Harmonic Series: For positive integers n, Hn =
k =1 n1 k = ln n + O(1) Guess and prove a bound holds using mathematical induction. Example: Show
k =1 1(2+1)(1+1) 6 n k2 = = 1 → correct n(2n+1)(n+1) . 6 Base Case:
k =1 1 (k )2 = 1 and
n(2n+1)(n+1) 6 Assume:
k =1 n+1 k =1 n k2 = holds for n. k2 =
(n+1)(2n+3)(n+2) . 6 Inductive step: Show for n + 1; i.e.,
n+1 k =1 k2 = = = =
k =1 n(2n+1)(n+1) + (n + 1)2 6 (n+1) 6 (n(2n + 1) + 6(n + 1)) (n+1)(2n+3)(n+2) (n+1) 2 6 (2n + 7n + 6) = 6 n k 2 + (n + 1)2 ECE 608, Fall 2007 [ 6 ] Summation Formulas and Properties continued • Telescoping Series: For any sequence a0, a1, a2, . . . , an,
n k =1 (ak − ak−1) = an − a0 (ak − ak+1) = a0 − an Similarly,
n−1 k =0 Consider: n−1 k =1 1 k (k +1) = n−1 k =1 1 1 1 ( k − k+1 ) = 1 − n • Products as Sums: We can convert a product formula into a summation as follows: lg(
n k =1 ak ) = n k =1 lg ak Sometimes a good upper bound on a series can be obtained by bounding each term in the series (e.g., the largest term). For example:
n k =1 k =1 k≤ n n = n2 In general, for a series
k =1 n k =1 n ak , if amax = max1≤k≤nak , then: ak ≤ n ∗ amax The previous is a weak method, when the series can be bounded by an inﬁnite n decreasing geometric series. Given ak , suppose ak+1 ≤ r, ∀k ≥ 0, where r < ak k =0 1 is a constant. Then the sum is bounded by an inﬁnite decreasing geometric series since ak ≤ a0rk :
n k =0 k =0 k =0 ak ≤ ∞ a0 ∗ rk = a0 rk = ∞ a0 1−r ECE 608, Fall 2007 [ 8 ] Bounding Summations: Mathematical Induction continued One need not guess the exact value of a summation to use mathematical induction. Example: Show
k =0 n 2k = O(2n) or n k =0 2k ≤ c ∗ 2n. Base Case:
k =0 0 2k = 1 ≤ c ∗ 20 → correct if c ≥ 1 Assume:
k =0 n 2k ≤ c ∗ 2n holds for n.
n+1 k k =0 Inductive step: Show for n + 1; i.e.,
n+1 k =0 2 ≤ c ∗ 2n+1. 2k = n ≤ c ∗ 2n + 2n+1 = 1 + 1 c ∗ 2n+1 2 c ≤ c ∗ 2n+1, if 1 + 1 ≤ 1. 2 c This is true if c ≥ 2. k =0 2k + 2n+1 We can often obtain a better bound by partitioning the range of the index and then bounding each of the resulting series. For example, we can obtain a good lower bound for the series the summation (assume n is even for simplicity):
n k =1 k =1 k =n/2+1 k =n/2+1 k =1 k =1 n 3 = Ω(n3) 2 n k 2 by splitting k2 = k2 + k2 ≥ 02 + n/2 n n n/2 n 2 ≥ 2 The upper bound is determined as follows:
n k =1 k =1 k2 ≤ n 2 = n 3 = O (n 3 ) n Hence,
k =1 n k 2 = Θ(n3). ECE 608, Fall 2007 [ 10] Bounding Summations: Bounding the Terms Example: Bound
k =1 4
k continued ∞k . The ﬁrst term is
k +1 4k+1 k 4k 1 4 k +1 k and the ratio of consecutive terms is: = 2 ≤, 4 4 ∀k ≥ 1
1 4 ∞ 2k 4 Hence, each term is bounded from above by
∞ so that: ≤ 1 2k 44 k
k =1 4k k =0 = 1 1 1 = 4 1−2 2 4 When a summation can be expressed as f (k ) where f (k ) is monotonically k =m increasing, we can approximate it with integrals:
n m−1 f (x)dx n k =m n+1 f (x)dx m n ≤ f (k ) ≤ n When a summation can be expressed as k=m f (k ) where f (k ) is monotonically decreasing, we can approximate it with integrals: n+1 f (x)dx m ≤
k =m n f (k ) ≤ n m−1 f (x)dx ECE 608, Fall 2007 [ 12] Bounding Summations: Splitting Summations continued We can split the summation to ignore a constant number of initial terms when each term in the summation is independent of n. For any constant k0 > 0:
n k =0 ∞ k2 k =0 k =0 2 (k +1)2 2k+1
k k ak = k0 −1 ak + n k =k0 ak = Θ(1) + n k =k0 ak Example: The ratio, r =
2 ∗ k2 = 4 9 = 0 + 1 + 4 + 8 + 16 + 25 + . . . 2 16 32 (k +1)2 2k 2 ≤ 16 18 = 8 9, k ≥ 3. We can prove the sum converges by breaking it in two:
∞ k2 k =0 2
k = 2 k2 k =0 2
k + ∞ k2 k =3 2 ∞
k 9 ≤ O(1) + 8 k =0 8k 9 = O(1) + 9 1 8 1− 8 9 = O(1) + 81 = O(1) 8 continued f(x) f(m) f(m+1) f(m+2) f(n−1) f(n) ...
m−1 m m+1 m+2 m+3 n−1 n n+1 ECE 608, Fall 2007 [ 14] Approximating Bounds by Integrals continued f(x) f(m) f(m+1) f(m+2) f(m+3) ...
m−1 m m+1 m+2 m+3 f(n) n−1 n n+1 Analyze the running time of the following code segment, assuming that the time to perform the assignment on line 3 is 2 units of time. Provide a summation and solve it in closed form. 1. for i ← 1 to n 2. do for j ← i to n 3. do k ← k + j ECE 608, Fall 2007 [ 16] Approximating Bounds by Integrals Example: Evaluate
k =1 n k =1 n3 3 n2 0 x dx n continued k2 k2 ≤ ≤
n k =1 n+1 2 x dx 1 n+1 2 x dx 0 ≤ ≤ k2 ≤
(n+1)3 3 Hence,
k =1 n k 2 = Θ(n3) ECE 608, Fall 2007 [ 18] Analyzing Code: Example 2 Analyze the running time of the following code segment, assuming that the time to perform the assignment on line 4 is 2 units of time. Provide a summation and solve it in closed form. 1. for i ← 1 to n 2. do for j ← 1 to i 3. do for k ← 1 to j 4. do x ← x + 1 ...
View
Full
Document
This note was uploaded on 04/07/2011 for the course ECE 608 taught by Professor Mithuna during the Fall '07 term at Purdue UniversityWest Lafayette.
 Fall '07
 Mithuna

Click to edit the document details