# How to extract coefficients of a generating function like this one, using a computer?

For example if we have the generating function $$G (x) = (1 + x + ... + x^k)^{10}$$ and we want to calculate the coefficient of $$x^{3k}$$ as a function of $$k$$: What is the best way to go about it using Mathematica?

• Assuming[k \[Element] Integers && k > 1, SeriesCoefficient[(-1 + x^(1 + k))^10/(-1 + x)^10, {x, 0, 3 k}] // FullSimplify]. – AccidentalFourierTransform Jun 30 '19 at 16:17

Clear["Global*"]


The closed-form of the Sum is

G[x_, k_] = Sum[x^n, {n, 0, k}]^10

(* (-1 + x^(1 + k))^10/(-1 + x)^10 *)


The coefficient for the x^(3k) term of G[x, k] is

coef3k[k_] =
FindSequenceFunction[
Table[SeriesCoefficient[G[x, k], {x, 0, 3 k}], {k, 1, 15}], k] //
FullSimplify

(* (1/90720)(1 + k) (2 + k) (3 + k) (15120 +
k (57552 + k (121438 + k (137565 + k (89110 + k (29163 + 3652 k)))))) *)


Verifying the result for k in the interval {0, 200}

And @@ Table[
coef3k[k] == SeriesCoefficient[G[x, k], {x, 0, 3 k}],
{k, 0, 200}]

(* True *)


Define the function

a[n_, k_] := SeriesCoefficient[ Sum[x^i, {i, 0, k}]^10, {x, 0, n}];


and you want a[3 k, k]. By the way, this is a $$9$$th degree polynomial function as given by

FindSequenceFunction[Table[a[3 k, k], {k, 9+2}]]


where FindSequenceFunction[]` is a bit finicky for polynomials of degree less than 2, but for quadratic and higher degree polynomials you need at least 2 more terms of the sequence than its degree.