To find the generating function for a sequence defined by a recurrence relation, multiply both sides of the recurrence by appropriate powers of x to align terms, then subtract the modified generating function from the original to eliminate all terms beyond the initial conditions, resulting in a rational function that encodes the entire sequence.
Finding Generating Functions from Recurrence Relations | Discrete Math Tutorial
Added:hello and welcome to another video um this time we're going to find the generating function for a sequence given recursively um in the first example I'm going to have the sequence given recursively by a n = 2 Aus 1 + 4 Aus 2 with initial terms a 0al 1 and A3 equal uh A1 equals 3 it might be helpful to write out the first few terms of the sequence uh they are 1 3 10 32 and so on I'm getting those just from the recurrence relation 10 was 2 * 3 + 4 * 1 um and so on that might help it also might help just as our side work here to rewrite our recurrence relation as a n minus 2 A nus1 minus 4 a n minus 2 equals zero this might be helpful to remember all right well let's go ahead and try to find the generating function much like we did with differencing we don't know what the generating function is so we're just going to call it a a is going to be equal to the generating Series so that would be 1 + 3x + 10 x^2 + 32 x cub and so on we could go as far as we need in fact we only really need to go out to the x s term to see what's going on now I want to take away two of the previous term from each of these and that's because over here in my uh recurrency relation when I wrote it like this I took away two of the previous terms and then I'll also take away four of the terms before that and I should always get zero so to take away two of the previous terms I need to get the previous term so the one needs to become a 1 x so it'll be grouped with the three but I also need to do two of them that's why I'm going to multiply a by 2x on both sides uh to get the behavior I want the one becomes a 2X the 3x becomes a 6 x^2 the 10 x^2 becomes uh 20 x cubed and we could keep doing this as far as we needed now I also want to take away four of the term before that so I'll multiply the sequence by four and an x squared that'll move everything over two spots giving me the a n minus 2 terms the one becomes uh 4 x^2 the 3x becomes a 12 x cubed and I would keep going as far as I needed but in this case that's all I need now what I want to do is I want to take my original generating series and I'm going to subtract off 2x a and I'm going to subtract off 4x^2 a and I'll see what that leaves me with on the left hand side I'll have 1 - 2x - 4 x^2 that entire thing time a and let's see what that's equal to well 1 - 0 - 0 that's 1 3x - 2x gives me X and let's see what happens after that I have 10 x^2 - 6 x^2 down to 4x^2 - 4x^2 gives me 0 x^2 okay what about the next one 32 x Cub - 20 x Cub - 12 x cubed is again 0x cubed well of course it is that's the way I set it up using this recurrence relation over here if I take any term subtract two of the previous ones and four of the ones before that I should get zero so all of these will be plus Z out forever okay well this is good I've simplified the right hand side of my generating series and now I can solve for a I get a is equal to 1 + x ID 1 - 2x - 4 x^2 and there I have it that's my generating function let's look at another example here the sequence is given recursively by the recurrence relation a an equals a n-1 plus 2 Aus 2 plus 3 plus this constant that makes this slightly different than any other examples we've seen before I also give you the initial terms here again probably a good idea to write down the first few terms of the sequence two two those are given to find the next one we would do um the third one or a two would be 2 plus 2 * the first term that's two so that would be uh 2 + 4 + 3 that should give you nine after that we'll have uh 16 and then 37 and you can keep going on in this way all right um it also might be a good idea to rewrite the recurrence relation like we did last time um let's get all the a something terms on one side that'll give me a n minus a n minus one minus not a but 2 a n minus 2 I'm going to say that's equal to three instead of equal to zero so that's where this is different all right well let's go ahead and uh try to solve using our our recurrence relation technique we'll say a is equal 2 and write down the generating Series so that'll be 2 plus 2X + 9 x^2 + 16 x cubed that should be enough okay I'm going to subtract off the previous term for that I just need to do x * a x * a will be equal to 2 becomes 2x the 2x becomes a 2x^2 the 9 x^2 becomes a 9 x cubed and so on let's see I need to take away two of the terms before that so I'm going to do 2x^ 2ar a the 2 will become a 4 x^2 the 2x will become a 4X cubed the next term would become an 18 x to 4th I'm not even going to write that down though all right and now let's combine these um I'm taking the first one minus the one before that minus two of them so I'm just going to subtract each of these line by line on this side I will have 1 - x - - 2x^2 that whole thing time a that'll be equal to let's see what we get on this side 2 - 0 - 0 is 2 2x - 2x it's no X that sounds good um how about 9 x^2 - 2x^2 - 4 that gives me actually a 3 X2 16 x Cub - 9 x Cub that drops me down to 7 x Cub minus another 4 x Cub that's going to give me a 3 x cubed what's going on here well it's not actually surprising at all whenever we do a subtraction of these three terms we should get three left over because over here we have this recurrence relation when we take a term subtract the previous term subtract two of the term before that we always get three okay well um in that case we're going to have a bunch of Threes here what are we going to do with that this whole thing we can simplify using its generating function this right here has generating function constant threes shift it over twice so three x^ 2 / 1 - x that gives me that generating function I I still have my plus 2 all right so now it's time to go ahead and write down the final generating function for a this is this whole thing there that's what that's equal to just make a little more room here okay so what do I get I get a is equal to 2 / 1 - x - 2x^2 plus 3x^2 ided well I had 1 - x before but then I also have my 1 minus x minus 2x^2 so that monstrosity of a generating function is my final answer and there I have it all right well I hope this has helped and thanks for watching
Up Next

Closed-Form Fibonacci Numbers via Generating Functions & Linear Algebra
@drawocoward
2.1K views•2026-01-29

Gain Recalibration in Hippocampal Path Integration: Math Theory
@1024kyz
144 views•2020-07-02

Fourier Series Introduction: The Big Idea Explained
@DrTrefor
387K views•2021-05-03

The Mathematical Impossibility of Accurate World Maps
@Vox
23.3M views•2016-12-02
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Mathematics














![1.1 Symbolic Method [Lecture 1 - Combinatorial structures and OGFs]](https://i.ytimg.com/vi/ULpHNFtOBBI/sddefault.jpg?sqp=-oaymwEmCIAFEOAD8quKqQMa8AEB-AHUBoAC4AOKAgwIABABGC4gQSh_MA8=&rs=AOn4CLCS0jUeXbkfhVW7cn825-olLGXd0w)










![2.2 Symbolic Method for Labelled Classes [Lecture 2 - Labelled Structures and EGFs]](https://i.ytimg.com/vi/EFHwN4m0dd8/sddefault.jpg?sqp=-oaymwEmCIAFEOAD8quKqQMa8AEB-AHUBoAC4AOKAgwIABABGDsgSCh_MA8=&rs=AOn4CLAbvfyrfRB0ep5-Immv3Tbz0e2APw)













