You are on page 1of 18
4 Recurrence Relation and _ Generating Function tite Introduction he an important use of recurrence relation is the analysis of the complexity of algorithms. A. eure relation that defines a sequence can be directly converted to an algorithm to compute ihe sequence. Generating functions are important tools in discrete mathematics and their use is by no means zsfned to solve linear recurrence relation. The function can be used to solve many types of counting problems. 412. Recurrence Relation Asequence can be defined by giving a general formula for its nth term or by writing few of isms. An alternative approach is to write the sequence by finding a relationship among its terms. sucha relationship is called a recurrence relation (also called difference equation). For example, let us consider a sequence $= {3!, 32, 3°, wary 3% } This sequence can be defined by giving an explicit formula for its nth term i.e., S = {S,} sere §, = 3", Since the value of S, is three times the value of S,,, for all n, once the value of §,,,is known, the value of S, can be computed. The same sequence S can be described by the elton S, = 38,722 with $,=3. The information S, = 3 is called initial condition. Definition : A recurrence relation for the sequence {S,} is an equation that relates S,, in of one or more of the previous terms of the sequence, Spy Sy, ....sS,.1 for all integer "ny where ng is a non negative integer. The specification of the values of S,y 1 < 1g is called the "ital conditions of a recurrence relation. For example, (0 The recurrence relation of the sequence S = (5,811, 14, 17 = 8,143,022 "til condition $, = 5. . ©) The recurrence relation of the Fibonnaci Sequence of numbers. S = {1 1,2,3,5,8, Bosse} Ay, Sy = Sy-1 + Spar 23 with initial conditions 8, = S, = 1 Mega the recurrence relation in example (i) requires only one initial condition S, to start |e ingy U™EMC€ relation in example (if) expresses S, in terms of two previous values and requires msitions S, and S, before all values of the recurrence are uniquely determined. a ne 1. Find the first four terms of each of the following recurrence relation + 2a, +k, for all integers k 2 2, a, = 1 41 a2 A TEXTBOOK OF DISCRETE rm ‘Ty () a Solution. (a) 1+ 2=4 = 2a,+3=2443=11 = 2a, +4=2.114+4=26 © ! = a,t+3aj=2+3.1=5 = a) +3a,=54+3.2=11 © z 1.@P=11=1 = 2.(a4P=21=2 a, = 3.(a,?=3.4=12 Example 2. Show that the sequence 82,34, 5, cress D+, Jorn 0 satisfies the recurrence relation a, =2a,_,—-a » 22. Solution. Let a, (nth term of the sequence) = 2 + n a, = 2+k 4) = 2+(K-1)=14+k 4,_,=2+(k-2) =k Now 2-1-2 = 21+ W-k=2+k= a, a % = 2a, )-ay_» A recurrence relation for a particular seque nce can be written more than one way. For exe @ = 34.1 22 with initial condition a, = 3 can also be written as by many different sequences, the actual txts! the Sequence are determined by initial conditions. For example 3a, With initial condition a, = 1 30,1 With initial condition 5, = 2. and 6) =3b,=3.2=6 5, = 36, =3.6=18 0, = 3b, 3,9, 27, and 6, 18, 54, A TEXTBOOK OF DISCRI a4 STE Mari Let C,, denotes the number 3 se there are 7 disks on pes nm ber of m, or. oP with the given restrictions. If there is only one disk, we se needa n> 1, we can transfer 1 ~ 1 disks to peg A using Cy PY mye i the bottom of peg ! stays fixed. There we use one ; are tig 0 , We ean now move agin 1 disks on peg Ayo Se Using Solu move them from peg 1 to to the second peg. If we have the moves, the largest disk at t the largest disk to the second pet C,_; moves. Therefore, C, = 2G, +1 >t with initial condition C, = 1. cn ; Example $. Find a recurrence relation and give initial conditions for the number of, ie of length n that do not contain the pattern 11. bin Solution. Let, C, denote the number of bit strings of length that do not contain the 11, and can be counted as Paten (a) that begin with 0, (b) that begin with 10. Since, the sets of strings of types (a) and (6) are disjoint, by the sum rule, C, will be eu to the sum of the numbers of strings of type (a) and (5). Suppose that an n bit string begins y itt 0 and does not contain the pattern 11. Since (1-1) bit string not containing 11 can follow then 0, there are C,, such bit string of type (a). In an m bit string begin with 10 and does not cong pattern 11, the (7 ~ 2) bit string following the initial 10 can not contain the pattern 11 : there, there are C,, » bit strings of type (6). Thus, Cpa +C,_9 223. 0 = 2, since both bit strings of length 1 and 0 do not contain te since the valid bit string of length two is 00, 01 and 10. 11.4 Solution of Recurrence Relation Suppose we have a se isfies a certain ret and initial conditions P quence that sat tai rence relation and initi iti explicit formula for a, vibe ae rai , i, Which satisfy the recurrence relation with initial conditions is call! a solution to the recurrence relation. For ex; = ”, n 2 0 is a solution of recurre tion. i i example, a, =A. 2", The initial conditions are C, pattem 11 and C, = Linear Recurrence Relation with Constant Coefficients. A linear recurrence relation wi ith constant coefficients i coefficients is ee of the form previous & terms of the sequence ie., the ord Linear refer to the fact that every subs; as a, . a,, do not appear. The words const, Aln) is identically zero the relation is know For example, (a) The recurrence relation a, = 2a, , a xt cripted term occurs to the first power. The 5 © ‘ant coefficients mean each of the c/s is CO", 7 as homogeneous, otherwise, it is non homoge is a linear homogeneous relation with constant coefficients of order 1 and degree 1. i ler 1 and degree |. (b) The recurrence relation a, =2.4,., a,» is not a linear homogeneous relation with constant coefficients as term such a5 dir? ® permitted. Each term is to be of the form ca, ot 3 ‘E RELATION AND GEN! peQURRENCE GENERATING FUNCTION 415 (The recurrence relation a, ~ a, , =3 4 linear homogencous relation with constant coeftic jg not is not zero because of the constant term 3 pnd side (a) The recurre jsa linear homogeneous relation with constant coefficients Note that the recurrence relation a, = 2a, yeition is generally harder to solve, "Methods of Solving Linear Recurrence Relation ients because the expression of the right relation a, = a,_,+ in Any yy of order 2 and degree 1. nn + n does not have a constant order. This type of The three methods of solving linear recurrence relations with constant co-efficient are discussed here. . Iteration 1 2, Characteristic roots and 3. Generating functions. Iteration Method: In this method the recurrence relation for a, is used repeatedly to look for a pattern to find a general expression for a, in terms of n. The mechanics of this method are described in terms of examples. Example 6. Solve the recurrence relation a, = 4,,+2, n>2 subject to initial condition a, = 3 Solution. We backtrack the value of a, by substituting the expression of a, , a,» and so on, until a pattern is clear, Given a, = 4,442 (1) Replacing n by n — 1 in (1), we obtain Gp, = Op +2 From (1) Gy = Gy, +2=(Q,2+2)+2=4,. +22 B02) Replacing n by n —2 in (1), we obtain ng +2 * So, from (2) a,5+2)+22=4,5+32 In general app tk.2 For k=n-1 a, -@-t M2 =a + (n-1).2=34+(-1),2 _ “hich is an explicit formula, a constant then one can solve More generally, if c is = cdg tf(0) for n> 1 in a similar way a, = Given ay = es IO) ° So, a1 tea + A= + From (3 wy = (Cty +fe0~ I) +H) ® Tce TO (4) . . in Replaing n by n- 2 in oa Ae ee +fn-2) ind 2 leaps) +21 * AM 1) + fea) From (4) One 2 fn 2+ Am~1) + fa) = Oa,-3+ > | A TEXTBOOK OF DISCRETE teary 416 ; : Mi ba, tht fin (k= 1) + ay to fl) +e? (2) +. In general, fn * fin ~1) +f For k=7 % + ofl D4 Af(K) In Tower of Hanoi problem, we deduced the recurrence relation as a, = 2a,,+1 n> 1 with the initial condition a, Using general formula, we get a, = 2"ag+Y2"* 1, taking ay = 0 i = 424 The Method of Characteristic Roots In this method the solution is obtained as the sum of two parts, the homogeneous solute, ‘which satisfy the recurrence relation when the right hand of the relation is set t0 0 Le. f(n) = the particular solation, which satisfies the relation with f(n) on the right hand side, (@) Homogeneous Recurrence Relation ‘The basic approach for solving homogeneous relation [/(n) = 0] is to look for solutions of te form a, =r". Now a, = ris a solutions of the recurrence relation 4, = C1a,.4 + C20, 9+ P= rl + ope Dividing both sides by r"-* H = artsy Pe ey = op which is called the characteristic or au: this equation are called the characteristic of the Ath degree has k characteristic root Distinct roots: If the characteristics form of the solutions for homogeneous e + 20 Q2"-1)(2 - 1) and + Chg if and only tent or equation has distinct roots r, ry ry then the gene! uation is, Gn = bury" + bars" + byes + + bere” where By, by by, are constants which may be chosen to satisfy any initial conditions, Example 7. Solve a, = 4,., +24, » n> 2 with the initial Solution. The given recurrence relation I conditions ay = 0, a, a, In = nyt ayy 0 tl) is a second order linear homogeneous recurrence relation with constant coellic Let a, = r" is a solution of (1). The characteristic equation is P-r-2=0 (-2r+1) =0 or, r = 2,~1 distinct real roots. So the general solution is 4, = b, Qy"+ by (Ayr ie. 4,-4,)~2 4,9 ients al) pence RELATION AND GENERATING FUNCTION =0 implies 26,-b, = 1 ae f these two equati ‘ solution of ‘0 equations are b, = 1/3 fe 1 and b, 1/3. Hence the explicit solution is yy e a, = (1/3)2"- (113X-17 ample 8. Solve the recurrence relation of the Fibonz fase phe inital condition fy = 0, f= 1. ibonaci sequence of numbers fy = fy_1 * = ris a soluti i a solution of the given equation, the characteristic equation 1s ediy2 ter, = (+V5)/2, 7, = O-N5)2 ae two distinct rots So the genera 1+ - Sh fF )-o(54] gain fy = 0 implies b, + By =O fh implies 6 (1+ /5)/2+b,(1-V5)/2=1 Solving these two equations we get b= gai | thus the mh Fibonacei number is given explicitly by eset of a homogeneous recurrence relation is Maltiple Roots: If the characteristic equation 33, Then the general solution is r-2)=0, then r = 2 is a required root of multiplicity a, = (b+nbyt rw b,)2" equation of mth order of a given recurrence eter isa Tooley the characteristic n ion with multiplicity m., then the general form ofthe solution IS a, = (by +2, bat +b, »,, are constants which may be chosen 10 satisfy any initial conditions. ae nee distinct and multiple roots is also possible £., some roots {fecharaeritc equation are distint and some spot are equal. the characteristic equation ofa tes ta eee ee ‘of sth order is (r - 2) (7-40 (7— 3) = 0, then r= 2,433.3. general solution is oe tae eae in Ma Pi ple 9. Solve the recurrence relation gy 3) with initial eonuiions ao = a, = 4,1 =0 eat) Solutio A vs mn. The given relation is a, - 4d, 4 44n-2 a, = Pisa solution of (1): acteristic equation is 2 - 4r + 4 = 0 which gives r= 2 ‘Then the har ‘Thus the $0, ays 5, H solution isa, = (b, + mb,)2" 18nd a, = 2(b, + by) >>, ON faa ATEXTBOOK OF DISCRETE MATHE May ee eg Now ay = 1 gives by and ao 1 gives 2 (b, + by) = 1 => b= - 1/2 So, the required solution is a, = (l-%n)" Example 10. Solve the recurrence relation a, -8a,_; + 2ia,_~ 18a, = 0 Solution. Let a, = r" be a solution of the given equation, The characteristic equation is 3 — 8? + 21r-18 = 0 ie. P27 -6r? + 12r + Or 18 or P(r -2)- 6 (r- 2) +9 (r-2) or (r-2) (2 -6r +9) or (r-2) 7-39 So the general solution is a, = (b, + by m) 3" + 6,2". Note : We restrict our examples to linear recurrence relation wi have only real roots. (6) Non Homogeneous Recurrence Relation A second order non homogeneous linear recurrence relati the form 0 which gives r = 2, 3,3 hose characteristic equations ion with constant coefficients is of y-2 + 54, + 6a, = f(x) Its solution a,, consists of two parts 1. Homogeneous solution a,” of the given recurrence relation by keeping f(n) = 0. 2. Particular solution a, of the given recurrence relation with f() on the right hand side. The required general solution is a, = a, +a, Particular Solution There is no general method for finding the particular solution of a recurrence relation for ever function f(n). We shall discuss method of undetermined co-efficients for finding particular solution. This method is useful when the function f(n) consists of special forms. Depending on certain foras off (n), we consider a trial solution containing a number of unknown constant coefficients which are to be determined by substitution in the recurrence relation. The trial solutions to be used it each case are shown in the following table where A, Ag Ay represent the unknown conststt coefficients to be determined. Form of f(n) Trial Function 2” (if b is not a root of characteristic equation) Abr Polynomial P (n) of degree m Ag t Aunt Agr + c* Pn) (ifc is not a root of characteristic equation) | o" (A, + Ayn + Ayr + 7 (if b is a root of characteristic equation of Agno" multiplicity s) © P(n) (ifc is a root of characteristic equation of [nt (A, + Ayn + Agr + multiplicity 1) T- r sin bn_or cos bn ‘Ag sin bn + A, cos bn br sin bn orb" cos bn BP (Ag sin bn + A, cos br) eC b f | | | | gg CURRENCE RELATION AND GENERATING FUNCTION _ 419 Tote: (2 HLF () is constant i.e, a polynomial of degree zero, the trial solution is taken as A. (i) 1/() is a linear combination of the above forms, the trial solution is taken as the sum of corresponding trial funetions with different unknown constant coefficients to be determined. solved Exumple (uy When fy Example U + 6a, = 2 with initial condition ay = 1 and a, =~ 1. Solution, The associated homogeneous recurrence relation is =Sa,, 4+ 6a, = 0 (1) lution of (1). equation is? = Sr++ 6= 05 r=3,2, So, the solution of (1) is a, = C,3" + C,2", To find the particular solution of the given equation, let a, = A, Substituting in the given equation, A-SA+6A=2=A=1 Particular solution a? = 1 Hence the solution is a, = a, + a, = C3" + C,2"+1 v2) To find C, and C,, put 2 = Q and n= 1 in (2) a = C+, +1 or, 1=C,+G+1 or, C+C,=0 - GB) Again, a, = 3C,+2C, +1 or, 1 = 3C,+2C,+1 or, 3C,+2C, = -2 + (4) Solving (3) and (4), we get. C, = —2and C, = 2. Putting the values of C, and C, in (2), the required solution is a, = —23"+22"+1. 2) When fa) X’is a polynominal Example 12. Solve the following Ynv2—Inv1~ Dn = 1 - Solution, Substituting y, =r" in the associated homogeneous recurrence relation, the Characteristic equation is 2 -r-2 = 0 o (r+) r-2) = 0 This gives pale? aa The solution of the associated homogeneous ecurenes relation is yt = CCD" Let the particula jon of the given equation be particular solution of the gi Pyare ; pire Ag + Ant Ayt (Since f(n) is a polynomial of degree 2) ye have Substituting in the given equation, a luting in the given eq! (rt DEMO D2 AS + Ab Aya) AoA, (12) 4A, (1+ 2 [Ag tA we 8D Ag + Ay FAQ) + 2A, + 2AM 2A TT aye On comparing the coellicients of like powers °° =2Ay +A, +342 = 0 (1) ATEXTBOOK OF DISCRETE 7 ~ t MATH “() From (3) ) We have thom (2) Fra) - Therefore, particular solution of given recurrence relation is ye) = 1-2) n= (aye Hence the general solution of the given recurrence relation is = yt yy = Cy) ED+C, 2" 1 = nd = (12) @ Am) = cr, were a is a root of characteristic equation Example 18. Sade a, . )- 4a.) + 4a, = 2" P* bea solution of the associated homogeneous recurrence relation day tda, = 0 The characteristic equation is P-4r+4=0 = (-2F =0 bas a single root 2 of multipli gP=(C, + Ce. ‘To Sad the particular solution of the given relation, we note b = 2 is a root of characteristic goestce with multiplicity s = 2, So, the particular solution has the form a, = Ag? . 2". Substituting i the given relation, we get Ay (n+ 2F 2-744, (n+ TP 214g Ag? 27 = 2" = AA 2F-SA (tI Hd Aya two. So the solution of associated homogeneous relation is > Ay = V8: Particular solution a,(?) = 1 8 Hence the general solution is a, = 4, +9,0) = (Cy + Cym2" + (1/8)n?, 2" Example 14(0), What panies relation a, os - on form does a particular solution of the linear homogeneous recurre™ 1~ 94, =f (n) have when f (n) = 3%, f (n) =n 3" int + 1)? Soluti a : " =n. 3" and f (n) = ( tution. Let, c, = r* be a solution of the associated homogeneous recurrence relation 2" _On-2~60,,,+9a, = 0 The characteristic equation Ee ontoiats “ (r-3F = 0 Moe tTOnee aay two. Thus iff (n) = 3°, the particular solution has the ft : nade cular solution hi 2 A Eat Ih the particular solution has the form nl (A+ Aim + Aroyan C0 * Aut) 3 IEF 0) = 7 * Example 14(5). Solve Bah () a,-7a,_, + 12a, (ii) a, 4a,_, + 4a, Solution, (i) Let a, = r* be a solution of the associated homogeneous recurrence relation a,-1a,_, + 12a, = 0 P-Tr+12 (r-4)(r-3) = 0 r=4r = 3, he solution of associated homogencous relation is . a = Cay + Gy, ae cis a of the given relation, we note 4 is a root of the characteristic 0 the particular solution is of the form a, = M(Ag + Ayn) (4)". substituting in the given relation, n(Ay + Ayn) (4)" = 742 = 1) (Ag + Ay 1). 4) + 12{(n—2) + Ag + Ay(n- 2).(4Y7} = nl" 7 ot (WAg + Ay?) — fa {n(Ap — 2Ay) + (Ay ~ Ag) + PA,} 2 So, t cat 12 + 7g mo — 4A) + 4A, -2A)) + PA =n Ay, 5A or Sa tn Qa opea tan A Ao , SAL _ _ > ze or Ay=2 and —P+—h=0 = Ag=-l0 Hence a, = n (10 + 2n). (4° So, the general solution is a, = 4,%+a,0) = 4(4y' + C3)" +0 2" 10). 4)". (if) Let a, = * be a solution of the associated homogeneous recurrence relation a,-4a,_,+4a,. = 0 The characteristic equation is 7? — 4r +4=0 => r= 2,2. So, a, = (C, + Cyn) 2". To find the particular solution of the given relation, 5d 4" is an exponential function and 4 is not a root of the characteris | Solution is of the form. So, a, = (Ag+ Ayn) + Ag (4)" Substituting in the given recurrence relation, we get My + Ayn) +A,(4)%) —4{A, + A(n— 1) + AA 2 + AfAg + Ayn =2) + AAT = + OP we note n is a polynomial of degree one tic equation so the particular OF By aay) + (A)AD ont (4 => MLA a= 4Ay=4 Ons 4 ane he general Solution is So, Atne grt) 4, = a) + ae) = (C+ Cn +(4tmt atl, - 7 a A TEXTBOOK OF DISCRETE yp THEM, 11.5. Solution of Non-linear Recurrence Relations Sometimes non-linear recurrence relations can be solved by converting the '™ into ling recurrence by suitable substitution. Example 18, Solve the recurrence relations a) 2a), = 4 forn2 1 and ay = 3. Satution. Let b= a Then the given relation rees 10 y= 2b, = 4 and oy 4 characteristic equation is r— 2 = 0 => r= 2. Hence b= C.2", The general form of a particular solution corresponding to the constant the equations A in place of b,, we get A-2A=4 = A= 4) = -4 418A. Substning Hence the general solution is 5, = 5 +b, = C.27-4 bg = C.22-4 => 9=C-4 ie CHB Hence 5, = 13.2" 4 @, = 13.2" —4 which is the required solution. Example 16. Solve the recurrence relation 9, = Tan); + 5 where n = Sanda, =1 4, = at. Then the given relation reduces to = Th t5 te by ‘The linear relation has the characteristic equation r — The general form of a the equation A in place of 8, 7h) =5 and by=a,=1 7=0=>r=7. Hence =C7 ing to the constant 5 is A. Substituting Particular solution correspondi he We get A-TA Hence the general solution is a= Hence 423 : generating Function it generating, function for the sequence a,, a, The .tapt+ Saxt oO k=O - ! gigeat at tar + gor example, the generating functions for the sequences {a,} where a, = 2, a= 3* ho Oe “ yprENCE RELATION AND GENERATING FUNCTION A, «. of real numbers is infinite series. _ Sot 53k and © anda, = (K+ 1) are 2? z x and erst respectively. | itis often possible to find a closed form expression for G (x) which can be manipulated sjebsilly 1 provide useful combinatorial information. | sone Special Generating Functions 1. The generating function of the sequence 1, 1,1 GQ) = l+xtx7+.. which can be written in closed form as G(@ = (-ayt= is 2, The generating function of the sequence 1, 2, 3,4, . G(x) = 1+ 2et3t + 4e + ye +1)xt i = (-9?= oF jn closed form |x| <1 is 3. The generating function of the sequence 0, 1, 2,3, + GQ) = OF 1xt 28430 + iso x(l+20430+. x(I-ay?= esd in closed form. #0, 4, ‘The generating function of the sequence 1, 4 G@ = ltartaetaet = -ay!= | in closed form |ax| <1 l-av ‘We can derive a closed fc i in 4 form expression for G (x) by i \tric series. We can also apply indirect method as follows. Example 17. Find the generating function for the sequence !, @ a, involving the formula for the sum ofa where a is a fixed constant. Sol + lution. Let S@) = tart art + ate + So, G@-1. ax + ate? + ahx + Ge a = ltaxtayt+ i ATEXTBOOK OF DISCRETE M ao - ETE MATHEy, “THEM AT og Gix)-1 | or = G&>Gw= ax The required generating function is The summary of various types of sequence and the correspondiny IB Bencrating fy given in the following table. 8 Functions x, SI. No, General term of Sequence a, Generating Function G ( 1 1 1 tre | 2 ct 1 4 k 5. k(k+1) 6. +1) (+2) 7. a i 7 cay ot I+ ar 9. Ab kL e Addition and Multiplication of two Generating Functions Arithmetic operations allow us to e " Teate new i ‘ 7 two generating functions are given : Benerating functions from old ones. Suppose tt = Fast, im FG) +6 G)= (ay tb) + (a, +b) + (q+) 24, Tia FQ) = ay + ax + ap? + ay + G0) = by + bx + bx? + by + = Liq +h)x! a) font Then F(x) + G(x) isthe generating function of a + by Multiplication is modelled on the familiar rules for multiplying two polynomials ae ad y F RRENCE RELATION AND GENERATING FUNCTION (0 425 F(t) G@) = (ay + yx + a? aye + Yi (By + bye + by? + dyed + = dgbo + (dghy + abg) x + (agby + aby + yb) 2 ‘ * (abs + aby + ash, + ayby) x9 +. + (Sen. } att ia i by; |x*. (E« i}? +2) Formula (2) is the definition of the product of two generating functions, and it has be _qatomary 10 distinguish this special kind of multiplication by calling it convolution. Then FCs), Gis the generating function a, « b, (convolution of a, and by) ‘ Mi k "gitting Properties of Generating Function — 1.1fG @) = La,x" generates the sequence (aq, 44, 4 .), then x G (x) generates the =) -)5 7 G (x) generates (0, 0, a, a4, a5, 0, ayy a4, A, “sequence (0, py dy, Ge) generates (0, 0, , and, in general x ..) where there are k zeros before ay. For instance, we know that 1/(1 -x)= "x" generates the sequence (1, 1, 1, ..)s that is the = sequence {a,} where a, = 1 for each n > 0. Thus, = Dx" =P x" generates (0, 1, 1, 1, . = ml 2 x" generates (0, 0, 1, 1, ly m0. mm and —_ x .), then G (x) - ay Dy 2 1G ()= ¥) a,x" generates (ap, a, ay, = (10, Op en .) and in general G(x) - ay G@)-ay—a,x= Ya,x" generates (0, 0, a3, a5, mt where there are k zeros before a,. “4% on — ayy 1 generates (0, 0, any 0, pp Oya EE Dividing by powers of x shifts the sequence to the left. For instance, (G (x) ~ ay)’x Ji (G (8) = ay = ayxyx? Son Baw Da.” generates the sequence (ay, ay, ay, zm. Dora = ; and in general, for k > 1, (G (x) ~ ay ~ a,x = Lage” generates (ay, Ay, 44s m0 ‘hh “ay lak generates (ays Oy 41» Gee2e “ample 18, Find a closed form for the generating function for each of the following sequence. 00111 C(8, 8), 0,0 426 A TEXTBOOK OF DISCRETE MATHE ( “ey Solution. (a) We know oe ects et i-x So, the generating function of 1, 1, 1, . xt > yn? Now —- ye I-x a Hence = is the generating function of 0, 0, 1, 1, 1, =x (Here -Peltrtx +t... I-x So, the generating function of 1, 1, 0, 1, 1, I-x (©) We know re = teyt= 1-2 txt x6 +38 = 140.44 CIP 40.9 41.44 0254 (Coe 1 So, the generating function of 1, 0,—1, 0, 1, 0,—1 is +x? @Weknow (1+) = C(8,0)2°+C(8, I)x+ +C(8,8)x8+0404.. « = Yc @mr. mo So, the generating function of C (8, 0), C (8, 1), C(8, 8), 0,0 is (1 +x)%. 3 : (e) We have Tras 3(1+2y'=3 1-xt+2-34,, = 34+(3)x+324(3) 94 = Yee, m= ) Hence, the required generating function is 3 +x" Example 19. (a) Find the generating function of a Sequence {a,} if a, = 2+ 3k Solution. The generating function of a sequence whose general term is 2 is roe oe x The generating function of a sequence whose general term is 3k is _ 3x Gw&)= a Hence the required generating function is F (x) + G(x) = (6) Determine the gene 2 if ris even -2" fF is odd (ia, = (e+ 1) 3" (ia, 8 + C+ 8 43¢, r(r+1) @ IZ a= s(r>0) Solution. () The required generating function i Ge)= Dax =F cayrey r=0 r=0 2°29 — 2x + 22 32 _ 93,3 1 2e + 2x2 ~ 298 4 = (142xy7 given by uo (if) The required generating function is given by j Gay= Dax’ = Dery ro 0 = Daw adoy aS = (0+ 1 Gx)! +262 + 3(3x)} +, = Gx) {1 + 23x) + 3x2 +... = 3x1 -3xy2 41 - 3xy! oe (3x? (1-35) "03? +14 By! + Gy? + Gy + + {1+ Gx) + Gx? + Gx, (ti) The required generating function is given by Gq) = Sax = dfs +CD'S 484 2} m” = Seve Seysv+ Severo en! a 0 = (1+ 5x4 (5x2 + (593 + + (1+ 3x + Bx)? + Bx) tocar + {148+ (By? + Bx 4) + PEC, + 3Cr? 303 +0404. 1~Sxy1 + + 3xy' + (1- 8p + (1+ xp 1~Sxy1 + (1 + 3xy' + (1- 8x) + (14+ xP 1 1 1 3 —— +140 Sr Thay Tog = 4-27x- 0 x? +9429 +367x4 +3615 +1202 ~Sx)(143x)(1-Bx) (142) iv) The required generating function is given by @ cr Go= DF (r>0 srt) 2 432+ 68 + 10x44 (1+ 3x + Gx + 1003 + x =x(1 =x)? >) Example 20. Find the sequences corresponding to the ordinary Benerating function (a) 3 +x), and (b) 3x3 + & Solution. (a) (3 +x)? = 27 + 27x + 9x2 + 39 the sequence is 27, 27,9, 1,0,0.0,, os 22 2) 3,2 4 2! : OIP+erm 14204 Ste 345 a 4! Ss! The sequence is (1, 2, 2721, 3314 3, 2441, lations using Generating Functions Y ion to a recurrence relation with intial conditions by finding an expis Senerating function. This is illustrated by the follow i examples Example 21. Use generating functions to solve the Tecurrence relation. @ a,=3a,_,+2 Gi) a,-9a,_,+20,.,=0 a itl) @,4.-2a,,,+a,=27 gx nv2—2a,., +4, 0 3,a,=-10 Solution. (/) Let G (x)= a,x" where G Gis the generating function for the sequence {2 ms Multiplying each term in the given recurrence relation by x" and summing from 1 to=, west ] Es (Since xG.@) = Sax" = Fa, 2%) 70 m= G@-a = a6 042 [tL G()-3x G(x) 0 + iy 1 { lex ii! cs 6) = Tay" (by partial fraction) dew" = aera Sa n=O Henge a, = 2 . 3"— 1 which is the required solution, = ce {ay} (ii) Let G (x) = a,x" where G (x) is the generating function for the sequence ( m0 geguRRENCE RELATION AND GENERATING FUNCTION 429 tiplying cach term in the given recurrence relation by x" and summing from 2 to 0, we get Dax" -9D 4,18" +209) a,_9x” =0 me m2 nd [G (x) - a9 — a,x] - 9x [G () — ag] + 2037 G (x) = 0 Mull or ar G (x) [1 - 9x + 2027] = ay + ax —9ayx a +ayx-9e, Ga = wtat9e: or @) = "roe 2087 Seda Be arity, Cela a (-5x) (=4x) _ 2.5 a G@ = Tose 1-4x (by partial fraction) Dax" = 2s"x"-Sy "x" = Hence a, = 2.5" 5.4" which is the required solution. (ii Let G (x) = 4,” where G (x) is the generating function for the sequence {a,). = Multiplying each term in the given recurrence relation by x" and summing from 0 to 2, we get Sagar” 20 duu” + Sage” = D2" 0 n=O n= m= G(x)-a-ax_,(G)-% 1 Sa 2(S=m jo a or G(x)-2- -2(S2-2)ee a or (2 - 2x +1) GQ) = fe or GQ) = 2 By partial fraction —_, (=2x) (=x? 1 7 3x 1 (=x? =x? 1-2e G@) “ Lax" = Lert yx" 43D me" + 2"x" Hence 4, = (M+ 1)+3nt2"= 1+ An $2", 11.8 Counting Problems and Generating Functions ‘As mentioned earlier, the method of generating function can b . ji agen ‘ ¢ applied to many areas of = fatematics besides the solution of reeurrence relation. One such area of ‘application is t0 ‘Problem of combination suc! e number of ways to ae ! ao Fiat beri arcy of oat YS t0 Select or distribute the objects of different Example 22. Using generating function show that combinatic - . 7 th repetition is C (n+ P= bs 2) combination of n objects taking r at a time fr

You might also like