# How to find closed-form of generating function

I have two series that I wanted to expand and to have the possibility to find the nth element for it. Using Wolfram software I was able to get the patterns but in generating function form. I tried to find some information and examples on how to find a closed-form from generating function but I do not quite understand how to do this except for several simple examples.

Here's the result I get for my series:

$$G_n(a_n)(z) = (-626 z^3 + 90 z^2 + 45 z + 731)/((z - 1)^2 (z^2 + z + 1))$$

and

$$G_n(a_n)(z) = -(3 (27 z^2 - 20 z - 87))/((z - 1)^2 (z + 1))$$

Any help is appreciated, thanks in advance.

• Developing in series about $z=0$ we have $731, 776, 866, 971, 1016, 1106,\cdots$ and $261 , 321,501, 561,741, 801,\cdots$ Commented Jul 15, 2021 at 7:55
• The numbers are correct, but I didn't understand how to get them from generating function (closed form). Could you explain a bit more, please? Commented Jul 15, 2021 at 8:04
• As I said, developing in series about $z=0$. Commented Jul 15, 2021 at 8:08

$$G(z) = \frac{-3( 27 z^2 - 20 z - 87)}{(z - 1)^2 (z + 1)} = \frac{30}{z+1} - \frac{111}{z-1} + \frac{120}{(z-1)^2}$$ Two are geometric series $$\frac{30}{z+1} = \frac{30}{1-(-z)} = \sum_{n=0}^\infty 30 (-1)^n z^n \\ \frac{-111}{z-1} = \frac{111}{1-z} = \sum_{n=0}^\infty 111 z^n$$ and one is a binomial series $$\frac{120}{(z-1)^2} = 120\;(1-z)^{-2} = 120\sum_{n=0}^\infty \binom{-2}{n}(-z)^n =\sum_{n=0}^\infty 120 (n+1) z^n$$ So the final result is $$\sum_{n=0}^\infty \big(120n+231+30(-1)^n\big) z^n =261+321 z+501 z^2+561 z^3+741 z^4+801 z^5+\dots$$
• Thanks a lot! Seems like it missing one more part $... - (-1)^n)z^n$ because otherwise, it is always wrong by one and you'll get 320, 502, 560, ... etc. I tried doing the same with the first function and get the following fractions: $(5(z+4))/(z^2+z+1)+(631)/(z-1)+(80)/(z-1)^2$. So the last two would be $\sum_{n=0}^{\infty} -631z^n$ and $\sum_{n=0}^{\infty} 80 (1 + n)z^n$ respectively. But I stuck with the first one. Could you help me here, please? Commented Jul 15, 2021 at 11:13
• Update for the previous comment - it would be easier to write $\sum_{n=0}^{\infty}(120n+231+30(-1)^n)z^n$ instead of $\sum_{n=0}^{\infty}(120n+231+31(-1)^n-(-1)^n))z^n$ .I tried to take partial fractions from $(5(z+4))/(z^2+z+1)$ also and added the series from the previous fractions. So I ended up with $5z/(z^2+z+1)$ and the following sum $\sum_{n=0}^{\infty}(80 n - 551 + (40 sin(2/3 (1 + n) \pi))/\sqrt{3})z^n$. Can't understand how to deal with $5z/(z^2+z+1)$ part. Commented Jul 15, 2021 at 12:06
• The other one has a trick. For denominator $z^2+z+1$, multiply and divide by $1-z$ to get denominator $1-z^3$. Of course $1/(1-z^3)$ is a nice geometric series. Thus $(5(z+4))/(z^2+z+1)$ turns out to have coefficients with period $3$. Commented Jul 15, 2021 at 16:37