# 生成函数

生成函数是一个幂级数，其系数编码了一个数列，从而整个数列可以作为一个代数对象来处理。对于数列 \( a_0, a_1, a_2, \ldots \)，函数

\[ A(z) = \sum_{k \ge 0} a_k z^k \]

称为该数列的普通生成函数（OGF），系数 \( a_k \) 记作 \( [z^k]A(z) \)<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup>。生成函数是组合数学、概率论和算法分析中的核心工具，它将计数问题与分析方法联系起来<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup>。例如，常数数列 \( 1, 1, 1, \ldots \) 的生成函数为 \( 1/(1-z) = \sum_{N \ge 0} z^N \)<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup>，而二项式系数 \( \binom{n}{0}, \ldots, \binom{n}{n} \) 是 \( (1+x)^n \) 的系数<sup>[2](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Combinatorics_%28Morris%29/02%3A_Enumeration/07%3A_Generating_Functions/7.01%3A_What_is_a_Generating_Function)</sup>。

| 关键事实 | 详情 |
|---|---|
| 普通生成函数 | \( A(z) = \sum_{k \ge 0} a_k z^k \)；系数 \( a_k \) 记作 \( [z^k]A(z) \)<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup> |
| 指数生成函数 | \( \sum_{n \ge 0} a_n x^n / n! \)，用于所计数的对象带有标号或有序的情形<sup>[3](https://www.isibang.ac.in/~d.yogesh/Course_Notes/DM1/Ch10.html)</sup> |
| 系数还原 | 若 \( G_a(s) \) 在原点附近解析，则 \( a_k = \frac{1}{k!} \frac{d^k}{ds^k} G_a(s) \big|_{s=0} \)，因此函数唯一确定数列<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup> |
| 卷积定理 | 若 \( c = a \star b \)（即 \( c_n = \sum_{k=0}^{n} a_k b_{n-k} \)），则 \( G_c(s) = G_a(s) G_b(s) \)<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup> |
| 概率生成函数 | 对于 \( X \sim \mathrm{Bin}(n,p) \)，\( G(s) = (1-p+ps)^n \)；对于 \( X \sim \mathrm{Poi}(\lambda) \)，\( G(s) = e^{\lambda(s-1)} \)<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup> |
| 递推关系 | 生成函数为求解许多递推关系提供了机械化的方法，包括斐波那契递推等线性递推<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup><sup> • </sup><sup>[5](https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/15.%20Generating%20Functions%20I/Generating%20Functions%20I.pdf)</sup> |
| 历史起源 | 欧拉于1748年以生成函数 \( \sum_{n=0}^{\infty} p(n) q^n = 1/(q;q)_\infty \) 开创了整数分拆的数学理论<sup>[6](https://doi.org/10.1016/j.jnt.2016.01.017)</sup> |

## 普通形式与指数形式

普通生成函数将数列 \( (a_n)_{n \ge 0} \) 视为幂级数 \( f(x) = \sum_{n \ge 0} a_n x^n \) 的系数<sup>[3](https://www.isibang.ac.in/~d.yogesh/Course_Notes/DM1/Ch10.html)</sup>。当该级数在0的某个邻域内收敛到函数 \( F(x) \) 时，该函数也称为数列的普通生成函数；在某个指标 \( d \) 之后为零的数列，其普通生成函数就是多项式 \( \sum_{n=0}^{d} a_n x^n \)<sup>[5](https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/15.%20Generating%20Functions%20I/Generating%20Functions%20I.pdf)</sup>。

指数生成函数（EGF）将每个系数除以一个阶乘：

\[ f(x) = \sum_{n \ge 0} a_n \frac{x^n}{n!}. \]

它是计数问题的自然形式，其中大小为 \( n \) 的集合中的对象带有标号或有序，而普通生成函数适用于在某种意义下不可区分的对象<sup>[3](https://www.isibang.ac.in/~d.yogesh/Course_Notes/DM1/Ch10.html)</sup>。还存在其他标准形式：指数生成函数 \( F(x,w) = \sum_{n=0}^{\infty} a_n(x) w^n / n! \) 和形式狄利克雷级数 \( F(x,s) = \sum_{n=1}^{\infty} a_n(x) / n^s \) 都被广泛使用，而对此类级数的操作通常无论收敛与否都可以得到合理论证<sup>[7](https://encyclopediaofmath.org/wiki/Generating_function)</sup>。

## 形式级数与唯一性

生成函数通常被视为形式幂级数，即使用幂级数的代数运算规则而不考虑级数是否收敛<sup>[7](https://encyclopediaofmath.org/wiki/Generating_function)</sup>。当级数在原点附近确实收敛时，与数列的对应是一一的：若 \( G_a(s) \) 在 \( |s| < R \)（\( R > 0 \)）内解析，则

\[ a_k = \frac{1}{k!} \frac{d^k}{ds^k} G_a(s) \Big|_{s=0}, \]

因此两个生成函数在某个正半径圆盘上一致的数列必然相同<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。正是这种唯一性使得关于数列的问题可以被替换为关于函数的问题，在函数层面求解后再通过读取系数翻译回来。

## 代数应用：卷积与递推

最重要的代数性质涉及卷积 \( c_n = \sum_{k=0}^{n} a_k b_{n-k} \)：卷积的生成函数是乘积 \( G_c(s) = G_a(s) G_b(s) \)<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。直接验证颇为繁琐的卷积，由此归结为函数的乘法。一个经典应用是恒等式 \( \sum_{k=0}^{n} \binom{n}{k}^2 = \binom{2n}{n} \)，它通过将数列 \( \binom{n}{k} \) 与自身卷积得到<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。

**求解递推关系。** 生成函数为求解许多递推关系提供了机械化的方法<sup>[1](https://aofa.cs.princeton.edu/30gf/)</sup>。递推关系被重新表述为关于整个数列的生成函数 \( G(z) \) 的方程，然后通过代数方法求解<sup>[8](https://cs.yale.edu/homes/aspnes/pinewiki/GeneratingFunctions.html)</sup>。对于递推 \( a_0 = 2 \)，\( a_{n+1} = 5 a_n \)，令 \( F(x) = \sum a_n x^n \) 得 \( F(x) = 2 + 5x F(x) \)，故 \( F(x) = 2/(1-5x) \)，从而 \( a_n = 2 \cdot 5^n \)<sup>[5](https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/15.%20Generating%20Functions%20I/Generating%20Functions%20I.pdf)</sup>。同样的步骤应用于斐波那契递推 \( F_{n+1} = F_n + F_{n-1} \)（\( F_0 = 0 \)，\( F_1 = 1 \)），得到生成函数 \( F(x) = x/(1 - x - x^2) \)，经过部分分式分解后得到显式公式

\[ F_n = \frac{1}{\sqrt{5}} \left( \frac{1+\sqrt{5}}{2} \right)^n - \frac{1}{\sqrt{5}} \left( \frac{1-\sqrt{5}}{2} \right)^n. \]

<sup>[5](https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/15.%20Generating%20Functions%20I/Generating%20Functions%20I.pdf)</sup> 正是这种可直接求解的性质使生成函数在算法分析中特别有用，因为形如 \( T(n) = aT(n-1) + bT(n-2) + f(n) \) 的递推在那里经常出现<sup>[8](https://cs.yale.edu/homes/aspnes/pinewiki/GeneratingFunctions.html)</sup>。

## 概率生成函数

对于取值于 \( \{0, 1, 2, \ldots \} \) 的离散随机变量 \( X \)，概率生成函数（pgf）为 \( G_X(s) = \mathsf{E}(s^X) = \sum_{k=0}^{\infty} s^k \, \mathsf{P}(X=k) \)，即概率质量函数的普通生成函数<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。标准分布具有紧凑的形式：参数为 \( p \) 的伯努利变量有 \( G(s) = (1-p) + ps \)，二项分布 \( \mathrm{Bin}(n,p) \) 变量有 \( (1-p+ps)^n \)，泊松分布 \( \mathrm{Poi}(\lambda) \) 变量有 \( e^{\lambda(s-1)} \)<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。

两个结构性事实使概率生成函数威力强大。第一，若 \( X \) 和 \( Y \) 是 \( \{0, 1, 2, \ldots \} \) 上的独立变量，则 \( G_{X+Y}(s) = G_X(s) G_Y(s) \)；独立和的分布是两个分布的卷积，其概率生成函数是乘积<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。这立即给出封闭性质，例如参数为 \( \lambda \) 和 \( \mu \) 的独立泊松变量之和是参数为 \( \lambda + \mu \) 的泊松变量<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。第二，矩可由 \( s = 1 \) 处的导数得到：第 \( k \) 阶阶乘矩等于 \( G^{(k)}(1) \)，特别地

\[ \mathsf{Var}(X) = G_X''(1) + G_X'(1) - \bigl( G_X'(1) \bigr)^2. \]

<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup> 相关的矩生成函数为 \( M_X(t) = \mathsf{E}(e^{tX}) = G_X(e^t) \)，即矩序列 \( \mathsf{E}(X^k<sup>[15](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/04:_Expected_Value/4.06:_Generating_Functions)</sup>) \) 的指数生成函数<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。生成函数还解决了依分布收敛的问题：对于概率分布 \( a_{k,n} \) 及其生成函数 \( G_n(s) \)，\( G_n(s) \) 在 \( [0,1) \) 上逐点收敛到 \( G(s) \) 是分布收敛到 \( (a_k) \) 的充分必要条件<sup>[4](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)</sup>。

## 历史与解析组合数学

将生成函数表示为几何级数乘积的方法由欧拉在18世纪中叶研究整数分拆时引入，这一工作路线由西尔维斯特（Sylvester）和凯莱（Cayley）从1850年代中期继续推进<sup>[9](https://www.combinatorics.org/ojs/index.php/eljc/article/download/v17i1r121/pdf/)</sup>。欧拉1748年的生成函数 \( \sum p(n) q^n = 1/(q;q)_\infty \) 开创了整数分拆的数学理论<sup>[6](https://doi.org/10.1016/j.jnt.2016.01.017)</sup>。凯莱1857年关于有根无标号树的生成函数 \( T(x) = \sum t_n x^n \) 的方程隐式地定义了系数，1937年波利亚（Pólya）将该方程转化为可以应用分析技术的形式，证明了 \( t_n \sim C \rho^{-n} n^{-3/2} \)，其中 \( \rho \) 是 \( T(x) \) 的收敛半径<sup>[9](https://www.combinatorics.org/ojs/index.php/eljc/article/download/v17i1r121/pdf/)</sup>。

这一轨迹成熟为解析组合数学，它将生成函数视为复解析对象，从其奇点读取系数的渐近信息。弗拉若莱-奥德利兹科定理（Flajolet-Odlyzko theorem）被描述为该领域的瑰宝之一，它用标准尺度中的函数在主导奇点附近逼近生成函数，并逐项将展开式转化为系数的渐近<sup>[10](https://ac.cs.princeton.edu/home/)</sup>。一个基本实例是收敛半径转移定理：若 \( f(z) \) 的收敛半径严格大于1且 \( f(1) \ne 0 \)，则对实数 \( \alpha \notin \{0, -1, -2, \ldots \} \)，

\[ [z^n] \frac{f(z)}{(1-z)^\alpha} \sim \frac{f(1)}{\Gamma(\alpha)} \, n^{\alpha-1} \]

<sup>[11](https://aofa.cs.princeton.edu/50ac/)</sup>。在数列一侧，对应是精确的：一个数列是P-递推的（即满足带多项式系数的线性递推），当且仅当其普通生成函数是D-有限的（即满足带多项式系数的线性微分方程）<sup>[12](https://www-users.cse.umn.edu/~odlyzko/doc/asymptotic.enum.pdf)</sup>。从历史上看，分析一侧可追溯到拉普拉斯（Laplace），他将有限差分等离散量转化为适合鞍点逼近的积分表示；以及柯西（Cauchy）1815年的论文，将同样的问题移入复分析领域<sup>[13](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.AofA.2026.1)</sup>。

乘积形式的方法并不能推广到所有计数问题。欧拉找到了线性分拆的生成函数，麦克马洪（MacMahon）找到了平面分拆的生成函数，但长期猜测的立体分拆生成函数的乘积形式现已被证明不成立；赖特（E. M. Wright）1967年的论文转而研究了立体分拆的限制生成函数 \( \eta(a,b,c) \)<sup>[14](https://www.cambridge.org/core/journals/proceedings-of-the-royal-society-of-edinburgh-section-a-mathematics/article/abs/xiiithe-generating-function-of-solid-partitions/CDC486586BA6544EA450C74D8BCAA380)</sup>。

## References

1. [Generating Functions, Analysis of Algorithms booksite, Princeton University](https://aofa.cs.princeton.edu/30gf/)
2. [7.1: What is a Generating Function? Joy Morris, Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Combinatorics_%28Morris%29/02%3A_Enumeration/07%3A_Generating_Functions/7.01%3A_What_is_a_Generating_Function)
3. [Chapter 10: Recursions and generating functions, Discrete Mathematics lecture notes, ISI Bangalore](https://www.isibang.ac.in/~d.yogesh/Course_Notes/DM1/Ch10.html)
4. [Probability II, Section 5: Generating functions, lecture notes, Durham University](https://www.maths.dur.ac.uk/users/ostap.hryniv/teaching/Probability2/Probability2-notes.html)
5. [F. Gotti, Generating Functions I, MIT 18.211 Combinatorial Analysis](https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/15.%20Generating%20Functions%20I/Generating%20Functions%20I.pdf)
6. [Fast computation of the partition function, Journal of Number Theory (2016)](https://doi.org/10.1016/j.jnt.2016.01.017)
7. [Generating function, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Generating_function)
8. [GeneratingFunctions, class notes by James Aspnes, Yale University](https://cs.yale.edu/homes/aspnes/pinewiki/GeneratingFunctions.html)
9. [Recursively defined generating functions, Electronic Journal of Combinatorics 17 (2010), #R121](https://www.combinatorics.org/ojs/index.php/eljc/article/download/v17i1r121/pdf/)
10. [Analytic Combinatorics booksite, Philippe Flajolet and Robert Sedgewick, Princeton University](https://ac.cs.princeton.edu/home/)
11. [Analytic Combinatorics, Section 5.5: Generating Function Coefficient Asymptotics, Princeton University](https://aofa.cs.princeton.edu/50ac/)
12. [A. M. Odlyzko, Asymptotic Enumeration Methods](https://www-users.cse.umn.edu/~odlyzko/doc/asymptotic.enum.pdf)
13. [Hsien-Kuei Hwang, Laplace, Cauchy and Early Analytic Combinatorics (Flajolet Lecture), AofA 2026, LIPIcs vol. 381](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.AofA.2026.1)
14. [E. M. Wright, The Generating Function of Solid Partitions, Proceedings of the Royal Society of Edinburgh Section A 67 (1967), pp. 185-195](https://www.cambridge.org/core/journals/proceedings-of-the-royal-society-of-edinburgh-section-a-mathematics/article/abs/xiiithe-generating-function-of-solid-partitions/CDC486586BA6544EA450C74D8BCAA380)
15. [4.6: Generating Functions](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/04:_Expected_Value/4.06:_Generating_Functions)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Combinatorics › Enumerative combinatorics › Generating functions and symbolic methods › Generating functions (general)

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/generating-function

English original: https://www.edgepedia.org/generating-function
