0% found this document useful (0 votes)
289 views49 pages

DM&GT Unit-3

Dmgt full notes

Uploaded by

krishnakamma07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
289 views49 pages

DM&GT Unit-3

Dmgt full notes

Uploaded by

krishnakamma07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
CHAPTER Recurrence Relations 6.1 GENERATING FUNCTIONS OF SEQUENCES The objects of interest in this unit are sequences of real numbers (dg, @), 5s yy ~) that is, functions whose domain is the set of non-negative integers and whose range is the set of real numbers. In other words, a function a: Z* -> Ris called sequence or sequence of real numbers. ‘We shall use expressions like A= {a,}%, “uy © denote such sequences. Example 1. A= {3"}"__, is the sequence and A=(1, 3,927, 81, sy BY sa) Example 2. mt Land B= (1,2, 3,4 oy mt Ty on) = {B,}T_, where B Next we introduce the concept of generating function, a generalization of the concept of polynomial, to allow for that eventuality and it is one of the most powerful tool for solving recurrence relations, Definition, Let A ={a,}"_, be the sequence of real numbers, then ay + a; x + ay x7 + = Liayx" #5 called power series and we write it as A (x). Aly) Ye Wt ax Pt a baat where xis an indeterminate, 315 316 4 Mathematical Foundation of Computer Science ‘The expression A (x) is called a formal power series is the coefficient of #, the term a, 22s the term of degree #and aj is called the constant term. We use the word “formal” to distinguish between the abstract symbol A (x)= a, x" and the concept of power series. Definition. Let A= {a,}"_) = (ap dye day oo dy son) Be the sequence. Then its generating incon is defined tbe A (s) = Sac ot ay eta e+ Note 1. We can easily obtain generating function from sequence and its converse. For example, the fo"k eo taxt xt abel + ou. (I) generating function of {4,}” ‘The infinite series in (1) can be written in closed form as _ which is a rather compact way to represent the sequence (a) = (1, ce.) Note 2 If #0 and ¢,= Ofor i= k++ 1 in A (2, then eee ees isa polynomial of degree Kand itis also called generating function of finite sequence (@y 4, Example 1. The generating function of the sequence {3°} | is AUN 14 Bx FB EB Fe BOWE Example 2. Find the generating function for the sequence (F, 1, 1, 1, 1, 1). Solution. Generating function for the sequence (1, 1, 1, 1, 1,1) is, Alga lt let lee ies itt ae leat date tad’ Example 3. Find the generating functions for the following sequences. ) oF (1,2, 3, 4 so) Fi) (E78 a) oF (1, = 2, 3, = 4 sured) Solution. (i) Generating function for sequence {nr} is A() = Daye", where a, = ay at a? 142+ 32+ =(1-3)7. Recurrence Relations 317 (i) Generating function for the sequence 1, ~ 2, 3, — 4, .... is A(x) = 1-204 3x ~ 4x8 + =(1+3)? Example 4. Find a generating function for the sequence 1 if ‘ A={a,}"_,, wherea,=93 if 3 0 in closed form. Solution. The generating function for this sequence is Algh=14 3x4 322433 4 > A (x) - 1 = 3x4 (3)? + (8x9 + 0. > A (x) - 1 = (Ga) [1 + (Bx) + (8x)? +. > AMAT yy ace ( > = (or) =(1-3x)t= 1- 3x Example 2. Find the generating function for the sequence (1, 0, 0, 0°, ......) where «. is fixed constant in closed form. Solution. The generating function for this sequence is Alaj)=14axt ox + 08x) + ox Example 3. Find the generating function (in closed form) of the fibonacci sequence {f,) defined by Sn +hn-25F0= Oi fr =1. Recurrence Relations & 319 Solution. The generating function is fet fxr fx + fet Yast (1) azo Consider f=foithnn20 Multiply both sides by x", and sum over all n> 2, we get Dh = Yh + Yh (2) m2 nad md Consider the first sam Lhe = nee (From (1)) Similarly, Yhat = ft $f boone ane Sx(fat fx toss) = «(A (x) -f) (From (1)) and J focaet = fat fa + fit! toe net HP (Gt fet fe + on) =x A(x) Substituting these three expressions in (2), we get Al) -f-fix=x(A(a)-f) +P AQ) Since f= 0 and f,=1, we get A(a) -«=axA (x) +27 A (a) => A(a) (L-x- ¥) Therefore, the required generating function is A (x) = l-x-x" Example 4. Find the sequences generated by the following functions : W) (24x) (ii) 2x (1- x)" (iii) 3x7 + A. 3 Solution. (:) We have (2 + x)'=8 ( +3) 320 «4 Mathematical Foundation of Computer Science =8{1-c(n3 1)=+€(,2) ws(dred este) 2 4 8 =84 1dxt 6x + 108 This shows that the sequence generated by (2 + «)° is 8, 12, 12, 1, 0, 0, 0, (ii) We have 2x7 (1 - a)" we (Lt at etx tin) =0+ 0x4 2 + 2x 42x +20 +... ‘The required sequence is 0, 0, 2, 2, 2, 2, » (2x)? + (2x) . (2x)" (iii) We have 3x) + @*=38 +14 2! 3! 4! ssn s(et)ovte 6 24 =142rtor4 B oats +. 13 2 The sequence generated by 3x° + @* is 1, 2,2, Example 5. Find the generating functions for the following sequences : @ 0, 1, 2, 3, (io) P, 27, i) P, 2, @) 8,7, 23, 3%, (ii) 0, P27, ae Solution. (#) Generating function is 0 + Ix +2. + 3x°+ =x(L+ 2x4 3x74. x(L- (i) We have x + 207 4 3x3 +... 14+2 (2x) +3 (38x) + = PHP x4 Pts Recurrence Relations ® 321 Pe Pe 2? 2492 ee gy 1+ (ii) We have? +P x42 P43? P+ xP +2? xt PP + t 7 (by above 1- x) result (ii}) 9 42 o2 a? 1+ Generating function of 0%, 1°, 2, 3%, ..... is x( 3 ax (io) We have I? x42? 24378 +. Differentiating w.r.t. on both sides, we get d x(1+x) PHP v4 33H 4. = a (ay 2 : +4xtl => P4tet ahve = TEE ; which is required generating function. x +4e tl (v) We have 1? +23 xt 3° x +... - (1-4) => OP x4 Br ssi v st... Then generating function for 0°, 1°, Example 6. Find the generating function for the sequence {a,}"_, ifa, =n +1. (or) Find the generating function for the sequence 0, 2, 6, 12, 20, 30, Solution. We have the generating function for the sequence {n} is A=, (See example 3) (I~) and the generating function for the sequence {n”} is 1 =*l +%) (See example 5 (ii) (1- x) Then, the generating function for the given sequence {n+ 1°} is x(l+x)_ dx (ay) ea) 322. 4 Mathematical Foundation of Computer Science Example 7. If n is a positive integer, prove that C (- n, 1) = (-1)'C (n+ 7-1, 9 =(- 1)" C(n+ r= 1, n= 1) and hence find generating function for C (n+ r= 1, ) @ Ca) a= n=2) rune —n-r+l) Proof : We have C (- n, 1) = , by definition rl _n(n+l)(n+2 n+r—1) pntr-l! =¢1) (n+) ) ( ) ay) r! n-I!r! =I (nt r-1, =I C (nt r-1, n= 1) > C(ntr-1j=CICEnD Therefore, Ye (rsr-taa’e’ = YEN CEnrya’x" no no = Yc-nn-ay fo =(1-a)" Generating function for C (nv — r+ 1, 7) a’ is (1 - ax) Note, The generating function for C (n= r+ 1, ) C gis (1+ aay”. Table 6.1 Table of Generating Functions S. No. Sequence Generating Function L Ck (i+ af 2. 1 a 3. a” 1l-ax 1 4 - 1)" a co lex 5 1" a=( a" 1 ‘ L+ax 6. C(k-14 1, n) (kis a fixed positive integer) 1. C(k-1+ n,n) at 8 Clk-1t mn) ae 9 n+1 Recurrence Relations 323 10. n i. (n + 2) (n + 1) 12, (n+ 1) n 13. n 14, na" 15. wa Definition. Let A (x) = Sa, x", B (x) = ¥.b, x" be two formal power series. Then, a0 io 1, Equality : A (x)= B (a) iff a, }, for each 22 0 2, Multiplication by a scalar number C :C A(x) = }'(Ca,) x’ 10 3. Sum : A(x) + B(x) = Yee +4,)x". n=0 4. Product : A(x) Bla) = ))P,a" where P,= Y)a,), io isjen = a), + a, By) + dy By +d, b, +a, Dy Then A(x) B(x) = cay By x° + (ay by + ay by) x4 + (hy by + Oy By + ty Dy) 2H eee (4 by + By y+ Oy by ig F vvveee # My bg) HEF oe 6.2 CALCULATING COEFFICIENT OF GENERATING FUNCTION Rule of Counting : Suppose we wish to determine the number of integer solutions of the equation ¢ + @ + ..... + ¢, = rwhere 0's rs nunder the constraints that é can take the integer values a1, @2, a3, ¢ can take the integer values @), a, 35 ¢, can take the integer values dj), day dy, ee To solve this problem, first we define the functions 324 44 Mathematical Foundation of Computer Science ils) A (2) Jj (3) as follows : fila) =x be ae Al) oy yl gE Hla ae and consider f(a) as f(s) ih (36 (nee fe (4) and determine the coefficient of x’ in this function. This coefficient happens to be equal to the number of solutions that we desired to find. The function f(x) is called the generating function for the problem. Example 1. The coefficient of x in (1 + x° + a9)! is C (10, 3) = ao because the only solutions of ¢ + & + ...... + &)=9 where each ¢;= 0, 3, 8 are those solutions here 3 values are equal to three, and the remaining values are () and the coefficient of «°° is ——"— zm ogy Because each solution to the equation will involve three 3°s, two 8's, and five 0's. Example 2. Find the generating function that determines the number of non-negative integer solutions of the equation e; + ¢3 + €; + ey + ¢5 = 20 under the constraints 0 < ¢, $3, OS €, 54,2 Se; 56, 28,55, es is odd with es < 9. Solution. Take ajavgcle eee ae e eevee av tcoatgv ts? filajaraceate fljaatae arti te, Hence the generating function for the number of non-negative integer solutions of the given equation under the given constraints is SI=KMAML AA OL t=x4 1-% yg 1-x 4 1-xt , x x a (lta? 4x4 42°45) =x (I- x") (1-2) (1-3) (148) (1-2) Example 3. Find the coefficient of x? in (1 +.x5 + x°)!”. Solution. We want the solutions of ¢, + & + Fe) = 32 where each ¢,= 0, 5, 9. This can be done only with three 9s, one 5, and six 0’s Thus, the 10! BIL6! coefficient of x” is Recurrence Relations W325 Example 4. Find a generating function for a, = the number of ways the sum r can be obtained when (i) 2 distinguishable dice are tossed (ii) 2 distinguishable dice are tossed and the first shows an even number and the second shows an odd number. Solution. (i) We want the number of integral solutions to ¢, + & = r where 1 PWS txt) (Lt at Pt) (Lt ete to) x (Lt xx +...) H(l¢xtxreet (1-ay* Taking x= °°, we get r= 25 The coefficient of x” is C (3 + 25, 25) (28, 25). 28! = 051g) = 3276. Thus, the given equation has 3276 non-negative integer solutions. (i) In the case of positive integer solutions, ¢}s can take values 1, 2, 3, 4, ...... accordingly. We can write fj(x)=a' +2 +a + x4 +... for f= 1, 2,3, 4. Therefore, the generating function is f(x) = f, (x) f(a) fi (0 f (9. “ fiat re oats iy! av (ltxe¥ 4x. fta-ayyt ys x (L-ay> YcE+r rx” 70 The coefficient of x C (3 + 21, 21) = 4! Lop o4. 2113! Thus, the given equation has 2024 positive integer solutions. Example 12. Jn how many ways can we distribute 24 pens to 4 children so that each child gets at least 3 pens but nat more than eight. 328 4 Mathematical Foundation of Computer Science Solution. The given problem is equivalent to the problem of finding the number of integer solutions of the equation x; + x) + a3 +44 = 24 with 3 <.x;< 8 for each x; Keeping the constraints on x; in mind, let us consider the functions f(x) =x + x'+ 2° +x +x + for i= 1,2, 3,4. ‘Therefore, the generating function for the problem is AI=AMLAMAW AU) a(t ata +a)! ‘The required number is the coefficient of x’ in this function. Now, we find that f(x) =a" (l+ a+ +03 +x'+.°)* aa (=) asx!) Ua! l-x = x2 [2 Cl4n)(- e} Zowr-noe] =) =x” [& 1 C(4,r) x". Ye prnae'] rao =O From this, we find that the coefficient of 2” in f(x) is C (4, 0) € (15, 12) -C (4, 1) C 0,6) + C (4, 2) C (3, 0). = 455 — 366 + 6 = 125, which is the required number. Example 13. Using the generating function, prove that the number of ways of choosing with repetitions, r of n objects is C (n +r - 1, 1). Solution. The problem is equivalent to that of finding the number of ways of selecting r similar balls from n numbered boxes. If x, is the number of balls selected from the box i, then x, satisfy the equation Rt ay tay tin. baa (1) and the constraints x; 20 for i= 1, 2, 3, ......, (2) ‘Thus, we have to find the number of integer solutions of the equation (1) under the constraints (2). We take SlQee tt te tone =(1- 4)! for i= , nt so that = =Vcwer-tyx (3) ° This is the generating function for the given problem, and the number of integer solutions of the equation (1) under the constraints (2) is the coefficient of x’ in this function. This coefficient, is evidently, Recurrence Relations 329 C(nt+r-1a) This proves the required result. Example 14. Find a generating function for a, = the number of ways distributing r similar balls into n numbered boxes where each box is non-empty. Solution. First we model this problem as an integral solution of an equation problem : namely, we are to count the number of integral solutions to ¢; + ¢ + ..... + , = % where each @21. Then the generating function is (x + x7 + 2° + =) i EXERCISE 6.1, L-—_-_— 1. Find the sequence generated by (@ 2 (L- 97 () (leapt 2, Find a generating function for the following sequences : (gj 1,1,0, 1,1, (8) 1,0, 1,0, 1,0, 3, Find a generating function for the sequence {a,}, where a,=0 for 0S rs n- 1 =C (r-1, n-1) forr2>n. \ (9 of rotst.. 4, Find a generating function for the numeric function @, { vif riseven 2" if risodd 5. Find the coefficient of x° in (1 = 2a)7. 6. Find the coefficient of x’? in (@ (L~ 4x)" () (+ ay” 7. Find the coefficient of x in (x! + x! +... +5 8. Find the coefficient of 2 in (x? + 2 + x! +29 + 2°) 1 (v-3)(e-2) Find the coefficient of x in © ¥ 10. Determine the coefficient of x'* in the product (x+ 2+ + af + ¥) (P+ x + x! Fosse)? 11. Find the coefficient of x" in (x? + x + x! + .2...)! 12. Determine the coefficient of x!° in (1 +x x7) (x 2 + 3x) + dat + 13. Finda generating function for a, =the number of non-negative integral solutions to ¢, + ¢ + + ¢,= 7, where 0 < <1. 14, In how many ways can 12 oranges be distributed among three children X, Y, Z, so that X gets at least four, ¥ and Z get at least two, but Z gets no more than five ? 15, Find the coefficient of in (1+ 7 + 2°)!" 16. Find a generating function for ¢,=the number of non-negative intregral solutions of ¢ + & + & +e, + 6=rwhere 0 <6, <3, 0< 4 £3,2 <0 56,2 1. Note. Recurrence relation is also called difference equation. Example 1. If a, denotes the sum of the first n positive integers, then 5, a recurrence relation, n+ s,_, which is Example 2. If s, denotes the m!” term of a geometric progression with common ratio 7, then 5, = 15,1 which is a recurrence relation. Example 3. ¢,~3a,_,+ 2a, 9=0 Example 4. a, ~ 5a,_; + 6a,_) = Example 5. a? +a7_,=- 1 Example 6. a, ~-(n~ 1) a,_;+(n~ 1) a,_,=0 Definition. Suppose n and k are non-negative integers. A recurrence relation of the form Cy (n) a, + Cp (a) dy — pt vsese + Gy (n) Oy =f (n) .». (1) for n = k, where Cy (in), Cy ()y vey Gy (n) ane f (n) are functions of n is said ta be a linear recurrence relation. If Cy (n) and C, (2) are not identically zero, then kis called degree of above linear recurrence relation. If Cy (n), C, (n), , C, (n) are constants, then the recurrence relation (1) is known as a linear recurrence relation with constant coefficients. If f(x) = 0, then (1) is said to be homogeneous recurrence relation. It ‘f{n) #0, then (1) is said to be inhomogeneous recurrence relation Note 1. All the examples above are linear recurrence relations except (5) because it contains square term. Note 2. The relations in (1), (2), (3), (4) are linear with constant coefficients. Note 3. Relations (1), (2) have degree 1 ; (3), (4) have degree 2. Note 4. Relations (2), (3), (6) are homogencous. Note 5. Relations (1), (4) are inhomogeneous. 6.3.1 The Fibonacci Recurrence Relation Definition. The recurrence relation F, =F,_, + Fy», n 22 with initial conditions Fy =F; = 1 is known as Fibonacei recurrence relation (or) Fibonacci relation. The numbers F, generated by the Fibonacci relation with initial conditions Fy = F, = 1 are called the Fibonacci numbers. The sequence of Fibonacci numbers {E,}7_, is the Fibonacci sequence properties of Fibonacci numbers. L Rt hy +P ta t ESF yoo Proof : We have F,,=F,_, +F,_9; n22,Fy= nei + Fy Replace nby n+ 2, we get Fy, 9 => Put 332 4 Mathematical Foundation of Computer Science Ry=F-F, F,=E,-F, Adding, Fy+F, +R) + Fy, => Fy t By + Fy ton + Fy =Fyy 9-1 2. Fy + Fy t Fy t e+ Foy = Fong 3. +A +R t.. th =F Pia) The above (2) and (3) properities can be proved by mathematical induction. Also, there is an interesting relation between Pascal’s triangle and the Fibonacci numbers, illustrated below : Clearly, the sum of the elements lying on the diagonal running upward from the left are Fibonacci numbers. With this introductory exposure about recurrence relations, our main aim is to solve the recurrence relations. Example. Prove that F2 =F,_; F,., + (- 1", n22 Solution. Using induction on 1. When n= 2, Fi =4=1.3+1=F, F, + (- 1? Now assume that the result is true for n= k Therefore FR=F,) yyy + C1)! (1) Consider FyFyegt CTS Fy ey +R) + HER yi th? +i"! SE, Fy yy + Fy-y Pega tC '+ C1)!*! by (ay) = Frei Fat Fe.) Recurrence Relations & = 333 =Feai Frat (By definition of recurrence relation) The result is true for n=k+ 1 = Hence the result by induction. Example. Prove that F, + F, +. Proof : Here, we use induction on n. When n=1, F,=1=2-1=F,-1 Now assume that the result is true for n= k We have FL + Fy tone + Foy aol (1) Consider Fy + Fy to. + Foe + Foes = ~ 1+ Fay, by (1) =Fyy.9-1 (by definition of Fibonacci Recurrence Relation) Therefore, the result is true for n= k + 1 by finite mathematical induction, the result is true for all n> 1. 64 SOLUTIONS OF RECURRENCE RELATIONS Definition. A sequence {a,}y_ 18 said to be a solution of a recurrence relation if eack value a, 1.0.) Ap, Aj, A, 4, o> Aj, A, satisfies the recurrence relation. Example 1. {a,}"_, where a, = 2" is the solution of the recurrence relation @, = 2a, _, n> 1 and the sequence {¢2"}"_ | where cis constant is also solution of recurrence relation a, = 2d,. 1, n21. Example 2. For the recurrence relation a, - 7 4,_, + 10a, solution, whete ¢, @ ate arbitrary constants, because a, Tle 2) + eq 5") +10 (6 2" 2465" 2" — Fe, 2") + 10e, 2") + (ey 5"— 7,5" + 106, 5"~7) = 6 2"? (27-7 (2) + 10) + & 5"~*) (57 - 7 (5) + 10) = 4 2"? (0) +645"? (0) =0. Note 1. In each of the above examples there are infinitely many different solutions, one for each specific value of the constants. Suppose if we want the solution of the recurrence relation 4, ~ 74-1 + 104, 9 =0, n> 2 for which a) = 10 and a = 41. These so called boundary conditions are requirements that must be satisfied in addition to that of satisfying the recurrence relation, =0, 22, 4,=¢,2" + 5"is the a@,_, + 10a, (q 2° + @ 5") - Note 2. We can compute 4, in terms of ay jy ---- jy @ j then we can compute 4, ,; in terms of ayy 4y_ 15 ss 5 do and so on, provided the value of the sequence at one or more points is given so that the computation can be initiated. Therefore, we need some values of the sequence. Usually the values for @y, 4), @), .... dy_ 1 are given and then it would be appropriate to call these initial conditions 334 4 Mathematical Foundation of Computer Science Note 3. Like in algebra, recurrence relations may have no solution. For example, ay + dj has no solution, since there are no real-valued functions f such that f+ f7_) = - 1, because the squares of real numbers are always non-negative, Example. a,=3 . 2" +7. 5" is the solution of recurrence relation a, -7a,_, + 10a,_»5 n> 2 with initial conditions a= 10, a; = 41. Example 1. Find a recurrence relation for @, the number of different ways to distribute either @ $1 bill, a $2 bill, a $5 bill, or a $10 dollar bill on successive days until a total of n dollars has been distributed. Solution : If, on the first day, we distribute a $1 bill, then we are to distribute n ~ 1 dollars on the succeeding days and there are a,_, ways to do that. If, on the oher hand, the first days distribution was a $2 bill, there remains the problem of distributing n - 2 dollars ; this can be done a,» ways and so on. Thus, we see that @,=4,_1 + @)-9 + @—5 + @-10 Example 2. Find a recurrence relation for the number of ways to arrange flags on a flag-pole n-feet tall using 4 types of flags ; red flags 2 feat high, or white, blue, and yellow flags cach, foot high. Solution. Let a, = the number of ways to arrange the flags on the flag-pole n-feet tall. If the first flag is 1 foot high, then there are a, _, ways to arrange the flags on the other n- | feet of the pole. Since there are 3 colors for the first flag, in this case, there are 3a,_, ways to arrange the pole. In case the first flag is red, and hence, 2 feet high, there are a, ways to arrange the flags on the other n~ 2 feet of the pole. Thus, a, 1+ a>. Example 3. Suppose that a school principal decides ta give a prize away each day. Suppose further that the principal has 3 different kinds of prizes worth $1 each and 5 different kinds of prizes worth $4 each. Find a recurrence relation for a,, = the number of different ways to distribute prizes worth n dollars. Solution. If, on the first day, a $1 prize is given, the prize could have been chosen from one of the 3 different kinds of $1 prizes, and then there are 1 — 1 dollars worth of prizes to be given away later. Thus, there are 34, _, ways to do this. If, on the other hand, the prize given on the first day was a $4 prize then there are 5 different ways to choose the prize and a,_ 4 ways to distribute the remaining prizes, Thus, 4, 3a,_,+5a,_4. 6.5 SOLVING RECURRENCE RELATIONS BY SUBSTITUTION AND GENERATING FUNCTIONS We shall consider three methods of solving recurrence relations in this and the next two sections : 1. Substitution (Iteration) 2. Generating functions 3. Characteristic roots and 6.5.1 Method I (Substitution Method) In this method, the recurrence relation for a, is used repeated to solve for a general expression for a, in terms of n. Example 1. Solve the recurrence relation a, = a, Solution. Here a, = a) + f(1). 1 +f (x) for m2 1 by substitution method. Recurrence Relations = 335 & =a) + f(2) = a + f(l) + f(2) & + f(3) = ay + f(1) + f(2) +13) Example 2. Solve the recurrence relation a, _ 1 + n°, where ag = 7 by substitution method. Solution. Initial condition is a =7. We have a=a+P=74+P 7+ P42 7+ P4049 a= a,+2? 2 24924. 92 +1)(2n41 a,=74+ (P+ 242 40+ 0 74 Bert) Ons) 6 which is required solution. Example 3. Soive the following reeurrence relations by substitution. | 7 @a,=a, “TG where ag =1 (ii) a, =a, ., + 3", where ag =7 [JNTU-MCA Feb. 07] Solution. (i) Initial condition is a= 1. 1 We havi =aH+t epee ae Ort? 1.2 a= 1 1. « 1+1-—— =2-—— is the solution. nel n+1 (ii) Initial condition is a = 1. We have, @,=a@+3!=a4+3=143 a,=a,+3°=14+34+3? 336 4 Mathematical Foundation of Computer Science a=, + 3 =14343' 43° 143434394... 43% pal -1 3 is the solution Example 4. Solve the recurrence relation a, =2a,_; + T with a, = 7 for r > 1 by substitution method. Solution. ‘The initial condition is @ =7 We have a= 2a, +1=2 (7) +1 @,=2a,+1=2(2.7+1)+1= 2a, +1=2(2?.7+24+ 1) +1 =P. 7424241 74241 a 14242? $2.4 27% > a,=7 27 '4+2")-1forre1 ar lyartiy 1 tn. 3, given ag = The solution is Example 5. Solve a, Solution. We have, yt. Baya @t1.3!=141.3 ay +2.37=141.342.3 a= 043.8 =14+1.342.3 43.3% G= 141.8 42.843.39 + m3" a,=1+ ¥.r.3", which is the required solution. Example 6. Ifa, is a solution of a, , ; = ka, for n > O.and a; = a and a; = gE a7 , find the value of k Solution. The general solution of a, , ; = ka, is a, = K' dy, nz | (verify) Here Recurrence Relations 337 and Bazh a=" Ba _ 1377 49 9 Fa, 2401 153° 49 9 Pa5 49 ? Example 7. Solve the recurrence relation a, =) +2049 > 7, [JNTU - November, 2006 - Set 4] L Solution. Given that a= 4,4") 2 We have a= 4a +1 y= a+3 =m +143 a= +6 =qMt1t+3+6 Q FLA BHO Ha + n(n+1 nerd is the required solution. 6.5.2 Method of Generating Functions Recurrence relations can also be solved by using generating functions. Some equivalent expressions used are given below. If A (x)= Yax®, then nao © =~ ae = ay 338 4 Mathematical Foundation of Computer Science Where A (3) is called a generating function for a given recurrence relation. Now we are ready to describe how to solve linear recurrence relation with constant coeffi- cients by the use of generating functions. The process is best illustrated by examples. Example 1. Solve the recurrence relation : a, = 7a, -; + 10a, > =0 for n >2 [JNTU - MCA - Feb-07] Solution. Here we use numbers for steps of the procedure. 1 Let A(s) = Saat. nao 2. Next multiply each term in the recurrence relation by «” and sum from 2 to % : 3. Replace each infinite sum by an expression from the equivalent expressions : IA (3) = ay ~ a 2] ~ 7x [A (2) ~ a] + 102 [A(x] =0 4, Then Simplify : A (x) (1-7x+ 102") = ay + a, x- Jay x Ag) = oes —Fa | ay + (a, — 7a) 1-7x+10x" (I= 2x) (15x) 5. Decompose A (s) asa sum of partial fractions : A(sj= + : = 2x” = Gx where ¢ and ¢ are constants, as yet undetermined. 6. Express A (x) as a sum of familiar series : 4 6 Ton mit AW) sponte Larrea Yee. 7. Express a, as the coefficient of x" in A (x) and in the sum of the other series : 4, = 2" + 5". Example 2. Find a general expression for a, using generating fienctions to a, ~ 7a, 1+ 12a, - > =0;n22 Recurrence Relations ® 339 Solution. Let A (2) y= Sar += 4, (8x) + V4)" = Consider the given recurrence relation a, - 7a, ;+ 12a, 9 jn22 AL) Multiply each term in (1) by x" and sum from 2 to =, we get = (A(s) ~ a ~ 4) 91-7 (A (a) ~ a) x4 12 (A (2) 2 =0 =0 => A (a) (1-7x+ 1227) = ay + ay x- Fay x 5 Als) go (a =7a)x _ + (4-744) 4 4% 17x + 12x (1-3x)(1-4x) 1=3x 0 14x ~4ne 0D (3n)" +6, ¥(40" 4, = G 3"+@ 4" Example 3. Solve the recurrence relation a, - 7a, _, + 10a, _, =O for n= 2 with initial conditions a9 = 10 and a; = 41 by using generating functioins.; [JNTU - Nov 06 - Set 3] Solution, From previous example 1 general solution of the recurrence relation @, ~ 74,_, + 10d,» = 0, n= 2 without using initial conditions is a, = 6 2" + & 5" AL) Put n=0 in (1), we get a= 6 2" + 65° > 1W=qt+e6 (2) Put n= 1 in (1), we get a, = 6 (2) +6 (5) > 41 =24 + 5q .(3) By solving (2), (3), we get 7. 6 =3, 6 The unique solution of the recurrence relation is a, = (3) 2" + (7) 5" Example 4. Using generating functions, solve the recurrence relation a, ~ 4a, ;+ 3a,» =0,n22 with initial conditions ay = 2 and a, = 4. Solution. Let A (x)= }' a3" Consider the given recurrence relation 4,-4a,_;+3a, )=0 (1) Multiply each term in (1) by x" and sum from 2 to , we get 340. « Mathematical Foundation of Computer Science => (A (a) = ay ~ a 4) - 4 (A (x) ~ @) e+ 3x (A (x) =0 => A(x) (1 -4x4 3x) ay + a, X—Lay x Put aq = 2, a = 4, we get _D+de-8x 2-4 Ata) 1-4x43x? — (1—x)(1-3x) Using partial fractions, A(gy= "+3" =1 +3", which is required solution. Example 5. Solve the recurrence relation a, + 3a, , - 100,_,=0 ; n 22, given dg =1, a, =4, using generating functions. [JNTU - Nov 06 - Set 1] Therefore, Solution. Let A (x) Consider the given recurrence relation a, + 34,_;- 10a, _5=0 (1) Multiplying each term in (1) by x* and sum from 2 to ~, we get Y aad, i -10 Sa, ox” => (A (a) =a — a 9) +3 (A(x) ~ ay) #102 (A (a) =0 = A(x) (14+3x- 10x) =a) + 3a) x4 a, x Recurrence Relations ® 341 5 AW= go Says tex 1+ 3x - 10x’ Put q = 1, a, =4, we get Le ox 1+7x Te 8x— 10x? (2a) (1+ 5x) Using partial fractions, 2-1)" 5" which is required solution 7 Therefore, Example 6. Solve a, - 64, _; + 12a, . > ~ 84, . ; =0 by generating functions. Solution. Given recurrence relation is a, 64, ,+12a,_5-8a,_;=0 ..(1) Let A()= Yar" Multiply each term in (1) by x" and sum from 3 to o», we get Yas! Saaax"+22 Yeas 8 Ya gst =0 ms 5 as Fat Replace the infinite sums by equivalent expressions, we get [A (a) = ag = a x= a x] — 6x [A (x) - ay — @ a] + 122" [A (2) — a] - 82° A (1) => A(x) [1-6x4 122° - 8x9] = ay + a x - Gay x + @ — Gay, x + ay x? 3 A (x) = 02 4H Sto + a2? ~ Gay x? + 12apx? 342. « Mathematical Foundation of Computer Science _ % + (ay ~ Gidg) + (ay ~ Gq, + 12a) a By using partial fractions, + —S__, where ¢,, ¢, ¢ are constants. 1- 2x (1-2x) im ms x) = 6, (1- 2x)! + & (1- 2a)? + @ (1 - 2x) =4q deo +e Yel (n+ 1,n) (2x)" + Yee (2 +2, n) (2x)" =o no = Yeasts Fo(atiae+ yd order Mon 0 0 « « yinat ae "= 3. Pep (ntl) 2 +e, POH) as ) ge Hence am ee reahnry2 tg CAEN y is the required solution. Example 7. Solve a, - 84, ) + 21a,_)- 18a, _;=Oforn>3 Solution. Given recurrence relation is a,-84,_; + 2la,_y~18a,_5=0 (1) Let A(g= Dax" nas Replace the infinite sums by equivalent expressions, we get IA (a) = ay ~ a ~ @ x1] ~ 8x [A (3) ~ a ~ a a] + 21° [A (a) ~ a] ~ 182" [A (2)] = = A(x) [L-8x+ 217 - 18x35] = ay - Bay x + Ql ay x? + ay x- Ba, x7 + ay x? ay + (= 8ay +a) x + (2lay ~ 8a, + ap) x? = A(a)= 3 a 1= 8x4 210? — 18x" _ y+ (Bay +4) 4 (2lay — Bay) x2 (1 = 2x) (I= 3x) Recurrence Relations ® 343 We see that there are constants ¢, @, ¢ such that ¢ AQ)=—L + — 1-2 "13x (1-3 g (1- 2a)! +g (1 - 3x0! + 6 (1-32)? 4 Sex +0 Sait Ye(ne inate! am m0 a=0 azo azo > ax" = Yi fe 2 He3" + (n+ oa") xt a0 Hence 4, = 6 2" + & 3" + (n+ 1) c 3" is the required solution. Example 8. Solve the recurrence relation a, ~ 9a, ; + 26a,» ~ 24a, ; =0 for n 3 with initial conditions ay = 0, a; = 1 and a = 10. Solution. Given recurrence relation is =0 a, ~ 94, _, + 26a,» ~ 24a, Let A(i= Yaga’. aso Multiply each term in (1) by x" and sum from 3 to =, we get ne 9 Sgt? por 24 Day" =0 a=a n= a= Replace the infinite sums by equivalent expressions, we get [A (x) = ay = ay = ay 7] = 9A (x) = ay = a x] + 2627 (A (x) = ag) = 242° A (x) =0. Put a =0, a, =1, a =10, [A (x) = x= 1027] - 9x [A (x) - x] +267 [A (x)] - 2427 A (2) =0 => A (a) [1-9x+ 262-2407] = 04 102-92 = 24% west yee? > AO) Toe bia? das?” 2 I= Bd) Using partial fractions, we get

You might also like