You are on page 1of 9
23 Recurrence Relations Proposition 22.3 gives a formula forthe sum of the squares ofthe natural numbers up (0 "= Oy Pata CEU Deed How did we derive this formula? In Exercise 22.16d you were told that a sequence of numbers, dod. da...» satishies the conditions do = 2, di = S.and dy, = Sdy-1 ~ 6dy--2 and you were asked to prove that dy = 2"43", More dramatically, in the same problem, you were asked to prove the following complicated expression forthe n™ Fibonacci number: cay 58" i= How did we create these formulas? 150 Chapter 4 More Proof ‘The recurrence relations with which sve begin ae called first order bocase ay can be expressed just in texms of the immediate previous element ofthe sequence, dy case he fet tern of the Sequence igo, i not meaningful to speak of the wm a Therefore, the recut relation Holds ony For n> 1. The ylue of ap must be ven separately In this section we present methods for solving a recurrence relation: a formula that spec- ifies how each term of a sequence is produced from earlier terms, For example, consider a sequence do, 1.42... defined by Ay = 30g 4g, ay = 3, ay = 2, We can now compute a in terms of ap and ay, and then a in terms of a2 and a, and so on: dz = Bay + dag =3x244x3 = 18 oan Seg t Aaj 3218 + 4X2 = G2 ag = 3s + day = 3 x 62 +4 x 18 = 258, ‘Our goal is to have a simple method to convert the recurrence relation into an explicit formula for the n"™ term of the Sequence. In this case, dy = 4" + 2-(-1)", First-Order Recurrence Relations ‘The simplest recurrence relation is dy = dy. Each term is exactly equal to the one before it, so every term is equal to the initial term, ag. Let's try something only slightly more difficult. Consider the recurrence relation ay = 2ay_1. Here, every term is twice as large as the previous term. We also need to give the initial term—say dg = 5. Then the sequence is 5, 10, 20, 40, 80, 160... Its easy to write down formula for then term of this sequence: ay = 5 x 2" More generally, if the recurrence relation is ay = 5y-1 then each termis just s times the previous term. Given ag, the n" term of this sequence is ay = aos” Let's consider a more complicated example. Suppose we define a sequence by Gq = 2dy-1 +3, do = 1 ‘When we calculate the fist several terms ofthis, sequence we find the Following values 1 5, 13 2% 6, 125, 253, 509, Because the recurrence relation involves doubling each term, we might suspect that powers of 2 are present in the formula. With this in mind, if we stare atthe sequence of values, we might realize that each term i 3 less than a power of 2, We can rewrite the sequence like this: 4-3, 8-3, 16-3, 32-3, 64-3, 128-3, 256-3, 512~3, With this, we obtain ay = 4-2" ~3, Unfortunately, "stare and hope you recognize” is nat a guaranteed procedure. Let's try to analyze this recurrence relation again in a more systematic fashion, We begin with the recurrence dp = 2a,—1 + 3 but leave the initial term ag unspecified for the moment, We derive an expression for ay in terms of ag using the recurrence relation: a = 2ap +3. Next, ets find an expression for aa. We know that @2 = 2a, +3, and we have an expression for ay in terms of ap. Combining these, we get dy = ay +3 = 2(2a9 +3) +3 = day + 9. Now that we have aa, we work out an expression for ay in terms of a: 3 = 2ap +3 = 2(dag +9) +3 = Bao +21. Section 23. Recurrence Relations 161 Here are the first several terms: ay = do ay = 2ao +3 a, = 4ag +9 a3 = Bag +21 Vag +45 dis = Fay +93 ag = Gag + 189. ‘One part of this pattetn is obvious: dy can be written as 2"ap plus something. I's the “plus something” that is still a mystery. We can try staring at the extra terms 0, 3,9,21. 45, 93. 189, in the hope of finding a pattern, but we don’t want to resort to that. Instead, let's trace out how the term +189 was created in a. We calculated ag from as ag = 2s +3 = 23209 +93) +3 so the +189 term comes from 2 x 93 +3. Where did the 93 term come from? Let's trace these terms back to the beginning: 189 = 2 93-43 = 2x (2x45 +3) 43 =2xQxO@x2143) 4943 2x QXxQxQx9+3 +3) 4343 2x 2x 2x QxQX3+3) +3) 43) +3) 43. ‘Now let's rewrite the last term as follows: 2x Ox (2x Ox (2X343 4343 43)43 HSH RIB RIEM EH IAM AT (25+ 24 + 22424284 2) x3 = (26—1) x3 =63x3 = 189 Based on what we have learmed, we predict a7 to be ay = 1289 + (27 —1) x3 = 27 (ag +3) —3 = 128a9 +381 and this is corect, We are now ready to conjecture. the solution to the recurrence relation ay = Daya +3. Ibis ay = (ao + 3) 2" = ‘Once we have the formula in hand, itis easy to prove itis correct using induction. How- ever, we don’t want to go through all that work every time we need to solve a recurrence relation; we want a much simpler method, We seek a ready-made answer to a recurrence relation of the form ay = Sdn +t where 5 and ¢ are given numbers. Based on our experience with the recurrence dy = 2adn-1 + 3, we.are in a position to guess that the Formula for ay will be of the Fol- Towing form: dy, = (@ number) x 5" ++ (a number, wr Chapter 4 Mare Proof Let's see that this is correct by finding a, a2, etc. in terms of ao ay = Sag +t ay = Sa +1 = ssa +) +1 = 5209 + (64 Dt $02 +1 = 8 (Pao + (8+ It) +6 = S'a04 2 +54 De 44 = 803 +6 = 5 (S240 4 62 45+ Dt) = stay + (7 $57 +54 De Continuing with this pattern, we see that diy = Shag + (SSF oe tsb DM, ‘We can simplify this by noticing that s"=" + s"-? 4... 4-6-4 1 isa geometric series whose stad sel provided s # 1 (a case with which we will deal separately), We can now write “(ES = ean of, collecting the s" terms, we have Gn Despite the precise nature of Equation (31), [ prefer expressing the answer as in the following result because itis easier to remember and just as useful Proposition 23.1 All solutions fo the recurrence relation dy dn + £ where # L have the form an = 5" bea where cy and ¢2 are specific numbers. Let's see how to apply Proposition 23.1 Example 23.2 Solve the recurrence dy = Say.-1 + 3 where a = 1 Solution; We have a= 15! + ¢2. We need to find ex and ¢2. Note that ay =1 scr ber a) =8=Sc, ben, Solving these equations, we finde, = 3 andes = —2, and so ‘We have a small bit of unfinished business: the case s = 1. Fortunately this case is easy. ‘The recurrence relation is of the form On = ayy +t where r is some number. I's easy to write down the first few terms of this sequence and see the result 9 = a9 ay = a9 +6 a =) $1 (Go tN +1 S49 42t 3 = a2 +0 = (ag +28) +1 ag = as +0 = (ao +3) +0 ‘Sce the pattern? In retrospect, it’s prety obvious. Section 23 Recurrence Relations 153 Proposition 23.3 Ina seconde recurrence relation, 4 is spect in tems of ay.=t and ‘ay 2. Sine the sequence bens with a9, the ecurenee relabon 6 vali for > 2, The values of and a must he given separately ‘The solution to the recurrence relation dy = ay—1 +1 is an = ag +n Second-Order Recurrence Relations {A second-order recurrence relation gives each term of a sequence in terms af the previous Wo terms. Consider, for example, the recurrence nat ~ Gay-2 @2 (This isthe recurrence from Exercise 22. 16d.) Let us ignore the fact that we already know a solution (0 this recuetence and do some creative guesswork. A first-order recurrence, dy ‘Say. has a solution that’s just powers of s. Perhaps such a solution is available for Equa tion (32). We can try dy = 5" o¢ perhaps ay = 6", but let’s hedge our bets and guess a solution of the form ay = r”* for some number r. We'll substitute this into Equation (32) and hope for the best. Here goes: an rh = Sptt = Gy? Ay = Sain ~ Ginn na Dividing this through by r"? gives =5r-6 ‘a simple quadratic equation. We can solve this as follows: P=5r-6 Pose + 6=(r=Ylr—3) ot ‘This suggests that both 2" and 3" are solutions to Equation (32). To see that this is correct, we simply have to check whether 2" (or 3") works in the recurrence. That is, we have to check whether 2" = 5-2"! — 6.2"? (and likewise for 3"). Here are the proofs 5.16.9" = 5.91 3.2.09 Ss. 3.2 =6-9-2t=2 = 6.38 5-1-2039? ase a2get = 6-2. a3, We have shown that 2" and 3” are solutions to Equation (32). Ate there other solutions? Here are two interesting observations First, ify is a solution fo Equation (32), so is cay, whete is any specific number. To see why, we calculate € (Sat ~ 6dy-2) = 5(Cn-1) ~ 6(€dp.2). ince 2" is a solution to (32), so is 5-2". ‘Second, if dy and ai, are both solutions to Equation (32), then so is ay + a. To see why, we calculate: ) = 6ldin-2 + dha), iy +a), = (Sdy—1 ~ Ganz) + (5a, — 62) = Sdn + 4, Since 2" and 3" are solutions to Equation (32), so is 2" + 3". ‘Based on this analysis, any expression of the form ¢}2" + c23" is a solution to Equa tion (32), Are there any others? The answer is no; le’s see why. We are given that dy, = Sdy1 — 6p. Once we have set specific values for ap and a1, a, a3, d4,... are all determined, If we are given do and a, we can set up the equations. 12 4 e238 =r bea 12! +023! = 2e1 + 30a ag a 184 Chapter 4 More Proof ‘There isa rough edge in his calculation; since we ae dividing by 10 this analysis faulty in he cease r = 0, However this sno problem because we chock oUF Work Jina moment by diferent method. ‘and solve these for ¢1.c2 to get Bag ~ ay Dag + ay. ry ‘Thus, any solution to Equation (32) can be expressed as an = Gap ~ a4) 2" + (-2ap + 41)3" Encouraged by this suecess, we are prepared to tackle the general problem nt + $2dn—2 3) where 5) and sp are given numbers, We guess.a solution of the form ay, = 1”, substitute into Equation (33), and hope for the best 1 + 520-2 ph oye page > sour ts so the r we seek is a root of the quadratic equation x? ~ 5.x ~s2 = 0. Let's record this as a proposition. Proposition 23.4 Lets. be given numbers and suppose r is a root of the quadratic equation x? —sx—s2 Then dy = r® isa solution to the recurrence relation dy = S1dq-1 + S2dn—2. Proof. Let r be a root of 1? —s1.x —s2 = O and observe nse syr +2) v7? because r su" + sor ‘Therefore r” satisfies the recurrence dy 1dy—t + Satna . We're now in a good position to derive the general solution to Equation (33). As we stw with Equation (32), if ay is a solution to (33), then so is any constant multiple of an—that is, a. Also, if dy and are to Solutions to (33), then sos their sum da + ‘Therefore, if ry and rz are roots of the polynomial x? ~ 5) x — s2 = 0, then is a solution to Equation (33). ‘Are these all the possible solutions? The answer is yes in most cases. Let's see what works and where we run into some trouble. ‘The expression cir! + car gives all solutions to (33) provided it can produce ag and ay; if we can choose cy and c2 so that @ scr? ter =e ter ark +arl=ne+ne then every possible sequence that satisfies (33) is of the form cir! + e2r'f. So all we have to dis solve those equations for ¢y and cz. When we do, we get this: ora non =n 72: we'll deal with this difficulty in a moment. First, le’s write down al Fan Allis well unless ry what we know so fa, Section 23 Recurrence Relations. 15 Theorem 23.5 Let 51,52 be numbers and let ry, r2 be roots of the equation x? —s4x —s2 =O. ry # ra, then every solution to the recurrence Gy = S141 + 5244-2 is of the form ay = crt Heard. Example 23.6 FFind the solution to the recurrence relation. iy = Mgt + Aya, do = 3. ay =2. Solution: Using Thearem 23.5, we find the roots of the quadratic equation x? ~ 3x—4 = 0. ‘This polynomial factors as x? — 3x — 4 = (x — 4)(x + 1) so the roots of the equation are ry = and ry = —1. Therefore dy has the form dy = c14" + ¢2(—1)" ‘To find cy and ca, we note that a= te mactttecy' = 2 che: Solving these gives: Therefore ay = 4" +2- Example 23.7 ‘The Fibonacci numbers are defined by the recurrence relation Fy = Fx + Fy—2. Using ‘Thoorem 23.5, we solve the quadeatic equations x? — x — 1 = O whose roots are (1 ¥/5)/2. “Therefore there is a formula for Fy ofthe form (2) onl) ‘We can work out the values of cy and cp based on the given values of Fy and Fi Fn Example 238 Solve the recurrence relation dy = 2dn— 2p where ag = 1 and ay = 3. Solution: The associated quadratic equation is x? — 2x +2 = 0, which, by the quadratic formula, has two complex roots: I 4: 7. Do not panic. There is nothing in the work we did that required the numbers involved to be real. We now just seek a formula of the form dn eu £1)" +91 — 1)". Examining ap and ay, we have ee Lifer + (1 iea i, Therefore dy = OU HOU 1" Solving these gives ‘The Case of the Repeated Root We now consider the recurrence relations in which the associated polynomial x? ~ 81x ~ 52 thas a repeated root. We begin with the following recurrence relation: Gy = Aga — Aen co) ‘with ap = Land ay = 3, The first few values of ay are 1, 3, 8, 20,48, 112, 256, and 576. "The quadratic equation associated with this recurrence relation is x? —4x-+ 4 = 0, which factors as (x —2)(x — 2). So the only root is r = 2. We might hope that the formula for ay 186 Chapter More Proof 2" but this is incorrect, Consider the frst wwo terms: takes the form dy = ag =1= 02° and ay =3 =c2! ‘The frst equation implies ¢ = | and the second implies ¢ = 3. We need a new idea, We hope that 2" is involved in the formula, so we try a different approach. Let us guess a formula of the form ay = e(n)2" here we can think of c() as a “changing” coefficient. Let's work out the first few values of () based on the values of dy, we already calculated: 2” (= 3 = =3 c= 5 > €Q)=2 as =20=G)2 + ()=3 a= 48 = c(42* > cfd) =4 7 as=11d= cp > (5) = 5 “The “changing” coetfcientc(n) works outto something simple: (a) = 1-+ in, We therefore conjecture that dy = (1+ n) 2" Please note that the solition has the following form: dy = ¢12" +242". Let's show that all sequences of ths form satisfy the recurrence relation in (34) by 4g = 4 (612! + 00(0 — D2") —4 (e122 + cal — 292") = [ei2" —e2"] + ean 2" — cand") + [4.2771 48-282] ci" + con? +0 = aa, So every sequence of the form dg = ¢12" + cpn2" is a solution to Equation (34). Have we found all-solutions? Yes we have, because we can choose cy and cp 0 match any initial conditions ag and aj ; here's how. We solve iy = 12° + 2-028 ay 2! + 02-12! Which gives 1 cr=ay and ey =p + a 1 =a mt + 54 Since the formula ay = 2" +42" is ofthe form c12" + can2, we know it satisfies the recurrence (34). Substituting » = 0 and n = 1 in the formula gives the correct values of do and ay (namely, 1 and 3), it follows that we have found the solution to Equation (34) Inspired by this success, we assert and prove the following statement. Notice the require- ment that r £ 0; we'll teat the ease r = 0 as a special ease. Theorem 23.9 [Lets S2 be numbers so that the quadratic equation x? — yx —s> = O has exactly one root, £0. Then every solution to the recurrence relation Oy = Sint + S2dy-2 is of the form an = err" + en Proof. Since the quadratic equation has a single (repeated) root, it must be of the form (=e =r) =x? = rx + 1? Thus the recurrence must be dy = 2rdq—t — dy “Thodtferenceopeatr A should nt be confused with he symmetric diference operation, also denoted by {4 The diference operator comers ‘asequence of mmbers into a new Sequence of umber, wheres the Symmtie dfference operation takes 1 pir of sts ad retumanoter set Section 23 Recurrence Relations 187 ‘To prove the result, we:show that ay satisfies the recurrence and that ¢y,¢9 can be chosen so.as to produce all possible aa, 1 “To see that dy satisfies the recurrence, we calculate as follows: 2g y — Fyn = Br (eve eal = Lye) — 0 (ex + exin ~2)e™) Beyr” — cnr") Qca(m— Ir" — enn =2)r") ur” ean” = ay ‘Ta see that we-can choose ¢4,.c2 to produce all possible aq. a1, we simply solve ag = cr $e2-0+79 = cy ay =cut Hop-on = rly +02) So long as r # 0, we ean solve these. They yield gr — ay crap and cp A . Finally, in case r = 0, the recurrence is simply a = 0, which means that all terms are. zero. ‘Sequences Generated by Polynomials ‘We began this section by recalling Proposition 22.3, which gives a formula for the sum of the squares of the natural numbers up to 1: 2 _ 2a + Wye + In) € Notice that the formula forthe sum of the frst squares is polynomial expression. In Excr- cise 22.4b you were asked to show thatthe sum ofthe first cubes is n?(n + 1)?/4, another polynomial expression, Proving these by induction is relatively routine, but how can we figure ‘out the formulas in the first place? Good news: We now present a simple method for detecting whether a sequences of num bers is generated by a polynomial expression and, if so, for determining the polynomial that created the numbers. ‘The key is the difference operator. Let do,a1,da,... be a sequence of numbers. From this sequence we form a new sequence [ OP + PED pop a? aya, ag—a1, asa in which each term is the difference of two consecutive terms of the original sequence. We denote this new sequence as Aa. That is, Aq is the sequence whose n® term is Ady = nei ~ ay. We call A the difference operator. Example 23.10 ‘he degree ofa polynomial ‘ameasion isthe largest exponent “ppeuring in the expression, For ceample, 30° =n? + 10g ‘egree’S polynomial in, Let a be the sequence 0,2, 7,15, 26, 40, 57, .... The sequence Aa is 2,5,8, 11, 14, 17. Thisis ‘easier to sce if We write the sequence a on one row and Aa ona second row with Aay written between ay and any. @ oo 2 7 1 26 40 37 Aa 205 8 ul 4 7 If the sequence ay is given by a polynomial expression, then we can use that expression to find a formula for Aa. For example, if dq = 03 — Sn + 1, then Adie = ant =a [+ 9 ~5er4) + 1]- [54 th =n 4 3n? 4+ 3n $1 —Sn-S + 1-0 +501 =3n? +3n —4. Notice that the difference-operator converted a degree-3 polynomial formula, n° ~ Sn + 1, into a degree-2 polynomial 198 Chapter More Proof Proposition 23.11 Leta be a sequence of numbers in which ay is given by @ degree-d polynomial in n where = 1, Then Aa isa sequence given by a polynomial of degree d Proof. Suppose dy is given by a polynomial of degree d. That is, we can write Gy = cant + eqn! $+ en + co where cg # Oand d > 1. We now calculate Aa: Ada = dnt ~ an = [ra 4 beyatn + Io be evta +1) +e] = [ean began! eben bea] = [cat nf cant] + [excatn OF ea] 4 + [e+ ern] + [60-eo} Bach term on the last line is of the form ¢y(n + 1)! — ey! We expand the (7 + 1)! teem using the Binomial Theorem (Theorem 17.8) to give |r 4 ({)e 4 (s)e feel (') ‘| Lage mo{(i)es (poe) Notice that c;( + 1’ ~¢jn/ is a polynomial of degree J — 1. Thus, if we look at the full expression for Ady, we see thatthe first term ¢q( + I) — can is a polynomial of degree d — | (because cy # 0) and none of the subsequent terms can cancel the n! term because they all have degree less than d — 1, Therefore Ady is given by a polynomial of degree d — 1. . ef + IY - ey = Ifa is given by a polynomial of dogree «then Aa is given by a polynomial of degree 4d ~1, This implies that (a) is given by a polynomial of degree d ~ 2, and so on. Instead of A(Aa), we write A2a. In general, Aa is A(A*!a) and Ala is just Aa. ‘What happens if we apply repeatedly to a polynomially generated sequence? Each subsequent sequence is 2 polynomial of one lower degree until we reach a polynomial of degree zero—which is just a constant. If we apply A one more time, we atrive at te all-zero sequence! Corollary 23.12 Ifa sequence a is generated by a polynomial of degree d, then A“ 1a is the all-zeros se- quence, Example 23.13 ‘The sequence 0,2, 7,15, 26, 40, 57,... from Example 23.10 is generated by a polynomial Repeatedly applying A to this sequence gives this: a 0 2 7 Is 26 40. 7 Aa: 2 s 8 " 4 ” Ata: 3 3 3 3 3 Ata: 0 ° ° ° Coroltary 23.12 tells us that if dq is given by a polynomial expression, then repeated applications of A will reduce this sequence to all zeros. We now seek to prove the converse; Section 23 Recurrence Relations, 19 that is, if there is a positive integer k such that Aig is the all-zeros sequence, then ay is, given by a polynomial formula, Furthermore, we develop a simple method for deducing the polynomial that generates dp Our fist tool isthe following simple proposition, Proposition 23.14 or those wha have ste liven ‘olgcbr, If we tink ofa sequance as a vector (with ininiely many components), then Proposition 23.14 says that A ica linear Not ony can (3) bg expressed polynomial inn, but the same is ue Feral!) (re kis ponte inegr) Using Theorem 1712, when mz kw () a6 n= Mn =2)--+(n = +1) Fert aed 0. This is equvalentto ("7") (2) = (2) which in tun isthe sume as (1')-(e() = By Pascal's Identity (Theorem 17.10), Equation (35) holds whenever 0 < k 0. Thus we know dy-1 = bm—1. We also know that ay = Bf, 5 here is why: yy = On = Am Amt = Phat = Abint = bn —bmn= bm bmi iy Ant = bm ee Thus dy = Dp forall n . We are now ready (o present our main result about sequences generated by polynomial expressions. Theorem 23.17 Let ao. d.d2,... be a sequence of numbers. The terms an can be expressed as polynomial expressions inn if and only if there isa nonnegative integer k such that forall 2 O we have AT aq = 0. In this case, Proof. One half of the ifand-only-if statement has already been proved: If dy is given by a polynomial of degree d, then A“, = 0 for all (Corollary 23.12). Suppose now that is a sequence of numbers and that there isa natural number & seh that for all n, Akay, = 0, We prove that dy is given by 4 polynomial expression by showing that ay is equal to nef) + cae (7) +(e) (3) + (ata) (1) ‘Ta show that ay, = by for all, we apply Proposition 23.16; that is, we need to prove ay ok ACby = 0 for all a, (2) ao = bo, and @) Mag = Albo forall t 0, we construct an s-cube by taking 1wo disjoint copies of an (11 ~ I)-cube and then joining corresponding points in the two cubes by line segments. Thus, a I-cube is simply a line segment and a 2-cube is a quadrilateral ‘The figure shows the construction of a 4-cube from two copies of a 3-cube. Note that fan n-cube has twiee as many points as an (1 — 1)-cube; therefore, an n-cube has 2” points. The question is, how many line segments does an n1-cube have? Let ay, denote the number of line segments in an n-cube. We have dy =0,a1 = 1,42 = 4,a3 = 12, and ag = 32, a Calculate as. bb. Find a formula for dy in terms of ay 1 Find a formula for ay just in terms of w (and not in terms of a1) and use part (b) to prove that your formula is correct. Solve the equation A%a,, = —dy with ay = ay = 2. Find two different sequences a and b for which Ay = Ab, for all r The second-order recurrence relations we solved were of the form Gp = sydn-1 + Sada. In this problem we extend this to relations ofthe form ay = sydy—t +5292 +. Typically (but not always) the solution to such a relation is of the form ay = cyrf + carl + cy where c1,¢2,¢3 are specific numbers, and ry,r2 are roots of the associated quadratic equation x ~ s,s) = 0, However, ifone of these roots is I, orif the roots are equal to each other, another form of solution is required. Please solve the following recurrence relations. In the cases where the standard form does not apply, iy to work out an appropriate alternative form, but if you get stuck, please consult the Hints (Appendix A). 2B. dy = Stn ~ 6ay2 + 2,0 De dy = Ady $ Sdya2 #4, 9 = 2ay—1 + 4dp-2 +6, a0 Banat —2dnaa + 5,0 —9aj-2 = 2a = -lea = 4. 21 —dn-2 + 2g = 4.) = 2. Extrapolate from Theorems 23.5 and 23.9 to solve the following third-order recurrence relations. Be diy = Adyt — diya ~ Gays, 40 = 8, 4) = 3, and a = 27. Be dy = ay 4 + 2aq—z — Aetn-2,.09 = [1 = 10, and a = 32. dq =~ y= ot Baga + 12dy-2, do = 6,41 = 19, and ar = 25. ay = Gay1 ~ 122 + Bays, 4g = 3,0 = 2, and a2 = 36, ‘Suppose you wish fo generate elements of a recurrence relation using a computer pro- ‘gram, ICis tempting to write such a program recursively. For example, consider the recurrence ay = 3dy1 — 2dy2, dg = I,ay = 5. Here isa program to calculate the values dy: procedure get.tora(n) sf <0) print ‘ILlegal argument? exit ond if @ = 0) return t end if =) return 5 Chapter Self Test 16 end return Seget_term(n-t) ~ 2egetterm(n-2) end Although this program is easy fo understand, itis extremely inefficient. Explain why, In particular, let, be the number of times this routine is called when it calculates dy. Find a recurrence—and solve it! —for by. 23.17. There are many types of recurrence relations that are of different forms from those: presented in tis section. Try your hand at finding a formula for dy for these: Be dy = Nd-1.00 = | a2. © dy = a9 Fay Fy bot gto = 1 A. ay = nag + (N= Nay +(e De +--+ 2d + Na bey = 3.91n1(1 dni) ao = 4. 23.18, The Catalan numbers are a sequence defined by the following recurrence relation: and crt = Yo cere: cond Please.do the following a. Calculate the first several Catalan numbers, say up (0 ¢s . Find a formula for cy, Part (b) is quite difficult, so here is a bit of magic to get you to an answer. The On-Line Encyclopedia of Integer Sequences is 4 tool into which you can type a list of integets to determine if the sequence has been studied and what is known about the sequence. It is available on the web here: http: //oeis.org/ €. Use Theorem 23.17 to find a formula for this sequence of numbers: 0, 1,5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210. Please simplity your answer. 4. Use the On-Line Encyclopedia to find the name of the sequence in part (¢). e. Finally (just for fun) consider this sequence: 1, 2,3, 4, 5, 6,7, 8, 9, 10, 11, 12, 14, 15, 16,17, 18, 19, 20, 21, 22, 23, 24... Try to idemtfy this sequence on your own before going to the On-Line Encyclopedia forthe answer es ines a: Provesthat the equation x? + 1 = 0 does not have any real solutions. rove that there is no integer x such that x? = 2. rove that the sum of any four consecutive integers is not divisible by 4 Leta and b be positive integers. Prove: Ifalb and bla, then a Which ofthe following sets are well-ordered? ‘a, The set ofall even integers. . The set of all primes. €. 100, —99, -98,.....98, 99, 100}. ao. e. The negative integers. f. (a? a re4,...} where is the familiar real number 3.14159 Let be & positive integer. Prove that an? 9 Pade Tbe t G02) = . Let be a natural number, Prove that OF E+ tal slat Dh 3. Suppose ap = 1 and dp = 4ay—1 ~ 1 when n > 1. Prove that forall natural numbers 7, we have ay =(2-4" + 1)/3. . Prove by induction: Ifm € N, then 2 <2"

You might also like