Integer Partitions and the Work of Hardy and Ramanujan
Count the ways to write a number as a sum, then see Euler's recursion, Hardy and Ramanujan's estimate and striking congruences.
Key takeaways
- A partition ignores order, so 3 + 1 and 1 + 3 count once.
- The values p(1) to p(10) are 1, 2, 3, 5, 7, 11, 15, 22, 30 and 42, and p(100) exceeds 190 million.
- Euler found an infinite product for all the p(n) at once and a fast recursion using pentagonal numbers.
- Hardy and Ramanujan showed in 1918 that p(n) is approximately e^(π√(2n/3)) divided by 4n√3.
- Ramanujan discovered that p(5k + 4) is always divisible by 5, with companion patterns for 7 and 11.
A partition of a positive whole number is a way of writing it as a sum of positive whole numbers, where order does not matter. The number 4 has five partitions: 4, 3 + 1, 2 + 2, 2 + 1 + 1 and 1 + 1 + 1 + 1. We write p(4) = 5.
The question "how many partitions does n have?" is easy to state and surprisingly hard to answer. There is no simple product formula. The work of G. H. Hardy and Srinivasa Ramanujan in the 1910s gave a remarkably accurate estimate and opened methods that number theorists still use.
Counting by hand
The safest way to list partitions is to write each sum with parts in decreasing order, then work through the choices for the largest part. For 6:
6
5+1
4+2 4+1+1
3+3 3+2+1 3+1+1+1
2+2+2 2+2+1+1 2+1+1+1+1
1+1+1+1+1+1 That is 11 partitions, so p(6) = 11. By convention p(0) = 1, counting the empty sum.
Do not confuse partitions with compositions, where order counts. The number 4 has 8 compositions but only 5 partitions. Compositions are easy to count (there are 2ⁿ⁻¹), and the difficulty of partitions comes from ignoring order.
Dot diagrams
Draw each part as a row of dots, longest on top. This is called a Ferrers diagram. For 4 + 2 + 1 you get rows of four, two and one.
Now read the same picture by columns. The columns have heights 3, 2, 1 and 1, giving 3 + 2 + 1 + 1, another partition of 7. This flip is called conjugation.
Conjugation proves a theorem for free. The number of partitions of n into at most k parts equals the number of partitions of n into parts no larger than k, because flipping the diagram turns one kind into the other.
A recursion by largest part
Before any clever theory, there is a dependable way to compute. Let p(n, k) be the number of partitions of n into parts no larger than k. Every such partition either uses at least one k or uses none.
If it uses a k, removing one copy leaves a partition of n − k into parts at most k. If it uses none, it is a partition of n into parts at most k − 1. So
p(n, k) = p(n − k, k) + p(n, k − 1) The starting values are p(0, k) = 1, p(n, 0) = 0 for n > 0, and p(n, k) = 0 for negative n.
| Largest part allowed | n = 1 | n = 2 | n = 3 | n = 4 | n = 5 | n = 6 |
|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 2 | 1 | 2 | 2 | 3 | 3 | 4 |
| 3 | 1 | 2 | 3 | 4 | 5 | 7 |
| 4 | 1 | 2 | 3 | 5 | 6 | 9 |
To fill the entry for n = 6 with parts at most 3, add p(3, 3) = 3 to p(6, 2) = 4, giving 7.
This is the same table you would use to count the ways of paying an amount with coins, if coins of every value 1 to k existed and the order of coins did not matter. Restricting the allowed parts to real coin values changes the numbers but not the method.
Euler's product
Euler noticed that a single infinite product keeps track of every partition. For each possible part size k, you decide how many copies to use: none, one, two and so on. That choice is recorded by 1 + x^k + x^(2k) + ..., which equals 1/(1 − x^k) when |x| < 1.
p(0) + p(1)x + p(2)x² + p(3)x³ + ...
= 1/(1 − x) × 1/(1 − x²) × 1/(1 − x³) × ... Multiplying out, the coefficient of xⁿ counts the ways to choose parts adding to n. This is a model use of generating functions.
With it Euler proved that the number of partitions into distinct parts equals the number into odd parts. For 6, the distinct-part list is 6, 5 + 1, 4 + 2, 3 + 2 + 1, and the odd-part list is 5 + 1, 3 + 3, 3 + 1 + 1 + 1, 1 + 1 + 1 + 1 + 1 + 1. Both have four.
Why odd and distinct parts match
Euler's proof takes two lines with products. Partitions into distinct parts are generated by multiplying factors (1 + x^k), since each part is used once or not at all. Each factor can be rewritten:
1 + x^k = (1 − x^(2k)) / (1 − x^k)
(1+x)(1+x²)(1+x³)...
= (1−x²)/(1−x) × (1−x⁴)/(1−x²) × (1−x⁶)/(1−x³) × ...
= 1 / ((1−x)(1−x³)(1−x⁵)...) Every factor with an even exponent on top cancels one underneath, leaving only odd exponents in the denominator. That is the product for partitions into odd parts.
There is also a hands-on version. Start with a partition into odd parts. Whenever two parts are equal, merge them into one part of double the size, and repeat until all parts differ. From 3 + 1 + 1 + 1 you get 3 + 2 + 1. From six 1s you get 2 + 2 + 2, then 4 + 2.
The process can be reversed by splitting every even part into halves until only odd parts remain, so it is a perfect pairing.
The pentagonal number recursion
Euler also expanded the product of (1 − x)(1 − x²)(1 − x³)... and found that nearly all terms cancel. Those that survive sit at exponents 0, 1, 2, 5, 7, 12, 15, the generalized pentagonal numbers described under figurate numbers.
The result is a recursion with signs in the pattern plus, plus, minus, minus:
p(n) = p(n−1) + p(n−2) − p(n−5) − p(n−7) + p(n−12) + p(n−15) − ...
(stop when the argument becomes negative)
p(7) = p(6) + p(5) − p(2) − p(0) = 11 + 7 − 2 − 1 = 15
p(10) = p(9) + p(8) − p(5) − p(3) = 30 + 22 − 7 − 3 = 42 Percy MacMahon used this method to compute p(n) by hand up to n = 200, reaching p(200) = 3,972,999,029,388.
The Hardy and Ramanujan estimate
Ramanujan, largely self-taught in South India, wrote to Hardy at Cambridge in 1913 and traveled to England the following year. Their partnership is described in Ramanujan and Hardy.
Their 1918 paper showed that, as n grows,
p(n) ~ e^(π √(2n/3)) / (4n √3) The symbol ~ means that the ratio of the two sides tends to 1. At n = 100 the formula gives about 199 million, while the true value is 190,569,292. The estimate is high by under 5%.
They went further than this first term. By adding a limited number of correction terms, they could obtain p(200) so precisely that rounding to the nearest whole number gave the exact answer. In 1937 Hans Rademacher modified the method to produce an infinite series that converges to p(n) exactly.
How fast p(n) grows
The growth of partitions sits between two familiar kinds. It is faster than any fixed power of n, yet slower than exponential growth such as 2ⁿ.
| n | p(n) | Compositions, 2ⁿ⁻¹ |
|---|---|---|
| 5 | 7 | 16 |
| 10 | 42 | 512 |
| 20 | 627 | 524,288 |
| 50 | 204,226 | about 563 trillion |
The reason is visible in the formula: the exponent contains √n, not n. To get an exponent twice as large you must make n four times as large.
For the same reason, listing partitions stops being practical long before computing p(n) does. The pentagonal recursion needs only about the square root of n earlier values (times a small constant) for each new one, so a short program can tabulate thousands of values. It does need whole-number arithmetic with unlimited digits, since the results soon exceed what ordinary machine integers hold.
A reasonable programming exercise is to implement both recursions, compare their outputs for n up to 100 and then compare the results with the asymptotic formula. Watch the ratio of estimate to truth drift down toward 1, slowly.
The circle method
The technique treats the product as a function of a complex number x with |x| < 1. Cauchy's formula recovers p(n) as an integral around a circle inside that region.
The function becomes enormous near the unit circle, especially near x = 1, then near x = −1, then near the cube roots of unity, and so on. Each such point contributes a term, and the largest contributions give the estimate.
Hardy and J. E. Littlewood developed this circle method into a general tool for additive questions, including Waring's problem on sums of powers.
Ramanujan's congruences
Studying MacMahon's table, Ramanujan saw patterns of divisibility:
| Rule | Examples |
|---|---|
| p(5k + 4) is divisible by 5 | p(4) = 5, p(9) = 30, p(14) = 135 |
| p(7k + 5) is divisible by 7 | p(5) = 7, p(12) = 77 |
| p(11k + 6) is divisible by 11 | p(6) = 11, p(17) = 297 |
He proved cases of these and conjectured extensions to higher powers, some of which needed correction and were settled later.
In 1944 Freeman Dyson, then a student, suggested a way to see the first two. Define the rank of a partition as its largest part minus its number of parts. Sorting by the remainder of the rank on division by 5 appeared to split the partitions of 5k + 4 into five equal groups, and similarly for 7. A. O. L. Atkin and Peter Swinnerton-Dyer proved this in the 1950s. Dyson also predicted a further statistic, the crank, that would handle 11. George Andrews and Frank Garvan found it in 1988.
Open questions and where partitions appear
Basic questions remain. For example, p(n) seems to be even about as often as it is odd, yet this had not been proved as of the mid-2020s. Check current literature before relying on that status.
Partitions also appear beyond number theory. In physics they count the ways a fixed amount of energy can be shared among identical vibrations. In algebra they index the basic representations of the group of all rearrangements of n objects.
To practice, check conjugation on all partitions of 6, then confirm that p(8) = 22 with the recursion: p(7) + p(6) − p(3) − p(1) = 15 + 11 − 3 − 1.