GeneratingFunction[expr,n,x]
gives the generating function in x for the sequence whose n
series coefficient is given by the expression expr.
GeneratingFunction[expr,{n1,…,nm},{x1,…,xm}]
gives the multidimensional generating function in x1,…,xm whose n1,… ,nm coefficient is given by expr.
GeneratingFunction
GeneratingFunction[expr,n,x]
gives the generating function in x for the sequence whose n
series coefficient is given by the expression expr.
GeneratingFunction[expr,{n1,…,nm},{x1,…,xm}]
gives the multidimensional generating function in x1,…,xm whose n1,… ,nm coefficient is given by expr.
Details and Options
- The generating function for a sequence whose n
term is an is given by
. - The multidimensional generating function is given by
. - The following options can be given:
-
Assumptions $Assumptions assumptions to make about parameters GenerateConditions False whether to generate answers that involve conditions on parameters Method Automatic method to use VerifyConvergence True whether to verify convergence - In TraditionalForm, GeneratingFunction is output using
.
Examples
open all close allBasic Examples (3)
The generating function for the sequence whose n
term is 1:
GeneratingFunction[1, n, x]All coefficients in the series are 1:
Series[%, {x, 0, 10}]Univariate generating function:
GeneratingFunction[(1/n!^2), n, x]GeneratingFunction[(1/(n + 1)! m!), {n, m}, {x, y}]The generating function for a shifted sequence:
GeneratingFunction[f[n + 1], n, x]Scope (23)
Basic Uses (7)
Generating function of a univariate function:
GeneratingFunction[a ^ n, n, z]Generating function of a multivariate function:
GeneratingFunction[1 / (m!n!), {m, n}, {x, y}]Compute a typical generating function:
F = GeneratingFunction[n (n + 1)(-1 / 2) ^ n, n, z]Plot the magnitude using Plot3D, ContourPlot or DensityPlot:
Block[{z = u + I v}, Table[plot[Abs[F], {u, -2, 2}, {v, -2, 2}], {plot, {Plot3D, ContourPlot, DensityPlot}}]]Block[{z = u + I v}, Table[plot[Arg[F], {u, -2, 2}, {v, -2, 2}], {plot, {Plot3D, ContourPlot, DensityPlot}}]]Generate conditions for the region of convergence:
GeneratingFunction[a ^ n, n, z, GenerateConditions -> True]With[{z = u + I v}, RegionPlot[Abs[z] < 1 / Abs[1 / 2], {u, -4, 4}, {v, -4, 4}]]Evaluate the generating function at a point:
F = GeneratingFunction[Sin[n 2Pi / 3](2 / 3) ^ n, n, Exp[I ω]]LogPlot[Abs[F] ^ 2, {ω, 0, 2π}, Ticks -> {{0, π, 2π}, Automatic}]Plot[Arg[F], {ω, 0, 2π}, Ticks -> {{0, π, 2π}, Automatic}]Plot both the spectrum and the plot phase using color:
LogPlot[Abs[F] ^ 2, {ω, 0, 2π}, Ticks -> {{0, π, 2π}, Automatic}, ColorFunction -> Function[ω, Evaluate@Hue[Arg[F] / (2Pi) + 1 / 2]], ColorFunctionScaling -> False, Filling -> Axis]Plot the spectrum in the complex plane using ParametricPlot3D:
ParametricPlot3D[{Cos[ω], Sin[ω], Log[10, Abs[F] ^ 2]}, {ω, 0, 2π}, BoxRatios -> {1, 1, 1}]GeneratingFunction will use several properties including linearity:
GeneratingFunction[a f[n] + b g[n], n, z]{GeneratingFunction[f[n + 1], n, z], GeneratingFunction[f[n - 1], n, z]}Multiplication by exponentials:
{GeneratingFunction[a ^ n f[n], n, z], GeneratingFunction[b ^ (-n)f[n], n, z]}GeneratingFunction[Exp[I ω n]f[n], n, z]Multiplication by polynomials:
{GeneratingFunction[ n f[n], n, z], GeneratingFunction[n(n + 1) f[n], n, z]}GeneratingFunction[Conjugate[f[n]], n, z]GeneratingFunction automatically threads over lists:
GeneratingFunction[{a ^ n, b ^ n}, n, z]GeneratingFunction[{{a ^ n, b ^ n}, {n, n ^ 2}}, n, z]GeneratingFunction[a ^ n == f[n], n, z]GeneratingFunction[f[n] -> a ^ n, n, z]TraditionalForm typesetting:
GeneratingFunction[f[n], n, z]//TraditionalFormSpecial Sequences (12)
{GeneratingFunction[DiscreteDelta[n], n, z], GeneratingFunction[DiscreteDelta[n - 5], n, z]}Table[DiscretePlot[f, {n, -10, 10}, PlotStyle -> PointSize[Medium]], {f, {DiscreteDelta[n], DiscreteDelta[n - 5]}}]{GeneratingFunction[UnitStep[n], n, z], GeneratingFunction[UnitStep[n - 3], n, z]}Table[DiscretePlot[f, {n, -10, 10}], {f, {UnitStep[n], UnitStep[n - 3]}}]{GeneratingFunction[n UnitStep[n], n, z], GeneratingFunction[(n - 3)UnitStep[n - 3], n, z]}Table[DiscretePlot[f, {n, -10, 10}], {f, {n UnitStep[n], (n - 3)UnitStep[n - 3]}}]Polynomials result in rational generating functions:
{GeneratingFunction[n, n, z], GeneratingFunction[n ^ 2, n, z]}GeneratingFunction[Pochhammer[n, Range[0, 3]], n, z]GeneratingFunction[FactorialPower[n, Range[0, 3]], n, z]GeneratingFunction[a ^ n, n, z]{GeneratingFunction[n a ^ n, n, z], GeneratingFunction[n ^ 2 a ^ n, n, z]}Table[DiscretePlot[f, {n, 0, 40}], {f, {n (10 / 12) ^ n, n ^ 2 (10 / 12) ^ n}}]Factorial exponential polynomials:
GeneratingFunction[Pochhammer[n, Range[0, 3]] a ^ n, n, z]GeneratingFunction[FactorialPower[n, Range[0, 3]] a ^ n, n, z]{GeneratingFunction[Sin[ω n + ϕ], n, z], GeneratingFunction[Cos[ω n + ϕ], n, z]}Table[DiscretePlot[f, {n, -20, 20}], {f, {Sin[2π / 10 n], Cos[2π / 10 n]}}]Trigonometric, exponential and polynomial:
{GeneratingFunction[(5 / 6) ^ n Sin[ω n], n, z], GeneratingFunction[n (5 / 6) ^ n Sin[ω n], n, z]}Table[DiscretePlot[f, {n, 0, 20}], {f, {(5 / 6) ^ n Sin[2π / 10 n], n (5 / 6) ^ n Sin[2π / 10 n]}}]Combinations of the previous input will also generate rational generating functions:
GeneratingFunction[n ^ 2 a ^ n + b ^ n Sin[ω n] UnitStep[n + 20], n, z]DiscretePlot[n ^ 2 (5 / 6) ^ n + (11 / 12) ^ n 20Sin[2Pi / 10 n]UnitStep[n - 20], {n, 0, 50}]Different ways of expressing piecewise-defined signals:
GeneratingFunction[n (UnitStep[n] - UnitStep[n - 6]) + a ^ n UnitStep[n - 6], n, z]GeneratingFunction[Piecewise[{{n, n ≤ 5}, {a ^ n, True}}], n, z]Simplify[%% - %]GeneratingFunction[1 / (n + 1), n, z]GeneratingFunction[(n^2 + n + 1) / (n + 1) ^ 2, n, z]GeneratingFunction[FactorialPower[n, -2], n, z]Rational exponential functions:
GeneratingFunction[a ^ n / (n + 1) ^ 2, n, z]GeneratingFunction[a ^ n FactorialPower[n, -2], n, z]Hypergeometric term sequences:
GeneratingFunction[1 / n!, n, z]The DiscreteRatio is rational for all hypergeometric term sequences:
DiscreteRatio[1 / n!, n]Many functions give hypergeometric terms:
hl = {a ^ n, n!, Gamma[n], Pochhammer[a, n], FactorialPower[a, n], Binomial[n, a], Binomial[b, n], CatalanNumber[n]};DiscreteRatio[hl, n]Any products are hypergeometric terms:
DiscreteRatio[Times@@RandomChoice[hl, 3], n]Generating functions of hypergeometric terms:
GeneratingFunction[(2^-2 + n/Gamma[(1/2) + n]), n, z]GeneratingFunction[n / Binomial[2n, n], n, z]GeneratingFunction[CatalanNumber[n] / Binomial[2n, n], n, z]GeneratingFunction[(FactorialPower[a1, n]/FactorialPower[b1, n]FactorialPower[b2, n]), n, z]GeneratingFunction[LegendreP[n, a], n, z]A holonomic sequence is defined by a linear difference equation:
DifferenceRootReduce[LegendreP[n, a], n]Many special function are holonomic sequences in their index:
GeneratingFunction[ChebyshevT[n, x], n, z]GeneratingFunction[ChebyshevU[2n, x] ^ 2, n, z]GeneratingFunction[BernoulliB[n] / n!, n, z]GeneratingFunction[EulerE[n] / n!, n, z]GeneratingFunction[DifferenceRoot[Function[{y, m}, {y[m + 2] == y[m + 1] + y[m], y[0] == 0, y[1] == 1}]][n], n, z]GeneratingFunction[Mod[n, 3], n, z]GeneratingFunction[Exp[n 2π I / 9], n, z]Multivariate generating functions:
GeneratingFunction[a^n + m, {n, m}, {u, v}]GeneratingFunction[n ^ 2 m ^ 3, {n, m}, {u, v}]GeneratingFunction[Sin[n + m]a ^ n, {n, m}, {u, v}]GeneratingFunction[m / (n + 1), {n, m}, {u, v}]GeneratingFunction[Mod[n + m, 3], {n, m}, {u, v}]Special Operators (4)
GeneratingFunction[a * f[n] + b * f[n], n, z]GeneratingFunction[DifferenceDelta[f[n], n], n, z]GeneratingFunction[DiscreteShift[f[n], n], n, z]GeneratingFunction[Sum[f[m], {m, 0, n}], n, z]GeneratingFunction[Sum[f[m], {m, a, n}], n, z, Assumptions -> a > 0 && a∈Integers]GeneratingFunction[Integrate[f[x, n], {x, a, b}], n, z]Generalizations & Extensions (1)
Options (6)
Assumptions (1)
In general, this generating function cannot be given:
GeneratingFunction[f[n + a], n, x]By providing additional Assumptions, a closed form can be given:
GeneratingFunction[f[n + a], n, x, Assumptions -> a∈Integers && a > 0]GenerateConditions (1)
By default, no conditions are given for where a generating function is convergent:
GeneratingFunction[a ^ n, n, x]Use GenerateConditions to generate conditions of validity:
GeneratingFunction[a ^ n, n, x, GenerateConditions -> True]Method (1)
VerifyConvergence (3)
Setting VerifyConvergence to False will treat generating functions as formal objects:
GeneratingFunction[2 ^ n, n, x, VerifyConvergence -> False]Setting VerifyConvergence to True will verify that the radius of convergence is nonzero:
GeneratingFunction[2 ^ n, n, x, VerifyConvergence -> True]In addition, setting GenerateConditions to True will display the conditions for convergence:
GeneratingFunction[2 ^ n, n, x, VerifyConvergence -> True, GenerateConditions -> True]Properties & Relations (5)
Use SeriesCoefficient to get the sequence from its generating function:
GeneratingFunction[SeriesCoefficient[F[z], {z, 0, n}], n, z]GeneratingFunction[a ^ n Sin[n], n, z]SeriesCoefficient[%, {z, 0, n}]GeneratingFunction effectively computes an infinite sum:
GeneratingFunction[n ^ 2, n, z]Sum[n ^ 2 z ^ n, {n, 0, Infinity}]GeneratingFunction and ZTransform can be expressed in terms of each other:
{ZTransform[n ^ 2, n, z], GeneratingFunction[n ^ 2, n, 1 / z]}//Simplify{ZTransform[n ^ 2, n, 1 / z], GeneratingFunction[n ^ 2, n, z]}//SimplifyGeneratingFunction[a f[n] + b g[n], n, z]GeneratingFunction[f[n + 2], n, z]GeneratingFunction[Sum[f[k]g[k - n], {k, 0, n}], n, z]GeneratingFunction[n f[n], n, z]GeneratingFunction is closely related to ExponentialGeneratingFunction:
{GeneratingFunction[n / n!, n, z], ExponentialGeneratingFunction[n, n, z]}{GeneratingFunction[n, n, z], ZTransform[n, n, 1 / z]}//Simplify{GeneratingFunction[n, n, Exp[I * ω]], FourierSequenceTransform[n UnitStep[n], n, ω]}Possible Issues (1)
A GeneratingFunction may not converge for all values of parameters:
{Sum[2 ^ n 1 ^ n, {n, 0, ∞}], GeneratingFunction[2 ^ n, n, 1]}GeneratingFunction[a ^ n, n, x]Use GenerateConditions to get the region of convergence:
GeneratingFunction[a ^ n, n, x, GenerateConditions -> True]Neat Examples (1)
Create a gallery of generating functions:
flist = {{UnitStep[n + 1 / 2], n, z}, {n ^ 2 + 2, n, z}, {1 / (2n + 1), n, z}, {Sin[a n], n, z}, {ChebyshevU[n, a], n, z}, {BernoulliB[n] / n!, n, z}, {a ^ n Sin[n], n, z}, {Mod[n, 7], n, z}, {Binomial[m, n], {m, n}, {u, v}}, {m / (n + 1), {m, n}, {u, v}}};Grid[Prepend[{#[[1]], GeneratingFunction@@#}& /@ flist, {f, "Generating Function"}], IconizedObject[«Grid options»]]//TraditionalFormRelated Guides
Related Links
History
Text
Wolfram Research (2008), GeneratingFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/GeneratingFunction.html.
CMS
Wolfram Language. 2008. "GeneratingFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GeneratingFunction.html.
APA
Wolfram Language. (2008). GeneratingFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GeneratingFunction.html
BibTeX
@misc{reference.wolfram_2026_generatingfunction, author="Wolfram Research", title="{GeneratingFunction}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/GeneratingFunction.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_generatingfunction, organization={Wolfram Research}, title={GeneratingFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/GeneratingFunction.html}, note=[Accessed: 15-June-2026]}