Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module #20 - Recurrences 1 7.2 Solving Recurrences Rosen 6 th ed., §7.2.

Similar presentations


Presentation on theme: "Module #20 - Recurrences 1 7.2 Solving Recurrences Rosen 6 th ed., §7.2."— Presentation transcript:

1 Module #20 - Recurrences 1 7.2 Solving Recurrences Rosen 6 th ed., §7.2

2 Module #20 - Recurrences 2 §7.2: Solving Recurrences A linear homogeneous recurrence of degree k with constant coefficients (“k-LiHoReCoCo”) is a rec. rel. 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.A linear homogeneous recurrence of degree k with constant coefficients (“k-LiHoReCoCo”) is a rec. rel. 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.The solution is uniquely determined if k initial conditions a 0 …a k−1 are provided. General Solution Schemas

3 Module #20 - Recurrences 3 Solving LiHoReCoCos Basic idea: Look for solutions of the form a n = r n, where r is a constant.Basic idea: Look for solutions of the form a n = r n, where r is a constant. This requires solving 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 = 0This requires solving 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 r to this equation are called the characteristic roots of the LiHoReCoCo.The solutions r to this equation are called the characteristic roots of the LiHoReCoCo. –They can yield an explicit formula for the sequence. (rearrange & × by r k−n )

4 Module #20 - Recurrences 4 Solving 2-LiHoReCoCos Consider an arbitrary 2-LiHoReCoCo: a n = c 1 a n−1 + c 2 a n−2Consider 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 = 0It has the characteristic equation (C.E.): r 2 − c 1 r − c 2 = 0 Theorem 1: If the CE has 2 roots r 1 ≠r 2, then the solutions to the RR are given by: a n = t 1 r 1 n + t 2 r 2 n for n≥0 for any and all constants t 1, t 2.Theorem 1: If the CE has 2 roots r 1 ≠r 2, then the solutions to the RR are given by: a n = t 1 r 1 n + t 2 r 2 n for n≥0 for any and all constants t 1, t 2. Special case: a n = r 1 n and a n = r 2 n are, of course, solutions.

5 Module #20 - Recurrences 5 Example Solve the recurrence a n = a n−1 + 2a n−2 given the initial conditions a 0 = 2, a 1 = 7.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:Solution: Use theorem 1: –We have c 1 = 1, c 2 = 2 –The characteristic equation is: r 2 − r − 2 = 0 –Solve it: –so, r = 2 or r = −1. –So, a n = t 1 2 n + t 2 (−1) n. (Using the quadratic formula here.)

6 Module #20 - Recurrences 6 Example Continued… To find t 1 and t 2, just solve the equations for the initial conditions a 0 and a 1 : a 0 = 2 = t 1 2 0 + t 2 (−1) 0To find t 1 and t 2, just solve the equations for the initial conditions a 0 and a 1 : a 0 = 2 = t 1 2 0 + t 2 (−1) 0 a 1 = 7 = t 1 2 1 + t 2 (−1) 1 Simplifying, we have the pair of equations: 2 = t 1 + t 2 7 = 2t 1 − t 2 which we can solve easily by substitution: t 2 = 2−t 1 ; 7 = 2t 1 − (2−t 1 ) = 3t 1 − 2; 9 = 3t 1 ; t 1 = 3; t 2 = −1. Using t 1 and t 2, our final answer is: a n = 3·2 n − (−1) nUsing t 1 and t 2, our final answer is: a n = 3·2 n − (−1) n Check: {a n≥0 } = 2, 7, 11, 25, 47, 97 …

7 Module #20 - Recurrences 7 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 ?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 = t 1 r 0 n + t 2 nr 0 n, for all n≥0, for some constants t 1, t 2.Theorem 2: Then, a n = t 1 r 0 n + t 2 nr 0 n, for all n≥0, for some constants t 1, t 2.

8 Module #20 - Recurrences 8 Degenerate Root Example Solve a n = 6a n−1 −9a n−2 with a 0 =1, a 1 =6.Solve a n = 6a n−1 −9a n−2 with a 0 =1, a 1 =6. The C.E. is: r 2 −6r+9=0.The C.E. is: r 2 −6r+9=0. –Note that b 2 −4ac = (−6) 2 −4·1·9 = 36−36 = 0. Therefore, there is only one root, namely −b/2a = −(−6)/2 = 3.Therefore, there is only one root, namely −b/2a = −(−6)/2 = 3.

9 Module #20 - Recurrences 9 k-LiHoReCoCos Consider a k-LiHoReCoCo:Consider a k-LiHoReCoCo: It’s C.E. is:It’s C.E. is: Theorem 3: If this has k distinct roots r i, then the solutions to the recurrence are of the form:Theorem 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 t i are constants.

10 Module #20 - Recurrences 10 Degenerate k-LiHoReCoCos Suppose there are s roots r 1,…,r s with multiplicities m 1,…,m s. Then:Suppose there are s roots r 1,…,r s with multiplicities m 1,…,m s. Then: for all n≥0, where all the t are constants.

11 Module #20 - Recurrences 11 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: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) The associated homogeneous recurrence relation (associated LiHoReCoCo).

12 Module #20 - Recurrences 12 Solutions of LiNoReCoCos A useful theorem about LiNoReCoCos:A useful theorem about LiNoReCoCos: –If a n = p(n) is any particular solution to the LiNoReCoCo: –Then all of 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

13 Module #20 - Recurrences 13 LiNoReCoCo Example Find all solutions to a n = 3a n−1 +2n. Which solution has a 1 = 3?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.

14 Module #20 - Recurrences 14 Trial Solutions If the extra terms F(n) are a degree-t polynomial in n, you should try a general degree-t polynomial as the particular solution p(n).If the extra terms F(n) are a degree-t polynomial in n, you should try a general degree-t polynomial as the particular solution p(n). This case: F(n) is linear so try a n = cn + d.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 + (2d−3c) = 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, … }Check: a n≥1 = {−5/2, −7/2, −9/2, … }

15 Module #20 - Recurrences 15 Finding a Desired Solution From the previous, we know that all general solutions to our example are of the form: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.The answer is a n = −n − 3/2 + (11/6)3 n.

16 Module #20 - Recurrences 16 Double Check Your Answer! Check the base case, a 1 =3:Check the base case, a 1 =3: a n = −n − 3/2 + (11/6)3 n a 1 = −1 − 3/2 + (11/6)3 1 = −2/2 − 3/2 + 11/2 = −5/2 + 11/2 = 6/2 = 3 a 1 = −1 − 3/2 + (11/6)3 1 = −2/2 − 3/2 + 11/2 = −5/2 + 11/2 = 6/2 = 3 Check the recurrence, a n = 3a n−1 +2n:Check the recurrence, a n = 3a n−1 +2n: −n − 3/2 + (11/6)3 n = 3[−(n−1) − 3/2 + (11/6)3 n−1 ]+2n = 3[−n − 1/2 + (11/6)3 n−1 ] + 2n = −3n − 3/2 + (11/6)3 n + 2n = −n − 3/2 + (11/6)3 n ■


Download ppt "Module #20 - Recurrences 1 7.2 Solving Recurrences Rosen 6 th ed., §7.2."

Similar presentations


Ads by Google