Combinatorics
Partition Function p(n)
p(n) = number of ways to write n = a₁ + a₂ + … + aₖ with a_i ≥ a_{i+1} ≥ 1 — Hardy-Ramanujan asymptotic
The partition function p(n) counts the number of ways to write a positive integer n as an unordered sum of positive integers. p(0) = 1, p(1) = 1, p(2) = 2 (2, 1+1), p(3) = 3, p(4) = 5, p(5) = 7, …, p(100) = 190,569,292. Euler's generating function: Σ p(n) x^n = ∏_{k=1}^∞ 1/(1 − x^k). Hardy-Ramanujan asymptotic (1918): p(n) ~ (1/(4n√3)) · e^(π√(2n/3)). Ramanujan's congruences: p(5n+4) ≡ 0 (mod 5), p(7n+5) ≡ 0 (mod 7), p(11n+6) ≡ 0 (mod 11). Connections to modular forms (Hardy-Littlewood circle method), the Jacobi triple product identity, and statistical mechanics. Key example of asymptotic combinatorics — the partition function grows sub-exponentially.
- Definitionp(n): integer partitions of n
- Generating fn∏ 1/(1 − x^k)
- p(100)190,569,292
- Asymptotice^(π√(2n/3)) / (4n√3)
- Ramanujanp(5n+4) ≡ 0 mod 5
- Connects toModular forms, Rogers-Ramanujan
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
Why the partition function matters
The partition function is a perfect compact example of how a simple-looking counting problem opens onto modular forms, analytic number theory, asymptotic combinatorics, and statistical mechanics. Each layer reveals more structure than the previous; the sequence p(n) is the entry point.
- Combinatorics. Partitions are the fundamental ordered-versus-unordered counting object, side by side with compositions, multisets, and Young tableaux. The Robinson-Schensted-Knuth correspondence sets up bijections between matrices, pairs of Young tableaux, and permutation patterns — partition shapes parametrize the entire theory.
- Modular forms. The Dedekind eta function η(τ) = q^{1/24} ∏(1 − q^k) makes 1/η a near-modular generating function for partitions; the modular transformation laws of η give Hardy-Ramanujan-Rademacher exact formulas for p(n) and force Ramanujan's congruences mod 5, 7, 11.
- Statistical mechanics. The grand canonical partition function for non-interacting bosons confined to integer-energy levels is exactly Σ p(n) e^{−βn}; the partition function in physics borrowed both name and structure from the combinatorial original. Bose-Einstein condensation, gap statistics in random matrix theory, and Hagedorn temperature all use partition asymptotics.
- Asymptotic analysis. The Hardy-Ramanujan circle method — bound the integrand on a Farey-sequence dissection of the unit circle, identify the dominant arcs near rational points — was developed for p(n) and is now a workhorse for sums in additive number theory (Goldbach, Waring, Vinogradov).
- Number theory and arithmetic of congruences. Ramanujan's congruences led to deep developments — Atkin-Lehner theory, l-adic Galois representations, Ono's work on infinite families of partition congruences for primes p ≥ 13. The Bringmann-Ono theory of mock modular forms generalizes the framework.
- Algorithms. Coin-change and subset-sum problems are partition-style counts. Dynamic-programming algorithms for these problems mirror the recursion that builds up the partition table; the same DP solves "minimum coins for amount n" and many scheduling problems.
- Random partitions. Plancherel measure on Young diagrams (probability proportional to (dim λ)² / n!) gives a random partition; Vershik-Kerov shows the limit shape converges to a deterministic curve, with fluctuations governed by the Airy process. Connections to random matrix theory and the longest-increasing-subsequence problem.
Small values and growth
Reading partitions of small n gives a sense of how the count grows.
- p(0) = 1 (the empty partition).
- p(1) = 1: {1}.
- p(2) = 2: {2}, {1+1}.
- p(3) = 3: {3}, {2+1}, {1+1+1}.
- p(4) = 5: {4}, {3+1}, {2+2}, {2+1+1}, {1+1+1+1}.
- p(5) = 7.
- p(10) = 42.
- p(20) = 627.
- p(50) = 204,226.
- p(100) = 190,569,292.
- p(1000) ≈ 2.4 × 10^31.
- p(10000) ≈ 3.6 × 10^106.
The growth is sub-exponential: p(n) increases faster than any polynomial but much slower than 2^n. The Hardy-Ramanujan asymptotic e^(π √(2n/3)) / (4n√3) gives the leading-order rate.
The Euler generating function
Euler observed that listing the contribution of each part size k separately and then convolving gives:
Σ_{n ≥ 0} p(n) x^n = ∏_{k = 1}^{∞} 1/(1 − x^k).
The k-th factor 1 + x^k + x^{2k} + x^{3k} + ⋯ encodes "how many parts of size k". The product expansion picks one term from each factor, contributing total Σ (multiplicity of k) · k summed across k = 1, 2, …. Reading the coefficient of x^n collects all such contributions whose total is n — that is, all partitions of n.
Variations:
- Partitions into distinct parts: Σ p_d(n) x^n = ∏ (1 + x^k).
- Partitions into odd parts: Σ p_o(n) x^n = ∏ 1/(1 − x^{2k−1}).
- Euler's identity p_d(n) = p_o(n) — the number of partitions into distinct parts equals the number into odd parts. Bijection: write each part m of an odd-only partition as m · 2^j; collect distinct (m · 2^j).
- Restricted partitions p(n, k): parts ≤ k, generating function ∏_{j=1}^{k} 1/(1 − x^j).
Euler's pentagonal recursion
Euler's pentagonal number theorem ∏(1 − x^k) = Σ_{j ∈ ℤ} (−1)^j x^{j(3j − 1)/2} gives a clean recursion for p(n):
p(n) = p(n − 1) + p(n − 2) − p(n − 5) − p(n − 7) + p(n − 12) + p(n − 15) − ⋯
The offsets are the generalized pentagonal numbers ω(j) = j(3j − 1)/2 for j = ±1, ±2, ±3, …, namely 1, 2, 5, 7, 12, 15, 22, 26, …; signs alternate in pairs. This recursion computes p(n) in O(n √n) time — fast enough to tabulate billions of values.
The Hardy-Ramanujan circle method
To prove the asymptotic, write p(n) as a contour integral around the origin:
p(n) = (1 / 2πi) ∮ (1 / x^{n+1}) · ∏_{k} 1/(1 − x^k) dx.
The integrand has its biggest singularity at x = 1; near x = 1 the η-function modular transformation gives an asymptotic. Hardy and Ramanujan dissect the unit circle into Farey arcs near each rational point e^{2πi h/k}, evaluate the integrand on each arc using the η transformation under SL(2, ℤ), and sum. The dominant contribution from x = 1 gives the leading asymptotic; subleading contributions from x = e^{2πi/q} and beyond give the Hardy-Ramanujan-Rademacher exact convergent series. This was the birth of the modern circle method.
Ramanujan's congruences
Ramanujan computed the first few hundred values of p(n) by hand and noticed:
- p(5n + 4) ≡ 0 (mod 5). E.g. p(4) = 5; p(9) = 30; p(14) = 135; p(19) = 490.
- p(7n + 5) ≡ 0 (mod 7). E.g. p(5) = 7; p(12) = 77; p(19) = 490; p(26) = 2436.
- p(11n + 6) ≡ 0 (mod 11). E.g. p(6) = 11; p(17) = 297; p(28) = 3718.
He conjectured higher-power refinements: p(5^a · 7^b · 11^c · n + r) ≡ 0 (mod 5^a · 7^b · 11^c) for some r depending on a, b, c. Most of these were proved by Watson (1938) and Atkin (1967); some refinements failed for higher 7-powers and were corrected by Atkin-Garvan-Ono. Ono (2000) proved that for every prime p ≥ 5 there are infinitely many congruences p(an + b) ≡ 0 (mod p^k) for some a, b, k — a vast generalization beyond the original three.
Common misconceptions
- "p(n) is polynomial." It grows sub-exponentially as e^(π√(2n/3)) / (4n√3); polynomial bounds are vastly too small. p(100) is already 190 million; a polynomial of degree d would give n^d ≈ 100^d.
- "p ~ 2^n." Compositions of n number 2^(n−1) (each gap between adjacent 1's gets a comma or not). Partitions are much fewer because order does not matter — p(n) grows exponentially in √n, not n.
- "Easy to enumerate." Listing p(50) = 204,226 partitions takes meaningful time; p(1000) is 10^31 partitions, far beyond physical enumeration. The recursion computes p(n) without listing the partitions.
- "Partitions and compositions are the same." Compositions are ordered, partitions unordered. 2 + 1 and 1 + 2 are the same partition (both have parts {2, 1}) but different compositions.
- "Ramanujan congruences exist for every prime." Ramanujan's three were special — only primes p = 5, 7, 11 admit single-progression congruences for p(n). For p ≥ 13, congruences are still infinite (Ono) but more subtle and require refining moduli.
- "Hardy-Ramanujan asymptotic is approximate." Hardy-Ramanujan gives the leading term; Hardy-Ramanujan-Rademacher gives a convergent exact series — the n-th partial sum produces p(n) exactly when truncated correctly. So "asymptotic" undersells: it's an exact convergent expansion.
Frequently asked questions
How is p(n) computed?
Three main routes. (1) Euler's pentagonal number theorem gives the recursion p(n) = p(n − 1) + p(n − 2) − p(n − 5) − p(n − 7) + p(n − 12) + p(n − 15) − ⋯ where the offsets are the generalized pentagonal numbers k(3k ± 1)/2 with alternating signs in pairs. This is fast — O(n^{3/2}) time. (2) The Euler generating function ∏ 1/(1 − x^k) can be expanded by repeatedly applying the geometric series and convolving — slower. (3) For very large n, the Hardy-Ramanujan-Rademacher exact formula gives p(n) as a convergent series of trigonometric / Bessel-function terms; truncating gives the integer p(n) exactly. p(100) = 190,569,292; p(1000) ≈ 2.4 × 10^31.
What is the Euler generating function?
Σ_{n ≥ 0} p(n) x^n = ∏_{k=1}^{∞} 1/(1 − x^k). Each factor 1/(1 − x^k) = 1 + x^k + x^{2k} + x^{3k} + ⋯ contributes the choice "how many copies of part k appear in the partition"; multiplying over k = 1, 2, 3, … and reading the coefficient of x^n gives p(n). This product is the simplest example of a "multiplicative partition" generating function and is the prototype for q-series, the η-function ∏(1 − q^k), and modular forms. Variations: p_d(n) (partitions into distinct parts) has g.f. ∏(1 + x^k); p_o(n) (parts odd only) has g.f. ∏ 1/(1 − x^{2k−1}). Euler's pairing identity p_d(n) = p_o(n) is a classical bijection.
What is the Hardy-Ramanujan asymptotic?
Hardy and Ramanujan (1918) proved p(n) ~ (1/(4n√3)) · exp(π √(2n/3)) as n → ∞. The leading exponent π √(2n/3) reflects sub-exponential growth — faster than any polynomial but much slower than 2^n or n!. The constant 1/(4n√3) is the order-of-magnitude prefactor; full Hardy-Ramanujan-Rademacher gives an exact convergent series with this leading term. Numerically: p(100) ≈ 199 million, asymptotic predicts ≈ 199.3 million — about 0.4% off. Higher-order corrections shrink the error like O(1/√n). The proof uses the circle method on the modular η-function — saddle-point analysis on the contour integral.
What are Ramanujan's congruences?
Three remarkable mod-prime congruences for the partition function: p(5n + 4) ≡ 0 (mod 5), p(7n + 5) ≡ 0 (mod 7), and p(11n + 6) ≡ 0 (mod 11). Discovered by Ramanujan from the partition table he had laboriously computed; he conjectured a family of further mod p^k extensions. Examples: p(4) = 5; p(9) = 30 (divisible by 5); p(14) = 135 (divisible by 5). p(5) = 7; p(12) = 77 (divisible by 7). The proofs use modular forms — η-quotients with weight and level chosen to detect the divisibility. Ahlgren-Boylan (2003) showed the only such congruences with small primes are these three and their refinements; Ono (2000) found infinite families for larger primes.
How do partitions relate to modular forms?
The Dedekind eta function η(τ) = q^{1/24} ∏_{k ≥ 1} (1 − q^k) where q = e^{2πi τ} is a modular form of weight 1/2 (under suitable refinement). Reciprocally, 1/η(τ) = q^{−1/24} Σ p(n) q^n — the partition generating function multiplied by a fractional q-power. Modular transformation laws of η give exact formulas (Hardy-Ramanujan-Rademacher) for p(n) by the circle method, and the symmetries q → e^{2πi/p} q underlie Ramanujan's congruences. The interplay of partitions with modular forms is a central case study in the modern subject — Atkin-Lehner theory, eta-quotients, and Ono's work on l-adic Galois representations all start here.
What's the difference between partitions and compositions?
A partition of n is an unordered representation as a sum of positive integers: 1 + 1 + 2 and 2 + 1 + 1 are the same partition. A composition of n is an ordered sum: 1 + 1 + 2 ≠ 1 + 2 + 1 ≠ 2 + 1 + 1 are three different compositions. The number of compositions of n is 2^(n−1) — between any two consecutive 1's in the unary representation 1 + 1 + ⋯ + 1 you choose "comma" or "no comma". The partition count p(n) is much smaller and grows sub-exponentially. Compositions count weak compositions if zero parts are allowed; partitions count is invariant under part relabeling. Generating functions reflect this: 1/(1 − x − x^2 − ⋯) for compositions vs ∏ 1/(1 − x^k) for partitions.