Section 1.6 Integer Partitions
How many ways are there to partition the integer \(n\) into a sum of any number of integers (each positive), if the order of the summands is not considered to create a different sum? This is the number of partitions of \(n\) and there is no simple way to compute it. Sage uses a convergent series based on transcendental functions due originally to Rademacher in 1937. This series has been used to compute partitions of \(10^{20}\) exactly, a result requiring 11 billion decimal digits to express. See Fredrik Johansson's blog post from March 2, 2014.
As usual, we can create an object representing integer partitions, and then use it in various ways without filling our computer's memory with every single one.
The famous number theorists, Hardy and Ramanujan, were able to count exactly the number of integer partitions of \(n = 200\) in 1915. Here is the result, which is nearly four trillion.
Your results will vary, but in my case, Sage can do this computation at the rate of roughly 250 times a second. You can cautiously try some larger integers, at around \(10^{12}\) you may begin to get impatient. Once the output gets too large, you can remove the request to print the result.
An application may require an integer partition with a specific number of parts. You can accomplish this with the length
keyword. So the number of integer partitions of \(30\) into exactly \(10\) (unordered) parts is computed as follows.