Stirling Numbers and Partition Functions

Stirling numbers count the ways to partition or arrange sets, bridging factorials, powers, and combinatorics. The Stirling numbers of the first kind count permutations by cycles; the second kind count set partitions into blocks. Together with the Bell numbers and partition function , they form the backbone of enumerative combinatorics. Studied by James Stirling (1730), with deep ties to Euler, Bell, and Hardy–Ramanujan.

Stirling numbers are two families of integers that mediate between the ordinary power basis and the falling-factorial basis . The second-kind numbers count the partitions of an -element set into exactly nonempty unlabeled blocks; the first-kind numbers count permutations of elements with exactly cycles. Their row sums give the Bell numbers (total set partitions), while the integer-partition function counts unordered ways to write as a sum of positive integers — a superficially similar but profoundly different problem. The surprising fact: although has no simple closed form, its asymptotics were pinned down exactly by Hardy and Ramanujan using analysis, not counting.

The Core Insight

A power counts functions; a falling factorial counts injections. Stirling numbers are precisely the change-of-basis coefficients between these two natural polynomial bases. The combinatorial meaning (cycles, blocks) emerges automatically because the algebra of the bases encodes the act of "choosing and grouping." All of Stirling theory is the dictionary between this algebraic fact and its counting shadow.

Formal Statement

Stirling Numbers of the Second Kind

(also written ) is the number of ways to partition a set of distinguishable objects into exactly nonempty, unlabeled, disjoint blocks. By convention , for , and for .
1
⟳Count functions from to two ways — total functions give ; classify by the image of size , choose the image ( as ) and partition the domain ().
2
⟳Inclusion–exclusion on surjections from onto ; the number of surjections is , and we subtract maps missing chosen target elements.

Stirling Numbers of the First Kind

The unsigned Stirling numbers of the first kind count the permutations of elements having exactly disjoint cycles. The signed version provides the inverse change of basis.

3
⟳Expand the rising factorial product; the coefficient of collects terms picking the "" factor from of the binomials, and the integer products correspond to cycle-counting via the cycle lemma.
4
⟳Replace in [3] and factor out ; matching signs forces .

Bell Numbers

The Bell number counts all set partitions of regardless of block count:

5
⟳First sum is by definition of total partitions; the recurrence classifies partitions by the block containing element , choosing its companions and partitioning the rest.

Integer Partition Function

The partition function counts the unordered ways to write as a sum of positive integers (parts). Order does not matter: gives .

6
⟳Each factor chooses how many parts equal ; the product over all enumerates every partition exactly once by its part-multiplicities.

Triangular Recurrences

Both Stirling families satisfy Pascal-like recurrences:

7
⟳Element either joins one of the existing blocks () or forms a new singleton block ().
8
⟳Element either is inserted into one of positions within existing cycles () or starts its own 1-cycle ().

Why It Holds / Derivation

:::proof[Equation [2]: closed form for ] We count surjections in two ways.

  1. Direct via partitions. A surjection is determined by a partition of into nonempty blocks (the fibers ) together with a bijection assigning blocks to the labeled targets. Thus the number of surjections equals .
  1. Inclusion–exclusion. Let be the set of functions that miss target . The surjections are functions in none of the . Total functions number . By inclusion–exclusion,
since choosing forbidden targets leaves functions into the remaining values.
  1. Equate and solve. Setting equal to the inclusion–exclusion sum and dividing by yields [2].

:::proof[Equation [7]: recurrence for ]

  1. Take any partition of into blocks. Focus on the element .
  2. Case A — is alone. Removing the singleton leaves a partition of into blocks: choices.
  3. Case B — shares a block. Removing leaves a partition of into blocks; conversely could have been placed in any of these blocks: choices.
  4. The cases are disjoint and exhaustive, giving [7].

James Stirling | 1692–1770

A Scottish mathematician educated at Oxford and Venice, Stirling published Methodus Differentialis (1730), the work that introduced these numbers as coefficients in interpolation series. Though best remembered today for Stirling's approximation , his deeper contribution was the systematic study of the finite-difference calculus — the algebra of falling factorials in which his namesake numbers naturally appear. His career was marked by political exile (Jacobite associations) and later work managing Scottish mining operations.

Building Intuition

Think of and as two languages for the same combinatorial reality. The "power" language counts all functions from an -set into an -set — it allows collisions, repetitions, freedom. The "falling factorial" language counts injections — strict, no collisions. To translate "free" into "strict," you must account for collisions, and that bookkeeping is the Stirling number: tells you how many collision-patterns group your inputs into distinct output-classes.

For the first kind, picture writing a permutation in cycle notation. Each permutation of decomposes uniquely into cycles, and simply tallies those with loops. The recurrence [8] is the act of "inserting the newest dancer" into a circle dance: either you slot them between two existing dancers (anywhere among the gaps) or you start a brand-new solo circle.

For the integer partition , abandon labels entirely — the parts are indistinguishable lumps. This loss of structure is exactly why resists a clean formula while the labeled and have tidy ones.

Stirling's triangle for S(n,k): each entry is k·(above) + (above-left)

Stirling numbers of the 2nd kind S(n,k) n\k 0 1 2 3 4 5 0 1 1 0 1 2 0 1 1 3 0 1 3 1 4 0 1 7 6 1 5 0 1 15 25 10 1 S(4,2) = 2·S(3,2) + S(3,1) = 2·3 + 1 = 7

Worked Examples

Counting surjections with $S(n,k)$

Given: How many ways can 5 distinct toys be distributed to 3 distinct children so that every child gets at least one toy? Steps:
  1. This is the number of surjections , which equals .
  2. Compute via formula [2]:
  1. Evaluate: , , . So
  2. Multiply by to label the children: .
Answer:

Bell number and integer partition compared

Given: For , compute (a) the Bell number (set partitions) and (b) the integer-partition count . Steps (a): Sum the row from the triangle: . So .

Check via recurrence [5]: ✓

Steps (b): List partitions of the integer 4 (unlabeled): . That is 5. Answer:

The dramatic gap — 15 versus 5 — quantifies how much information labels carry.

Common Misconceptions

Set partitions ≠ integer partitions. The Bell number counts ways to partition a labeled set into blocks; the partition function counts ways to break the integer into summands. They answer entirely different questions and grow at different rates ( super-exponentially, sub-exponentially). Confusing them is the single most common error in this topic. Sign conventions for the first kind differ between texts. Some authors define as the signed Stirling number (used in [4]), others reserve for the unsigned count of permutations by cycles. Always verify which family a formula uses; the relation is , so signs alternate down each row. " is symmetric like the binomial coefficient." False. Pascal's triangle is symmetric (), but Stirling triangles are not. For instance but — no symmetry. The reason: the recurrence [7] has the asymmetric weight on one term, breaking the left–right balance that produces binomial symmetry.

Connections

Stirling numbers are the hinge between several core areas. The change-of-basis equations [1]–[4] connect them to Finite Difference Calculus, where converts ordinary powers into falling factorials that the difference operator treats like derivatives. Their generating functions tie into Exponential Generating Functions: and . The first-kind numbers relate directly to the cycle structure studied in Symmetric Group and to the Gamma Function through rising factorials. The integer partition function opens into Generating Functions and the deep analytic theory of Modular Forms via Dedekind's eta function.

Real-World Applications

  1. Computer science — Bell numbers in clustering. Counting all possible groupings of data points equals , the size of the search space for partition-based clustering and the number of equivalence relations on a set.
  2. Numerical analysis — Newton forward-difference interpolation. Equation [1] is the engine that rewrites tabulated polynomial data in the falling-factorial basis, the foundation of finite-difference interpolation tables.
  3. Probability — moments of the Poisson distribution. The -th moment of a Poisson() variable equals (Dobinski's formula gives at ), used in actuarial and queueing models.
  4. Statistical mechanics — counting microstates. Distributing indistinguishable energy quanta among levels uses integer partitions ; distributing distinguishable particles into occupied states uses Stirling numbers.
  5. Cryptography & combinatorial design — surjection counting. The number of "onto" hash configurations or balanced assignments is , used in coupon-collector and load-balancing analyses.
  6. Quantum field theory — normal ordering. Converting between ordinary and normal-ordered products of creation/annihilation operators introduces exactly the Stirling numbers as coefficients (the "Stirling identity for the number operator").
  7. Phylogenetics — counting tree topologies and labelings. Partition structures and Bell numbers enumerate possible ancestral groupings of species.

Historical Development

  • 1730 — James Stirling publishes Methodus Differentialis, introducing both families as interpolation coefficients.
  • 1740s — Leonhard Euler studies the generating function for and proves the celebrated pentagonal number theorem, giving a fast recurrence for partitions.
  • 1859 — G. Dobinski derives his formula , expressing Bell numbers as a Poisson moment.
  • 1877 — The cycle interpretation of first-kind numbers is clarified within the developing theory of permutation groups.
  • 1918 — G. H. Hardy and Srinivasa Ramanujan establish the asymptotic formula for via the circle method, a landmark of analytic number theory.
  • 1934 — Eric Temple Bell systematizes the numbers now bearing his name in his paper on "exponential polynomials."
  • 1937 — Hans Rademacher converts the Hardy–Ramanujan asymptotic into an exact convergent series for .
  • 1974 — Knuth, Graham, and Patashnik later popularize the bracket/brace notation , in Concrete Mathematics, unifying the field's conventions.
  • 2011 — Ken Ono and collaborators discover that partition numbers exhibit fractal congruence structure governed by modular forms, vindicating Ramanujan's mysterious congruences .

Subtleties & Limits

While and have explicit closed forms, the integer partition function does not — Rademacher's exact formula is an infinite convergent series, not a finite expression. Ramanujan's congruences (, , ) are now understood via modular forms, yet a full classification of all such congruences, and a transparent combinatorial (bijective) explanation of even the mod-5 case, remains an active research frontier. The deep mystery is why a purely additive counting problem should be controlled by the symmetry-rich world of modular forms — a connection still being mined.

See Also

Bell Numbers · Pentagonal Number Theorem · Catalan Numbers · Symmetric Group · Hardy–Ramanujan Asymptotics · Dobinski Formula · Falling and Rising Factorials

Before this

Where this leads