Home> urticator.net Search About This Site > Domains Glue Stories Computers Driving Games Humor Law Math > Numbers Science Powers and Fractions Notes About Squares Decimal Expansions (Section) Number Maze Primes Divisibility Intrinsic Nature of Primes Other Topics > Other Topics (2) Machine Language Pascal's Triangle Dead Reckoning Exponentials Multiplication in Base 10 The Multiplication Table
|
PartitionsI know about two kinds of partitions. In one, a set is divided into disjoint subsets. This is sometimes useful as a technical device in proofs, but is not very interesting. In the other, an integer is divided into integer pieces. This is sometimes useful in actual math problems, and so is nice to know something about.Since a picture is worth a thousand words, here's a picture of the seven different partitions of 5. The diagrams are called Young diagrams.
Most of the time, the quantity of interest is not any specific partition but rather the number p(n) of different partitions of n.
There's no simple formula for p(n), so it's useful to remember the first few values. Under normal circumstances (when I haven't already been thinking about partitions), my limit is probably somewhere around n = 6. Note that the value p(0) = 1 is not an arbitrary convention. A partition is just a set (multiset) of pieces. It makes sense to talk about the empty set, and in the same way, it makes sense to talk about the empty partition. And, the sum of all the pieces in the empty partition is 0, so the empty partition is a partition of 0. It's also clearly the only one. Here are two interesting facts about partitions. First, partitions have duals. To take the dual of a partition, just flip the Young diagram about a line with slope −1. In the picture above, taking duals has the same effect as reversing the order, so that 41 and 2111 are dual, 311 is self-dual, and so on. Unfortunately, the same thing doesn't work in general—taking duals only reverses dictionary order for n ≤ 5. Second, there's a natural correspondence between the partitions of n and the irreducible representations of the symmetric group Sn. Somehow you can use a Young diagram to actually construct a representation! I've never understood the details, but some day I will, and then I'll write up a nice summary for you. If you want more facts about partitions, the Wikipedia article has plenty, but to me they're less interesting. I should also point out that with Young diagrams it's conventional to look at the row counts, not the column counts. I'm only breaking the rules here to make the picture more readable. Although there's no simple formula for p(n), there is an algorithm that's easy to understand, easy to remember, easy to implement in code, and easy to execute by hand. In fact, the algorithm produces a whole grid of meaningful numbers, sort of like the algorithm in Powers of N. The only drawback is that since grids are inherently at least O(n2), it's quite inefficient. As sometimes happens with math, the key is to make the problem larger. So, let p(n,k) be the number of partitions of n with pieces of size at most k. Here are some sample values from running the algorithm with n = 12.
How do we know the value of, say, p(12,4)? Well, suppose we have a partition of 12 with pieces of size at most 4. The obvious question to ask is how many pieces of size 4 it has.
To sum up,
p(12,4) = p(12,3) + p(8,3) + p(4,3) + p(0,3), or in the general case,
p(n,k) = sum j=0 … ⌊n/k⌋ ( p(n−jk,k−1) ). With that equation, we can compute any column from the previous one. Then we need only observe that the first column is all 1s, and we have an algorithm. We can do better, though! Returning to the p(12,4) example, let's also write down the equation for p(8,4).
p(8,4) = p(8,3) + p(4,3) + p(0,3) If we substitute that into the equation for p(12,4), we find
p(12,4) = p(12,3) + p(8,4), or in the general case,
p(n,k) = p(n,k−1) + p(n−k,k). With that equation, too, we can compute any column from the previous one, as long as we compute the cells in an appropriate order, e.g. downward. (How many upward steps can there be?) The advantage is that the cost per cell is fixed. The disadvantage is that the equation has an edge case: when n < k the second term on the right shouldn't even be there (and is undefined).
|
See Also@ May (2022) |