Generating Functions
Total Page:16
File Type:pdf, Size:1020Kb
CHAPTER 4: GENERATING FUNCTIONS MIKE ZABROCKI - 2019 VERSION 1. Introduction Consider the following sequences 0 1 2 3 4 ; ; ; ; ;::: 1; 1; 1; 1; 1; 1; 1;::: 0 0 0 0 0 0 1 2 3 4 ; ; ; ; ;::: 0; 1; 2; 3; 4; 5; 6 ::: 1 1 1 1 1 0 1 2 3 4 ; ; ; ; ;::: 0; 0; 1; 3; 6; 10; 15;::: 2 2 2 2 2 0 1 2 3 4 ; ; ; ; ;::: 0; 0; 0; 1; 4; 10; 20;::: 3 3 3 3 3 0 1 2 3 4 ; ; ; ; ;::: 0; 0; 0; 0; 1; 5; 15 ::: 4 4 4 4 4 We have kind of written the table of binomial coefficients but we have selected the columns as our sequences to look at (we will also consider rows and diagonals too). For any sequence of numbers a0; a1; a2; a3;::: (if you have a finite sequence of numbers then put 0's at the end), we define the generating function of the sequence as the series 2 3 A(x) = a0 + a1x + a2x + a3x + ··· : Remark 1: The first mistake that a lot of people make about the generating function and the sequence is that they are not the same thing. For every sequence we have a generating function and for every generating function we can come up with a sequence. They are not equal. We use the phrases `...the generating function for/of a sequence...' and `...the sequence whose generating function is...' but please don't mix the two things up. Remark 2: A generating function neither generates, nor (at least in our case) is it a function (although it looks like one). x is an indeterminate. x does not have a value. x is a placeholder. Sometimes I will use other variables instead of x, but those will also be 1 2 MIKE ZABROCKI - 2019 VERSION unknowns and we are working in a space where it makes sense to manipulate the variable algebraically. We all know the geometric series: 1 1 + x + x2 + x3 + x4 + ··· = 1 − x (remember (1−x)·(1+x+x2+x3+x4+··· ) = 1+x+x2+x3+x4+· · ·−x−x2−x3−x4− = 1 so divide by (1 − x)). Notice that the second sequence has a generating function x + 2x2 + 3x3 + 4x4 + 5x5 + 6x6 + ··· If you want a formula for it differentiate the first sequence to get 1+2x+3x2 +4x3 +5x4 + 6x5 + ··· and then multiply by x. That is, d 1 x x + 2x2 + 3x3 + 4x4 + 5x5 + 6x6 + ··· = x = : dx 1 − x (1 − x)2 2. Examples of sequences and their generating functions We started to experiment a bit with generating functions and manipulate them and come up with formulas. We wrote down a bunch of sequences that we were able to give formulas for their generating functions. Recall that on Tuesday I had said look at the sequences 0 1 2 3 4 ; ; ; ; ;::: k k k k k If you look for k = 1; 2; 3;::: then you can conjecture that there is a relatively simple formula for the generating function 0 1 2 3 4 X n xk + x + x2 + x3 + x4 + ··· = xn = : k k k k k k (1 − x)k+1 n≥0 2 3 4 P n 1 Proof. Take the derivative of 1 + x + x + x + x + ··· = n≥0 x = 1−x . We have (by a quick induction argument), that dk 1 k! = dxk 1 − x (1 − x)k+1 We also know that dk 1 dk X X = xn = n(n − 1)(n − 2) ··· (n − k + 1)xn−k dxk 1 − x dxk n≥0 n≥0 Therefore 1 X n(n − 1)(n − 2) ··· (n − k + 1) = xn−k (1 − x)k+1 k! n≥0 CHAPTER 4: GENERATING FUNCTIONS 3 n But the binomial coefficient is exactly the coefficient in this sum since k n n! = k k!(n − k)! n(n − 1) ··· (n − k + 1)(n − k)(n − k − 1) ··· 2 · 1 = k!(n − k)(n − k − 1) ··· 2 · 1 n(n − 1)(n − 2) ··· (n − k + 1) = : k! Therefore 1 X n = xn−k (1 − x)k+1 k n≥0 and xk X n = xn : (1 − x)k+1 k n≥0 This corresponds to looking at columns of Pascal's triangle. We can also look at rows 1 1 1 1 1 ; ; ; ; ;::: = 1; 1; 0; 0; 0; 0;::: 0 1 2 3 4 2 2 2 2 2 ; ; ; ; ;::: = 1; 2; 1; 0; 0; 0;::: 0 1 2 3 4 3 3 3 3 3 ; ; ; ; ;::: = 1; 3; 3; 1; 0; 0;::: 0 1 2 3 4 . n n n n n ; ; ; ; ;::: 0 1 2 3 4 These have generating functions (1 + x), (1 + x)2, (1 + x)3 and the general sequence has generating function X n (1 + x)n = xk : k k≥0 Proof. left to the reader. easiest to do this by induction on n. Then I suggested we look at sequences like 1; 2; 3; 4; 5;::: and 12; 22; 32; 42; 52;::: and 13; 23; 33; 43; 55;:::. I looked at 1 d 1 X = = 1 + 2x + 3x2 + 4x3 + 5x4 + 6x5 + ··· = (n + 1)xn: (1 − x)2 dx 1 − x n≥0 4 MIKE ZABROCKI - 2019 VERSION If you multiply by x and then take the derivative then you get the generating function for the squares because x X = x + 2x2 + 3x3 + 4x4 + 5x5 + 6x6 + ··· = (n + 1)xn+1 (1 − x)2 n≥0 and 1 + x d x X = = 1 + 4x + 9x2 + 16x3 + 25x4 + 36x5 + ··· = (n + 1)2xn : (1 − x)3 dx (1 − x)2 n≥0 At this point I was using the computer at a regular basis. I went to the website www.sagemath.org and I had registered for an account or I went to the sage cell server. I used that account to do some of the calculations. These can also be done on Wolfram alpha or in Maple (which you should have access to through the university). sage: taylor((1+x)/(1-x)^3,x,0,15) 256*x^15 + 225*x^14 + 196*x^13 + 169*x^12 + 144*x^11 + 121*x^10 + 100*x^9 + 81*x^8 + 64*x^7 + 49*x^6 + 36*x^5 + 25*x^4 + 16*x^3 + 9*x^2 + 4*x + 1 sage: diff(x/(1-x)^2,x) 1/(x - 1)^2 - 2*x/(x - 1)^3 sage: factor(diff(x/(1-x)^2,x)) -(x + 1)/(x - 1)^3 1+x The first command takes the taylor series of the expression (1−x)3 , the second command x takes the derivative of (1−x)2 and (since that wasn't presented as a single fraction) the x+1 third command factored the rational expression and showed it was equal to − (x−1)3 . Then I said, what if I wanted to come up with a formula for the generating function P 3 n n≥0(n + 1) x ? I should just multiply the last result by x and then differentiate. We find that 0 1 d 1 + x d X X x = x (n + 1)2xn = (n + 1)3xn dx (1 − x)3 dx @ A n≥0 n≥0 and I can use the computer to determine that: sage: factor(diff(x*(1+x)/(1-x)^3,x)) (x^2 + 4*x + 1)/(x - 1)^4 sage: taylor((1+4*x+x^2)/(1-x)^4,x,0,14) 3375*x^14 + 2744*x^13 + 2197*x^12 + 1728*x^11 + 1331*x^10 + 1000*x^9 + 729*x^8 + 512*x^7 + 343*x^6 + 216*x^5 + 125*x^4 + 64*x^3 + 27*x^2 + 8*x + 1 CHAPTER 4: GENERATING FUNCTIONS 5 3. New generating functions from old If we a sequence a0; a1; a2; a3;::: and its generating function 2 3 A(x) = a0 + a1x + a2x + a3x + ··· and we do an operation on the sequence, we can then ask what the effect is on the generating function. For instance, to insert a 0 in the sequence 0; a0; a1; a2; a3;::: then the generating function 2 3 4 is a0x+a1x +a2x +a3x +··· . Algebraically to obtain this expression, we would take A(x) and multiply it by x and hence the generating function for the sequence 0; a0; a1; a2; a3;::: is xA(x). That is, multiplying by x on the generating function shifts the terms in the sequence to the right by one. Next say that you want to shift a sequence to the left by one and obtain the sequence a1; a2; a3; a4;::: by dropping the first term of the sequence. Dividing the generating func- tion by x will have the right effect on the sequence if the first term is zero. If the first term is not zero then dividing by x does not kill off the a0 term. Instead you should first subtract the first term off and then divide by x so the generating function for the sequence a1; a2; a3; a4;::: is (A(x) − a0)=x. If I want to know what the generating function was for the sequence of just the even terms a0; a2; a4; a6;:::. If I set x ! −x then I see that 2 3 4 5 6 A(x) = a0 + a1x + a2x + a3x + a4x + a5x + a6x + ··· and 2 3 4 5 6 A(−x) = a0 + a1(−x) + a2(−x) + a3(−x) + a4(−x) + a5(−x) + a6(−x) + ··· then notice if we add f(x) + f(−x) we have 2 4 6 A(x) + A(−x) = 2a0 + 2a2x + 2a4x + 2a6x + ··· and then divide by 2 1 (A(x) + A(−x)) = a + a x2 + a x4 + a x6 + ··· 2 0 2 4 6 p and then replace x ! x, so that 1 p p (f( x) + f(− x)) = a + a x + a x2 + a x3 + ··· 2 0 2 4 6 and this is the generating function for the sequence a0; a2; a4; a6;:::.