 To find a generating function for a sequence, we assume some function given as a power series, then we use algebra and calculus to eliminate the tail of the series and solve for f of x. And all of this revolves around our key strategy, be a lizard, and drop the tail. So suppose we want to find a generating function for this recurrence relation, where we know a0, a1, and a2. So it's useful to remember we should try to align on the xn term. So our power series has an xn term, anx to the n. Our recurrence relation has a term for an-1, and we want that to be an x to the n term, so we want for an-1 x to the n. Now in our function, the an-1 coefficient is multiplied by x to the n-1. And so to make for an-1 the coefficient of x to the n, we need to multiply f of x by 4x. Our recurrence relation has a minus 5 an-2, and we want minus 5 an-2 x to the n. So in our power series we have an-2 x to the power n-2, and so we want to multiply our function by minus 5x squared. Our recurrence relation has a 2 an-3 term. We want 2 an-3 to the power xn, and in our function we have an-3 x to the power n-3. So multiplying by 2x cubed gives us 2 an-3 x to the n. Now because we've aligned on the x to the n term, this means our x to the n coefficients include something that looks like our recurrence relation. And in fact if we subtract our xn coefficient will be, but from our recurrence relation we know that an is equal to the subtracted terms, which means that after a certain point all our coefficients are zero and the tail drops out. And in fact the first value the recurrence relationship can compute is a3, which means that the x cubed and higher degree terms vanish automatically. So if we look at the left hand side it will be f of x minus, and we can simplify that. So remember the x cubed and higher degree terms vanish automatically because of the recurrence relationship. We need to worry about the x squared or lower degree terms, and we'll include them as the first terms. In f of x they are, in 4x f of x they are, where again we only need to worry about the x squared or lower degree terms. And likewise for minus 5x squared and 2x cubed f of x our first terms up to the square term will be, the right hand side will be, and since we know a0, a1 and a2 we can simplify to get, and finally we can solve for f of x to get. So now that we've gone through all this trouble to find a generating function, why bother? We'll take a look at that next.