This will be, I think, a relatively gentle treatment of what could be a rather complicated matter.
The problem came up in problem seminar this week, the matter of integer partitioning. Specifically, given an integer n, how many different ways can you write it as the sum of smaller integers? More specifically, and a notably easier problem, how many different ways can you write it as the sum of three smaller integers?
For example, 6 can be written as 1 + 4 + 1, 3 + 2 + 1, and 2 + 2 + 2. Notice that we're counting 1 + 4 + 1 as the same as 4 + 1 + 1. 5 can be written as 1 + 1 + 3, 1 + 2 + 2. So the number of 3-partitions for 6 is 3, and the number of 3-partitions for 5 is 2. Clearly 0, 1, and 2 all have no 3-partitions, and 3 has one, 1 + 1 + 1. But for a general n, how many are there?
The basic approach is going to be to come up with a method of constructing all 3-partitions of a given number, and then the formula for the total number falls out almost automatically. What follows then is a reduction from the initially simple to understand but difficult to compute formula to a relatively difficult to understand but surprisingly simple formula. It's interesting.
So, we have an integer n, and we want to construct a 3-partition of it. Constructing a partition basically amounts to choosing 3 integers i, k, j such that i + k + j = n.
Notice though, that we want to, in picking our numbers, avoid duplication. For example, when n = 6, we want to avoid choosing 1, 1, 4 and also 1, 4, 1. To avoid this, we're going to make sure to pick our numbers in sorted order. That is, we're going to make sure that the first number we pick will be the smallest of the three, and that the second number we pick will be at least as big as the first, and that the third is at least as big as the second. We'll call them, in order, i, k, j.
So, how many values can we pick for i, the smallest of the three? Clearly the smallest value we can have for i is 1. But what is the largest? i can be, at most, n/3. Think about it. If i is greater than n/3, then what is left of n to partition between k and j? Something less than n - n/3, or 2n/3. Partitioning 2n/3 between two numbers, one of them is going to have a value less than n/3 - but this contradicts our definition of i as the smallest of the three. Therefore, i is at most n/3.
But, since we're dealing with integers, i is really at most n/3, rounded down to the nearest integer. In math speak, this is the floor of n/3, or . So, for example with n = 5, n/3 is 1 and 2/3rds, which rounds down to 1. Looking back up at the introduction, you'll see that in the two partitions I give for n = 5, the smallest number in each case is 1.
So, we declare a value for i between 1 and . Notice though, that since k and j are at least as big as i, in deciding the value of i, we've 'pre-partitioned' 3*i of the total n. We know that the sum of the partition is going to be at least i + i + i. So really, in choosing k and j, what we're doing is partitioning n - 3*i between k and j, each of which is already at least i.
So, having picked a value for i, and thus set a minimum value of k, how can we partition n - 3*i between k and j such that j is greater than or equal to k? Similar to before, we can add, at most, half the remaining value to be partitioned to k. If we add any more, we'll end up adding less value to j, and k will be greater than j - which violates how we're setting things up. Remembering the fact that k must be an integer though, we can add at most to k. That gives us the upper bound. For the lower, remember that it's perfectly acceptable for i to equal k, but k cannot be less than i, so i is a lower bound for k.
To summarize,
We have that i is between 1 and .
We have that k is between i and i + .
Now what of j?
This is largely a trick question. Remember that we're after i + k + j = n. If we've chosen values for i and k, then j = n - (i + k). There's only one choice for j. And, by the way we've bounded our choices for i and k, it guarantees that j is the largest of the three numbers.
And that's it : ) This gives us a method for constructing all the partitions of n into 3 integers, such that no partition is constructed twice.
Now, as to counting the number of such partitions, it amounts to counting every possible choice of i and k. So, we basically count through every i, and for each i count through every possible k, and sum the number of times we do this Counting amounts to adding 1 a certain number of times. Thus we have our partition counting function,
That's the easy to understand formula, because you can see where every part of it comes from. Now to simplify : ) Notice though that it is difficult to compute, because it basically amounts to running through every possible partition, though in a convenient way, and counting them. If there are 10000000 bajillion partitions, that double sum will take a long time to compute.
Firstly, summing 1 over a given range is just equal to the number of numbers in that range. So we can reduce the double sum to a single sum of the form
Now instead of summing over all possible i and then all possible k, we've reduced it to a sum over all possible i. But we can do better. Notice, for example, that the floor function isn't very ... managable. There's not a lot you can do with it algebraically. But we can replace it with something just as good.
First, think about
So, think about that behavior. For even values of n - 3*i, we want a function that returns (1/2)(n - 3 i), and for odd values of n - 3*i, we want one that returns (1/2)(n - 3 i) - (1/2). The only thing that really changes is the subtracting of one half.
So notice that (-1)m equals 1 for even m, and -1 for odd m. Then 1 - (-1)m equals 0 for even m, and -2 for odd m. Then, (1/4)(1 - (-1)m) equals 0 for even m, and -1/2 for odd m.
That being so, we can rewrite our floor function as
We can then reform our summation as
The rest is just a matter of algebra and series formulae. Expanding everything,
And then I could step through each step of simplifying the sum, but that would be even more tedious than everything I've done so far, so I'll skip straight to the punchline,
And that is awesome. Because we've reduced a function that was a multiple summation to a function that requires a fixed number of compuations, -dramatically- easier to calculate. Plugging in n = 0, 1, and 2, we get P3 is 0 for each. For n = 3, when
So there is only one partition of n = 3, which we know is true since the only partition is 1 + 1 + 1.
I don't really feel like doing any more examples, since I've gone on well long enough. I think it is very interesting though that the resulting function turned out to be (effectively) quadratic in terms of n. Honestly, I find it interesting the formula reduced half as nicely as it did anyway : )
So that's our final result for the number of ways of partitioning an integer n into three pieces. I've gone on long enough at this point though, and it's time enough for me to get back to work.




