# FindGeneratingFunction gives up too easily [closed]

I am trying to automatically find a generating function from the coefficients of a simple rational function using Mathematica's FindGeneratingFunction:

f[x_] := (x + 2 x^2 + x^3 + 2 x^4 + x^5)/(1 - 2 x + 2 x^3 - x^4)
coefs = Table[SeriesCoefficient[f[x], {x, 0, n}], {n, 0, 4}]
FindGeneratingFunction[coefs, x, FunctionSpace -> "Rational", TimeConstraint -> 999999]


However, even after specifying the right FunctionSpace and increasing the TimeConstraint, Mathematica immediately gives up on finding a solution. Does anyone know how I can make Mathematica search harder for a solution?

Also, if I restrict the list to the first 4 elements, it does find a generating function, but only if I remove both the FunctionSpace and TimeConstraint parameters. Why?

• You need at least 12 series coefficient, a to a, in order to uniquely determine the rational generating function. – Somos Feb 4 '19 at 3:05

f[x_] := (x + 2 x^2 + x^3 + 2 x^4 + x^5)/(1 - 2 x + 2 x^3 - x^4)

coefs = Table[SeriesCoefficient[f[x], {x, 0, n}], {n, 0, 11}];


The option FunctionSpace should be specified as "RationalFunction" rather than "Rational". And as pointed out in the comment by Samos, you need more coefficients.

g[x_] = FindGeneratingFunction[coefs, x,
FunctionSpace -> "RationalFunction"] // Simplify

(* -((x (1 + 2 x + x^2 + 2 x^3 + x^4))/((-1 + x)^3 (1 + x))) *)


Verifying equivalence,

f[x] == g[x] // Simplify

(* True *)


Or use the default for FunctionSpace

FindGeneratingFunction[coefs, x] == f[x] // Simplify

(* True *)