Solving multivariate generating functions

December 26, 2022
Útulek Series, 6 | CF1761D Chapter, 6

It seemed appropriate to broach the subject directly today—that is, generating functions. To do this, we will be looking at three functions today: f(x)f(x) the Fibonacci sequence generating function, p(x,y)p(x,y) the generating function for Pascal’s triangle, and finally g(x,y)g(x,y) the generating function for 1761D: Gi,j=3Gi1,j+3Gi1,j18Gi2,j1G_{i,j}=3G_{i-1,j}+3G_{i-1,j-1}-8G_{i-2,j-1} (it is minor, but I have since determined that GG is a better letter to use than AA for 1761D), which, as a reminder, generates

13194327151398154524227.\begin{matrix} 1\\ 3&1\\ 9&4&3\\ 27&15&13&9\\ 81&54&52&42&27\\ \ldots. \end{matrix}

1 Deriving the Generating Functions

As in the proof for ζ(2)\zeta(2) in Taylor Series, we utilize the properties of a polynomial to gain more information on its coefficients. The theory of generating functions begins by assigning the sequence as the coefficients of the polynomial:

f(x)=0x0+1x1+1x2+2x3+3x4+5x5+=iFixi,p(x,y)=1x0y0+1x1y0+1x0y1+1x2y0+2x1y1+1x0y2+1x3y0+3x2y1+3x1y2+1x0y3+=ijPi,jxiyj,g(x,y)=1x0y0+3x1y0+1x0y1+9x2y0+4x1y1+3x0y2+27x3y0+15x2y1+13x1y2+9x0y3+=ijGi,jxiyj.\begin{aligned} f(x)&=0x^0+1x^1+1x^2+2x^3+3x^4+5x^5+\ldots\\ &=\sum_i F_ix^i,\\ p(x,y)&=1x^0y^0\\ &+1x^1y^0+1x^0y^1\\ &+1x^2y^0+2x^1y^1+1x^0y^2\\ &+1x^3y^0+3x^2y^1+3x^1y^2+1x^0y^3\\ &+\ldots\\ &=\sum_i\sum_j P_{i,j}x^iy^j,\\ g(x,y)&=1x^0y^0\\ &+3x^1y^0+1x^0y^1\\ &+9x^2y^0+4x^1y^1+3x^0y^2\\ &+27x^3y^0+15x^2y^1+13x^1y^2+9x^0y^3\\ &+\ldots\\ &=\sum_i\sum_j G_{i,j}x^iy^j. \end{aligned}

We then proceed to reduce the generating function into a recurrent form for easier analysis. This is quite trivial for one-dimensional recurrences, but two-dimensional ones need some care around boundary conditions. As

Fi:=Fi1+Fi2,Pi,j:=Pi1,j+Pi1,j1,Gi,j:=3Gi1,j+3Gi1,j18Gi2,j1,\begin{aligned} F_i&:=F_{i-1}+F_{i-2},\\ P_{i,j}&:=P_{i-1,j}+P_{i-1,j-1},\\ G_{i,j}&:=3G_{i-1,j}+3G_{i-1,j-1}-8G_{i-2,j-1}, \end{aligned}

we have recurrent generating functions

f(x)=x+xf(x)+x2f(x),p(x,y)=1+xp(x,y)+xyp(x,y),g(x,y)=12xy+3xg(x,y)+3xyg(x,y)8x2yg(x,y),\begin{aligned} f(x)&=x+xf(x)+x^2f(x),\\ p(x,y)&=1+xp(x,y)+xyp(x,y),\\ g(x,y)&=1-2xy+3xg(x,y)+3xyg(x,y)-8x^2yg(x,y), \end{aligned}

which subsequently solves as

f(x)=x1xx2,p(x,y)=11xxy,g(x,y)=12xy13x3xy+8x2y.\begin{aligned} f(x)&=\frac{x}{1-x-x^2},\\[3ex] p(x,y)&=\frac{1}{1-x-xy},\\[3ex] g(x,y)&=\frac{1-2xy}{1-3x-3xy+8x^2y}. \end{aligned}

2 Solving the Fibonacci

I believe all one-degree one-dimensional generating functions may be partial fraction decomposed (this seems easy to prove):

f(x)=x1xx2=(11/5)/2x(15)/2+(1+1/5)/2x(1+5)/2=(1+1/5)/2(51)/2x+(11/5)/2(51)/2x=1/51(51)x/2+1/51(5+1)x/2=15(11(5+1)x/211(51)x/2)\begin{aligned} f(x)&=\frac{x}{1-x-x^2}\\[3ex] &=\frac{(-1-1/\sqrt{5})/2}{x-(-1-\sqrt{5})/2}+\frac{(-1+1/\sqrt{5})/2}{x-(-1+\sqrt{5})/2}\\[3ex] &=\frac{(1+1/\sqrt{5})/2}{(-\sqrt{5}-1)/2-x}+\frac{(1-1/\sqrt{5})/2}{(\sqrt{5}-1)/2-x}\\[3ex] &=\frac{-1/\sqrt{5}}{1-(\sqrt{5}-1)x/2}+\frac{1/\sqrt{5}}{1-(\sqrt{5}+1)x/2}\\[3ex] &=\frac{1}{\sqrt{5}}(\frac{1}{1-(\sqrt{5}+1)x/2}-\frac{1}{1-(\sqrt{5}-1)x/2})\\ \end{aligned}

we have recurrent generating functions

f(x)=x+xf(x)+x2f(x),p(x,y)=1+xp(x,y)+xyp(x,y),g(x,y)=12xy+3xg(x,y)+3xyg(x,y)8x2yg(x,y),\begin{aligned} f(x)&=x+xf(x)+x^2f(x),\\ p(x,y)&=1+xp(x,y)+xyp(x,y),\\ g(x,y)&=1-2xy+3xg(x,y)+3xyg(x,y)-8x^2yg(x,y), \end{aligned}

which subsequently solves as

f(x)=x1xx2,p(x,y)=11xxy,g(x,y)=12xy13x3xy+8x2y.\begin{aligned} f(x)&=\frac{x}{1-x-x^2},\\[3ex] p(x,y)&=\frac{1}{1-x-xy},\\[3ex] g(x,y)&=\frac{1-2xy}{1-3x-3xy+8x^2y}. \end{aligned}

2 Solving the Fibonacci

I believe all one-degree one-dimensional generating functions may be partial fraction decomposed (this seems easy to prove):

f(x)=x1xx2=(11/5)/2x(15)/2+(1+1/5)/2x(1+5)/2=(1+1/5)/2(51)/2x+(11/5)/2(51)/2x=1/51(51)x/2+1/51(5+1)x/2=15(11(5+1)x/211(51)x/2)\begin{aligned} f(x)&=\frac{x}{1-x-x^2}\\[3ex] &=\frac{(-1-1/\sqrt{5})/2}{x-(-1-\sqrt{5})/2}+\frac{(-1+1/\sqrt{5})/2}{x-(-1+\sqrt{5})/2}\\[3ex] &=\frac{(1+1/\sqrt{5})/2}{(-\sqrt{5}-1)/2-x}+\frac{(1-1/\sqrt{5})/2}{(\sqrt{5}-1)/2-x}\\[3ex] &=\frac{-1/\sqrt{5}}{1-(\sqrt{5}-1)x/2}+\frac{1/\sqrt{5}}{1-(\sqrt{5}+1)x/2}\\[3ex] &=\frac{1}{\sqrt{5}}(\frac{1}{1-(\sqrt{5}+1)x/2}-\frac{1}{1-(\sqrt{5}-1)x/2})\\ \end{aligned}

which is now the sum of two geometric sequences in xx. We may take the coefficient of xix^i then as

Fi=[xi]f(x)=15((5+12)i+(512)i)\begin{aligned} F_i=[x^i]f(x)=\frac{1}{\sqrt{5}}((\frac{\sqrt{5}+1}{2})^i+(\frac{\sqrt{5}-1}{2})^i) \end{aligned}

which coincides with Binet’s formula as expected.

3 Solving the Pascal

This one was very tricky for me but I ended up solving it at the end of the day.

The key here is sequential isolation of the variable powers with liberal use of geometric series reinterpretations. Of course, one should expect combinatorial arguments to arise at some point. We use [x][x] to denote “the coefficient of xx.”

p(x,y)=11xxy=11x11x1xy,[yj]p(x,y)=11x(x1x)j,Pi,j=[xi][yj]p(x,y)=[xi](1+x+x2+)(x+x2+x3+)j=[xij](1+x+x2+)j+1\begin{aligned} p(x,y)&=\frac{1}{1-x-xy}=\frac{1}{1-x}\cdot\frac{1}{1-\frac{x}{1-x}y},\\[3ex] [y^j]p(x,y)&=\frac{1}{1-x}\cdot(\frac{x}{1-x})^j,\\[3ex] P_{i,j}=[x^i][y^j]p(x,y)&=[x^i](1+x+x^2+\ldots)(x+x^2+x^3+\ldots)^j\\ &=[x^{i-j}](1+x+x^2+\ldots)^{j+1} \end{aligned}

at which point we must use stars and bars with iji-j stars and jj bars:

Pi,j=(ij+1)(ij+2)(i)j!=(ij).\begin{aligned} P_{i,j}&=\frac{(i-j+1)(i-j+2)\cdots(i)}{j!}\\[3ex] &={i\choose j}. \end{aligned}

The reason radicals don’t show up here is likely to due with the degrees of the variables and the dimension of the recurrence. It has to do with how simple the second term 1/(1x1xy)1/(1-\frac{x}{1-x}y) is. I think there’s some simple condition that I’m missing here, but I will sleep on it.

4 Solving 1761D

Similarly,

g(x,y)=12xy13x3xy+8x2y=113x12xy13x8x213xy,[yj]g(x,y)=113x(3x8x213x)j1(3x8x213x2x)=113x(3x+x213x)j1(x2x213x)=xj113x(3+x13x)j1(1+x13x),Gi,j=[xi][yj]g(x,y)=[xij](1+3x+9x2+)(3+x+3x2+9x3+)j1(1+x+3x2+9x3+)=k=0j13k(j1k)[xij](1+3x+9x2+)(x+3x2+9x3+)j1k(1+x+3x2+9x3+)=k=0j13k(j1k)[xi2j+1+k](1+3x+9x2+)jk(1+x+3x2+9x2+)=k=0j13k(j1k)([xi2j+1+k](1+3x+9x2+)jk+[xi2j+k](1+3x+9x2+)jk+1)=k=0j13k(j1k)(3i2j+1+k(ijjk1)+3i2j+k(ijjk))=k=0j13i2j+2k(j1k)(3(ijjk1)+(ijjk)).\begin{aligned} g(x,y)&=\frac{1-2xy}{1-3x-3xy+8x^2y}\\[3ex] &=\frac{1}{1-3x}\cdot\frac{1-2xy}{1-\frac{3x-8x^2}{1-3x}y},\\[3ex] [y^j]g(x,y)&=\frac{1}{1-3x}\cdot(\frac{3x-8x^2}{1-3x})^{j-1}(\frac{3x-8x^2}{1-3x}-2x)\\[3ex] &=\frac{1}{1-3x}\cdot(3x+\frac{x^2}{1-3x})^{j-1}(\frac{x-2x^2}{1-3x})\\[3ex] &=x^j\cdot\frac{1}{1-3x}\cdot(3+\frac{x}{1-3x})^{j-1}(1+\frac{x}{1-3x}),\\[3ex] G_{i,j}&=[x^i][y^j]g(x,y)\\[3ex] &=[x^{i-j}](1+3x+9x^2+\ldots)(3+x+3x^2+9x^3+\ldots)^{j-1}(1+x+3x^2+9x^3+\ldots)\\[3ex] &=\sum_{k=0}^{j-1}3^k{j-1\choose k}[x^{i-j}](1+3x+9x^2+\ldots)(x+3x^2+9x^3+\ldots)^{j-1-k}(1+x+3x^2+9x^3+\ldots)\\[3ex] &=\sum_{k=0}^{j-1}3^k{j-1\choose k}[x^{i-2j+1+k}](1+3x+9x^2+\ldots)^{j-k}(1+x+3x^2+9x^2+\ldots)\\[3ex] &=\sum_{k=0}^{j-1}3^k{j-1\choose k}([x^{i-2j+1+k}](1+3x+9x^2+\ldots)^{j-k}+[x^{i-2j+k}](1+3x+9x^2+\ldots)^{j-k+1})\\[3ex] &=\sum_{k=0}^{j-1}3^k{j-1\choose k}(3^{i-2j+1+k}{i-j\choose j-k-1}+3^{i-2j+k}{i-j\choose j-k})\\[3ex] &=\sum_{k=0}^{j-1}3^{i-2j+2k}{j-1\choose k}(3{i-j\choose j-k-1}+{i-j\choose j-k}).\\[3ex] \end{aligned}