Partition function (number theory)

In number theory, the partition function $p(n)$ represents the number of possible partitions of a non-negative integer $n$. For instance, $p(4) = 5$ because the integer 4 has the five partitions $1 + 1 + 1 + 1$, $1 + 1 + 2$, $1 + 3$, $2 + 2$, and $4$.

No closed-form expression for the partition function is known, but it has both asymptotic expansions that accurately approximate it and recurrence relations by which it can be calculated exactly. It grows as an exponential function of the square root of its argument. The multiplicative inverse of its generating function is the Euler function; by Euler's pentagonal number theorem this function is an alternating sum of pentagonal number powers of its argument.

Srinivasa Ramanujan first discovered that the partition function has nontrivial patterns in modular arithmetic, now known as Ramanujan's congruences. For instance, whenever the decimal representation of $n$ ends in the digit 4 or 9, the number of partitions of $n$ will be divisible by 5.

Definition and examples
For a positive integer $n$, $p(n)$ is the number of distinct ways of representing $n$ as a sum of positive integers. For the purposes of this definition, the order of the terms in the sum is irrelevant: two sums with the same terms in a different order are not considered to be distinct.

By convention $p(0) = 1$, as there is one way (the empty sum) of representing zero as a sum of positive integers. Furthermore $p(n) = 0$ when $n$ is negative.

The first few values of the partition function, starting with $p(0) = 1$, are:

Some exact values of $p(n)$ for larger values of $n$ include: $$\begin{align} p(100) &= 190,\!569,\!292\\ p(1000) &= 24,\!061,\!467,\!864,\!032,\!622,\!473,\!692,\!149,\!727,\!991 \approx 2.40615\times 10^{31}\\ p(10000) &= 36,\!167,\!251,\!325,\!\dots,\!906,\!916,\!435,\!144 \approx 3.61673\times 10^{106} \end{align}$$

Generating function


The generating function for p(n) is given by $$\begin{align} \sum_{n=0}^\infty p(n)x^n &= \prod_{k=1}^\infty \left(\frac {1}{1-x^k} \right)\\ &=\left(1+x+x^2+x^3+\cdots\right) \left(1+x^2+x^4+x^6+\cdots\right) \left(1+x^3+x^6+x^9+\cdots\right) \cdots \\ &=\frac{1}{1 - x - x^2 + x^5 + x^7 - x^{12} - x^{15} + x^{22} + x^{26} - \cdots}\\ &=1 \Big/ \sum_{k=-\infty}^{\infty} (-1)^k x^{k(3k-1)/2}. \end{align}$$ The equality between the products on the first and second lines of this formula is obtained by expanding each factor $$1/(1-x^k)$$ into the geometric series $$(1+x^k+x^{2k}+x^{3k}+\cdots).$$ To see that the expanded product equals the sum on the first line, apply the distributive law to the product. This expands the product into a sum of monomials of the form $$x^{a_1} x^{2a_2} x^{3a_3} \cdots$$ for some sequence of coefficients $$a_i$$, only finitely many of which can be non-zero. The exponent of the term is $n = \sum i a_i$, and this sum can be interpreted as a representation of $$n$$ as a partition into $$a_i$$ copies of each number $$i$$. Therefore, the number of terms of the product that have exponent $$n$$ is exactly $$p(n)$$, the same as the coefficient of $$x^n$$ in the sum on the left. Therefore, the sum equals the product.

The function that appears in the denominator in the third and fourth lines of the formula is the Euler function. The equality between the product on the first line and the formulas in the third and fourth lines is Euler's pentagonal number theorem. The exponents of $$x$$ in these lines are the pentagonal numbers $$P_k = k(3k-1)/2$$ for $$k \in \{ 0, 1,-1,2,-2,\dots\}$$ (generalized somewhat from the usual pentagonal numbers, which come from the same formula for the positive values of $$k$$). The pattern of positive and negative signs in the third line comes from the term $$(-1)^k$$ in the fourth line: even choices of $$k$$ produce positive terms, and odd choices produce negative terms.

More generally, the generating function for the partitions of $$n$$ into numbers selected from a set $$A$$ of positive integers can be found by taking only those terms in the first product for which $$k\in A$$. This result is due to Leonhard Euler. The formulation of Euler's generating function is a special case of a $q$-Pochhammer symbol and is similar to the product formulation of many modular forms, and specifically the Dedekind eta function.

Recurrence relations
The same sequence of pentagonal numbers appears in a recurrence relation for the partition function:

$$\begin{align} p(n) &= \sum_{k \in \Z\setminus\{0\}} (-1)^{k+1} p(n-k(3k-1)/2) \\ &= p(n-1) + p(n-2)-p(n-5)-p(n-7) +p(n-12) +p(n-15) - p(n-22) -\cdots \end{align}$$ As base cases, $$p(0)$$ is taken to equal $$1$$, and $$p(k)$$ is taken to be zero for negative $$k$$. Although the sum on the right side appears infinite, it has only finitely many nonzero terms, coming from the nonzero values of $$k$$ in the range $$ - \frac{\sqrt{24n+1}-1}{6} \leq k \leq \frac{\sqrt{24n+1}+1}{6}.$$

Another recurrence relation for $$p(n)$$ can be given in terms of the sum of divisors function $p(40)$: $$ p(n) = \frac{1}{n} \sum_{k=0}^{n-1} \sigma(n-k) p(k).$$ If $$q(n)$$ denotes the number of partitions of $$n$$ with no repeated parts then it follows by splitting each partition into its even parts and odd parts, and dividing the even parts by two, that $$p(n) = \sum_{k=0}^{\left\lfloor n/2 \right\rfloor} q(n-2k) p(k). $$

Congruences
Srinivasa Ramanujan is credited with discovering that the partition function has nontrivial patterns in modular arithmetic. For instance the number of partitions is divisible by five whenever the decimal representation of $$n$$ ends in the digit 4 or 9, as expressed by the congruence $$p(5k+4) \equiv 0 \pmod 5$$ For instance, the number of partitions for the integer 4 is 5. For the integer 9, the number of partitions is 30; for 14 there are 135 partitions. This congruence is implied by the more general identity $$ \sum_{k=0}^\infty p(5k+4)x^k = 5~ \frac{ (x^5)^5_\infty } {(x)^6_\infty},$$ also by Ramanujan, where the notation $$(x)_\infty$$ denotes the product defined by $$(x)_\infty = \prod_{m=1}^\infty (1-x^m).$$ A short proof of this result can be obtained from the partition function generating function.

Ramanujan also discovered congruences modulo 7 and 11: $$\begin{align} p(7k + 5) &\equiv 0 \pmod 7,\\ p(11k + 6) &\equiv 0 \pmod {11}. \end{align}$$ The first one comes from Ramanujan's identity $$ \sum_{k=0}^\infty p(7k+5)x^k = 7~ \frac{ (x^7)^3_\infty} {(x)^4_\infty} +49x ~ \frac{ (x^7)^7_\infty } {(x)^8_\infty}.$$

Since 5, 7, and 11 are consecutive primes, one might think that there would be an analogous congruence for the next prime 13, $$p(13k + a) \equiv 0 \pmod{13}$$ for some $a$. However, there is no congruence of the form $$p(bk + a) \equiv 0 \pmod{b}$$ for any prime b other than 5, 7, or 11. Instead, to obtain a congruence, the argument of $$p$$ should take the form $$cbk+a$$ for some $$c>1$$. In the 1960s, A. O. L. Atkin of the University of Illinois at Chicago discovered additional congruences of this form for small prime moduli. For example: $$p(11^3 \cdot 13 \cdot k + 237)\equiv 0 \pmod {13}.$$

proved that there are such congruences for every prime modulus greater than 3. Later, showed there are partition congruences modulo every integer coprime to 6.

Approximation formulas
Approximation formulas exist that are faster to calculate than the exact formula given above.

An asymptotic expression for p(n) is given by
 * $$p(n) \sim \frac {1} {4n\sqrt3} \exp\left({\pi \sqrt {\frac{2n}{3}}}\right)$$ as $$n \to \infty$$.

This asymptotic formula was first obtained by G. H. Hardy and Ramanujan in 1918 and independently by J. V. Uspensky in 1920. Considering $$p(1000)$$, the asymptotic formula gives about $$2.4402 \times 10^{31}$$, reasonably close to the exact answer given above (1.415% larger than the true value).

Hardy and Ramanujan obtained an asymptotic expansion with this approximation as the first term: $$p(n) \sim \frac{1}{2\pi \sqrt{2}} \sum_{k=1}^v A_k(n)\sqrt{k} \cdot \frac{d}{dn} \left({\frac {1} {\sqrt{n-\frac{1}{24}}} \exp \left[ {\frac{\pi}{k}   \sqrt{\frac{2}{3}\left(n-\frac{1}{24}\right)}}\,\,\,\right]}\right) ,$$ where $$A_k(n) = \sum_{0 \le m < k, \; (m, k) = 1} e^{ \pi i \left( s(m, k) - 2 nm/k \right) }.$$ Here, the notation $$(m,k)=1$$ means that the sum is taken only over the values of $$m$$ that are relatively prime to $$k$$. The function $$s(m,k)$$ is a Dedekind sum.

The error after $$v$$ terms is of the order of the next term, and $$v$$ may be taken to be of the order of $$\sqrt n$$. As an example, Hardy and Ramanujan showed that $$p(200)$$ is the nearest integer to the sum of the first $$v = 5$$ terms of the series.

In 1937, Hans Rademacher was able to improve on Hardy and Ramanujan's results by providing a convergent series expression for $$p(n)$$. It is $$p(n) = \frac{1}{\pi \sqrt{2}} \sum_{k=1}^\infty A_k(n)\sqrt{k} \cdot \frac{d}{dn} \left({   \frac {1} {\sqrt{n-\frac{1}{24}}}    \sinh \left[ {\frac{\pi}{k}    \sqrt{\frac{2}{3}\left(n-\frac{1}{24}\right)}}\,\,\,\right] }\right) .$$

The proof of Rademacher's formula involves Ford circles, Farey sequences, modular symmetry and the Dedekind eta function.

It may be shown that the $$k$$th term of Rademacher's series is of the order $$\exp\left(\frac{\pi}{k} \sqrt\frac{2n}{3} \right), $$ so that the first term gives the Hardy–Ramanujan asymptotic approximation. published an elementary proof of the asymptotic formula for $$p(n)$$.

Techniques for implementing the Hardy–Ramanujan–Rademacher formula efficiently on a computer are discussed by, who shows that $$p(n)$$ can be computed in time $$O(n^{1/2+\varepsilon})$$ for any $$\varepsilon>0$$. This is near-optimal in that it matches the number of digits of the result. The largest value of the partition function computed exactly is $$p(10^{20})$$, which has slightly more than 11 billion digits.

Definition and properties
A partition in which no part occurs more than once is called strict, or is said to be a partition into distinct parts. The function q(n) gives the number of these strict partitions of the given sum n. For example, q(3) = 2 because the partitions 3 and 1 + 2 are strict, while the third partition 1 + 1 + 1 of 3 has repeated parts. The number q(n) is also equal to the number of partitions of n in which only odd summands are permitted.

Generating function
The generating function for the numbers q(n) is given by a simple infinite product: $$\sum_{n=0}^{\infty} q(n)x^n = \prod_{k = 1}^\infty (1 + x^k) = (x;x^2)_{\infty}^{-1},$$ where the notation $$(a;b)_{\infty}$$ represents the Pochhammer symbol $$(a;b)_{\infty} = \prod_{k = 0}^{\infty} (1 - ab^{k}).$$ From this formula, one may easily obtain the first few terms : $$\sum_{n=0}^{\infty} q(n)x^n = 1+1x+1x^2+2x^3+2x^4+3x^5+4x^6+5x^7+6x^8+8x^9+10x^{10}+\ldots.$$ This series may also be written in terms of theta functions as $$\sum_{n=0}^{\infty} q(n)x^n = \vartheta_{00}(x)^{1/6}\vartheta_{01}(x)^{-1/3}\biggl\{\frac{1}{16\,x}\bigl[\vartheta_{00}(x)^4 - \vartheta_{01}(x)^4\bigr]\biggr\}^{1/24},$$ where $$\vartheta_{00}(x) = 1 + 2\sum_{n = 1}^{\infty} x^{n^2}$$ and $$\vartheta_{01}(x) = 1 + 2\sum_{n = 1}^{\infty} (-1)^{n} x^{n^2}.$$ In comparison, the generating function of the regular partition numbers p(n) has this identity with respect to the theta function: $$\sum_{n=0}^{\infty} p(n)x^n = (x;x)_{\infty}^{-1} = \vartheta_{00}(x)^{-1/6}\vartheta_{01}(x)^{-2/3}\biggl\{\frac{1}{16\,x}\bigl[\vartheta_{00}(x)^4 - \vartheta_{01}(x)^4\bigr]\biggr\}^{-1/24}.$$

Identities about strict partition numbers
Following identity is valid for the Pochhammer products:


 * $$(x;x)_{\infty}^{-1} = (x^2;x^2)_{\infty}^{-1}(x;x^2)_{\infty}^{-1}$$

From this identity follows that formula:


 * $$\biggl[\sum_{n=0}^\infty p(n)x^n\biggr] = \biggl[\sum_{n=0}^\infty p(n)x^{2n}\biggr]\biggl[\sum_{n=0}^\infty q(n)x^n\biggr]$$

Therefore those two formulas are valid for the synthesis of the number sequence p(n):


 * $$p(2n) = \sum_{k=0}^{n} p(n - k)q(2k)$$
 * $$p(2n+1) = \sum_{k=0}^{n} p(n - k)q(2k + 1)$$

In the following, two examples are accurately executed:


 * $$p(8) = \sum_{k=0}^{4} p(4 - k)q(2k) =$$
 * $$= p(4)q(0) + p(3)q(2) + p(2)q(4) + p(1)q(6) + p(0)q(8) = $$
 * $$= 5\times 1 + 3\times 1 + 2\times 2 + 1\times 4 + 1\times 6 = 22 $$
 * $$p(9) = \sum_{k=0}^{4} p(4 - k)q(2k + 1) =$$
 * $$= p(4)q(1) + p(3)q(3) + p(2)q(5) + p(1)q(7) + p(0)q(9) = $$
 * $$= 5\times 1 + 3\times 2 + 2\times 3 + 1\times 5 + 1\times 8 = 30 $$

Restricted partition function
More generally, it is possible to consider partitions restricted to only elements of a subset A of the natural numbers (for example a restriction on the maximum value of the parts), or with a restriction on the number of parts or the maximum difference between parts. Each particular restriction gives rise to an associated partition function with specific properties. Some common examples are given below.

Euler and Glaisher's theorem
Two important examples are the partitions restricted to only odd integer parts or only even integer parts, with the corresponding partition functions often denoted $$p_o(n)$$ and $$p_e(n)$$.

A theorem from Euler shows that the number of strict partitions is equal to the number of partitions with only odd parts: for all n, $$q(n) = p_o(n)$$. This is generalized as Glaisher's theorem, which states that the number of partitions with no more than d-1 repetitions of any part is equal to the number of partitions with no part divisible by d.

Gaussian binomial coefficient
If we denote $$p(N, M, n)$$ the number of partitions of n in at most M parts, with each part smaller or equal to N, then the generating function of $$p(N, M, n)$$ is the following Gaussian binomial coefficient:


 * $$\sum_{n=0}^\infty p(N, M, n)q^n = {N+M \choose M}_q

= \frac{(1-q^{N+M})(1-q^{N+M-1})\cdots(1-q^{N+1})} {(1-q)(1-q^2)\cdots(1-q^M)}$$

Asymptotics
Some general results on the asymptotic properties of restricted partition functions are known. If pA(n) is the partition function of partitions restricted to only elements of a subset A of the natural numbers, then:

If A possesses positive natural density α then $$ \log p_A(n) \sim C \sqrt{\alpha n}$$, with $$C = \pi\sqrt\frac23$$

and conversely if this asymptotic property holds for pA(n) then A has natural density α. This result was stated, with a sketch of proof, by Erdős in 1942.

If A is a finite set, this analysis does not apply (the density of a finite set is zero). If A has k elements whose greatest common divisor is 1, then


 * $$ p_A(n) = \left(\prod_{a \in A} a^{-1}\right) \cdot \frac{n^{k-1}}{(k-1)!} + O(n^{k-2}) . $$