Mathematica has built-in functions for counting the number of partitions of an integer. PartitionsP counts the total number of partitions of an integer, while PartitionsQ counts the number of partitions that use distinct summands.
In[1]:=
Out[1]=
In[2]:=
Out[2]=
The asymptotic behaviour of these functions can be studied numerically
In[3]:=
Out[3]=
In[4]:=
Out[4]=
In[5]:=
Out[5]=
Since the natural log of the number of partitions grows like a square root curve, this suggest that the P[n] is of order .
The Combinatorica add-in package has functions that aid in enumerating and other calculations.
In[6]:=
In[7]:=
Out[7]=
In[8]:=
Out[8]=
There is also a function for drawing Ferrers diagrams.
In[9]:=
Out[9]=
The Combinatorica add-in also has the ability to enumerate partitions of an integer using summands that don't exceed a given number.
In[10]:=
Out[10]=
We can make a table of these.
In[11]:=
Out[11]//MatrixForm=
In order to construct a method for counting the number of partitions of an integer m into exactly n parts, we can use the above function. Then we can build a table of values for the number of partitions of m using exactly n parts that illustrates the recurrence that we talked about in class. Of course, this method is very inefficient since it uses the Mathematica functions that actually enumerate the partitions (only counting the total number of such) rather that constructing the numbers using a more efficient recurrence relation.
In[12]:=
In[15]:=
Out[15]//MatrixForm=
The above method for generating the table of values is very inefficient since it actually enumerates the partitions and simply counts the number of such. Since we have a recurrence relation given by
we can directly implement this in Mathematica.
In[22]:=
We can now define a new function for calculating a table of the partition numbers p(m,n) that runs more efficiently than what we did before.
In[26]:=
Now we can use the PartitionTable function to compute tables of a partition numbers much more quickly.
In[29]:=
Out[29]//TableForm=
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
13 | 1 | 6 | 14 | 18 | 18 | 14 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
14 | 1 | 7 | 16 | 23 | 23 | 20 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
15 | 1 | 7 | 19 | 27 | 30 | 26 | 21 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
16 | 1 | 8 | 21 | 34 | 37 | 35 | 28 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
17 | 1 | 8 | 24 | 39 | 47 | 44 | 38 | 29 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
18 | 1 | 9 | 27 | 47 | 57 | 58 | 49 | 40 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
19 | 1 | 9 | 30 | 54 | 70 | 71 | 65 | 52 | 41 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
20 | 1 | 10 | 33 | 64 | 84 | 90 | 82 | 70 | 54 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
21 | 1 | 10 | 37 | 72 | 101 | 110 | 105 | 89 | 73 | 55 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
22 | 1 | 11 | 40 | 84 | 119 | 136 | 131 | 116 | 94 | 75 | 56 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 0 |
23 | 1 | 11 | 44 | 94 | 141 | 163 | 164 | 146 | 123 | 97 | 76 | 56 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 | 0 |
24 | 1 | 12 | 48 | 108 | 164 | 199 | 201 | 186 | 157 | 128 | 99 | 77 | 56 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 | 0 |
25 | 1 | 12 | 52 | 120 | 192 | 235 | 248 | 230 | 201 | 164 | 131 | 100 | 77 | 56 | 42 | 30 | 22 | 15 | 11 | 7 | 5 | 3 | 2 | 1 | 1 |
Converted by Mathematica (February 20, 2003)