Download presentation
Presentation is loading. Please wait.
Published byNeil Cannon Modified over 9 years ago
1
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen Recurrence Relations
2
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 2 Recurrence Relations Definition and Examples Solving Recurrences linear homogeneous recurrence linear nonhomogeneous recurrence
3
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 3 Recurrence Relations A recurrence relation (R.R., or just recurrence) for a sequence {a n } is an equation that expresses a n in terms of one or more previous elements a 0, …, a n−1 of the sequence, for all n n 0. A recursive definition, without the base cases. A particular sequence (described non-recursively) is said to solve the given recurrence relation if it is consistent with the definition of the recurrence. A given recurrence relation may have many solutions.
4
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 4 Recurrence Relation Example Consider the recurrence relation a n = 2a n−1 − a n−2 (n 2). Which of the following are solutions? 1. a n = 3n 2. a n = 2 n 3. a n = 5
5
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 5 Example Applications Recurrence relation for growth of a bank account with P% interest per given period: M n = M n−1 + (P/100)M n−1 Growth of a population in which each organism yields 1 new one every period starting 2 periods after its birth. P n = P n−1 + P n−2 (Fibonacci relation)
6
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 6 Solving Compound Interest RR M n = M n−1 + (P/100)M n−1 = (1 + P/100) M n−1 = r M n−1 (let r = 1 + P/100) = r (r M n−2 ) = r·r·(r M n−3 )…and so on to… = r n M 0
7
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 7 Tower of Hanoi Example Problem: Get all disks from peg 1 to peg 2. Only move 1 disk at a time. Never set a larger disk on a smaller one. Peg #1Peg #2 Peg #3
8
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 8 Hanoi Recurrence Relation Let H n = # moves for a stack of n disks. Optimal strategy: Move top n−1 disks to spare peg. (H n−1 moves) Move bottom disk. (1 move) Move top n−1 to bottom disk. (H n−1 moves) Note: H n = 2H n−1 + 1
9
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 9 Solving Tower of Hanoi RR H n = 2 H n−1 + 1 = 2 (2 H n−2 + 1) + 1 = 2 2 H n−2 + 2 + 1 = 2 2 (2 H n−3 + 1) + 2 + 1= 2 3 H n−3 + 2 2 + 2 + 1 … = 2 n−1 H 1 + 2 n−2 + … + 2 + 1 = 2 n−1 + 2 n−2 + … + 2 + 1(since H 1 = 1) = 2 n − 1
10
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 10 Solving Recurrences A linear homogeneous recurrence of degree k with constant coefficients (“k- LiHoReCoCo”) is a recurrence of the form a n = c 1 a n−1 + … + c k a n−k, where the c i are all real, and c k 0. The solution is uniquely determined if k initial conditions a 0 …a k−1 are provided.
11
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 11 Solving LiHoReCoCos Basic idea: Look for solutions of the form a n = r n, where r is a constant. This requires the characteristic equation: r n = c 1 r n−1 + … + c k r n−k, i.e., r k − c 1 r k−1 − … − c k = 0 The solutions (characteristic roots) can yield an explicit formula for the sequence.
12
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 12 Solving 2-LiHoReCoCos Consider an arbitrary 2-LiHoReCoCo: a n = c 1 a n−1 + c 2 a n−2 It has the characteristic equation (C.E.): r 2 − c 1 r − c 2 = 0 Thm. 1: If this CE has 2 roots r 1 r 2, then a n = á 1 r 1 n + á 2 r 2 n for n 0 for some constants á 1, á 2.
13
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 13 Example Solve the recurrence a n = a n−1 + 2a n−2 given the initial conditions a 0 = 2, a 1 = 7. Solution: Use theorem 1 c 1 = 1, c 2 = 2 Characteristic equation: r 2 − r − 2 = 0 Solutions: r = [−(−1)±((−1) 2 − 4·1·(−2)) 1/2 ] / 2·1 = (1±9 1/2 )/2 = (1±3)/2, so r = 2 or r = −1. So a n = á 1 2 n + á 2 (−1) n.
14
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 14 Example Continued… To find á 1 and á 2, solve the equations for the initial conditions a 0 and a 1 : a 0 = 2 = á 1 2 0 + á 2 (−1) 0 a 1 = 7 = á 1 2 1 + á 2 (−1) 1 Simplifying, we have the pair of equations: 2 = á 1 + á 2 7 = 2á 1 − á 2 which we can solve easily by addition: 9 = 3á 1 ; á 1 = 3; á 2 = -1. Final answer:a n = 3·2 n − (−1) n
15
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 15 The Case of Degenerate Roots Now, what if the C.E. r 2 − c 1 r − c 2 = 0 has only 1 root r 0 ? Theorem 2: Then, a n = á 1 r 0 n + á 2 nr 0 n, for all n 0, for some constants á 1, á 2.
16
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 16 k-LiHoReCoCos Consider a k-LiHoReCoCo: It’s C.E. is: Thm.3: If this has k distinct roots r i, then the solutions to the recurrence are of the form: for all n 0, where the á i are constants.
17
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 17 LiNoReCoCos Linear nonhomogeneous RRs with constant coefficients may (unlike LiHoReCoCos) contain some terms F(n) that depend only on n (and not on any a i ’s). General form: a n = c 1 a n−1 + … + c k a n−k + F(n)
18
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 18 Solutions of LiNoReCoCos A useful theorem about LiNoReCoCos: If a n = p(n) is any particular solution to the LiNoReCoCo Then all its solutions are of the form: a n = p(n) + h(n), where a n = h(n) is any solution to the associated homogeneous RR
19
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 19 Example Find all solutions to a n = 3a n−1 +2n. Which solution has a 1 = 3? Notice this is a 1-LiNoReCoCo. Its associated 1-LiHoReCoCo is a n = 3a n−1, whose solutions are all of the form a n = á3 n. Thus the solutions to the original problem are all of the form a n = p(n) + á3 n. So, all we need to do is find one p(n) that works.
20
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 20 Trial Solutions If the extra terms F(n) are a degree-t polynomial in n, you should try a degree-t polynomial as the particular solution p(n). This case: F(n) is linear so try a n = cn + d. cn+d = 3(c(n−1)+d) + 2n(for all n) (−2c-2)n + (3c−2d) = 0(collect terms) So c = −1 and d = −3/2. So a n = −n − 3/2 is a solution. Check: a n 1 = {−5/2, −7/2, −9/2, … }
21
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 21 Finding a Desired Solution From the previous, we know that all general solutions to our example are of the form: a n = −n − 3/2 + á3 n. Solve this for á for the given case, a 1 = 3: 3 = −1 − 3/2 + á3 1 á = 11/6 The answer is a n = −n − 3/2 + (11/6)3 n
22
Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c)2001-2004, Michael P. Frank and Modified By Mingwu Chen 22 Review Recurrence relation Solving recurrences k-LiHoReCoCos LiHoReCoCos
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.