GeneratingFunction
The ordinary generating function ∑nexpr(n)xn of a sequence, in closed form, when one exists.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
GeneratingFunction!↗GeneratingFunction(expr, n, x)the ordinary generating function of expr(n) in xTyped signatures
| Type | Package | Applies |
|---|---|---|
(any, symbol, symbol) -> any | combinatorics | always |
Domain: Combinatorics
Details
- C-finite sequences (satisfying a constant-coefficient linear recurrence -- Fibonacci-like sequences, fixed-k binomials, polynomials in n, geometric terms, and any combination of those) get a rational generating function, found from the recurrence by Berlekamp--Massey -- there is no family-specific code.
- A handful of named, non-C-finite sequences are recognised directly by value, not by name: the Catalan numbers have the algebraic generating function (1−1−4x)/(2x).
Count(Family(n))is not special-cased either: it is sampled numerically like any other sequence, so a family whose cardinality happens to be Catalan (or any C-finite sequence) gets the matching closed form automatically.- Falls back to staying symbolic when no closed form is found (e.g. n! has none), the same as Wolfram.
Examples
Basic #
(1−1−4x)/(2x) -- algebraic, not rational: Catalan numbers are not C-finite
live ↗InGeneratingFunction(CatalanNumber(n),n,x)Out2x1−1−4x
the same Catalan generating function, reached through a collection's cardinality rather than CatalanNumber directly
live ↗InGeneratingFunction(Count(DyckPaths(n)),n,x)Out2x1−1−4x
The constant sequence 1 sums to the geometric series 1/(1−x)
live ↗InGeneratingFunction(1,n,x)Out1−x1
Scope #
n! has no elementary ordinary generating function -- stays unevaluated, as Wolfram does too
live ↗InGeneratingFunction(n!,n,x)OutGeneratingFunction(n!,n,x)
live ↗
In[GeneratingFunction(n,n,z),GeneratingFunction(n2,n,z)]Out[z2−2z+1z,−z3+3z2−3z+1z2+z]
live ↗
In[GeneratingFunction(UnitStep(n),n,z),GeneratingFunction(UnitStep(n−3),n,z)]Out[1−z1,1−zz3]
live ↗
In[GeneratingFunction(nUnitStep(n),n,z),GeneratingFunction((n−3)UnitStep(n−3),n,z)]Out[z2−2z+1z,z2−2z+1z4]
Properties #
The squares give z(1+z)/(1−z)3, one more pole order than n
live ↗InGeneratingFunction(n2,n,z)Out−z3+3z2−3z+1z2+z
live ↗
In[GeneratingFunction(n!n,n,z),ExponentialGeneratingFunction(n,n,z)]Out[GeneratingFunction(n!n,n,z),zez]
About
| Examples | 14 |
|---|---|
| Checked against | Wolfram Language 11 agree2 differ |
| Crosswalk | Wolfram Language |
See also: ExponentialGeneratingFunction, FindSequenceFunction, DiscreteRatio