On the Twelfth Day of Christmas, My True Love Gave to Me ...
At dinner last night, amid the ubiquitous miasma of egregious Christmas music which is inescapable in public places starting in mid November, during "The Twelve Days of Christmas" Dave got a faraway expression in his eyes. My mother asked why, and he explained that he was thinking about the mathematics of the song: how many items of each type have been given by the end, and which items are more numerous?There are two ways to interpret the song.
On the second day of Christmas, my true love gave to me Two turtle doves And a partridge in a pear tree.
So by the second day, you have two turtle doves, and you have the original partridge -- but do you also have a second partridge, as a literal interpretation of the song implies? Or is the song simply repeating all the previous gifts, not implying that they're given again?
Most people seem to assume the latter, but let's take the song literally and assume that on the third day, you get three french hens, plus two more turtle doves (that makes four) and one new partridge (for a total of three).
My first thought was that at time step T, you double what you had in step T-1 (you're getting all the same stuff yet again) and add T for the new gifts. But that's not right: you get a new load of each item (one partridge, two doves, three hens, and so forth) but you don't double all the accumulated extras who are now crowding your back yard. Time to start writing down the sums.
At each time T, the quantity you have of the Jth item is:
T | |
N_{J,T} = | Σ J |
i=J |
That's easy: it's just N_{J,T} = J*T- J*(J-1) (pretend you've given J of the Jth object at each time step; but since you didn't give it before timestep J, subtract all the ones up to timestep J-1).
N_{J,T} = J * (T - J + 1)
If all you want to know is how many of each item you have at the end (on the 12th day), plug in T-12:
N_{J,12} = J * (13 - J)
A quick sanity check: that means you'll have 12 of item 1 (partridges in pear trees), because you've gotten one new one each time, and 12 of item 12 (drummers drumming), which you got in one big noisy box on the last day. Likewise, you'll have 22 each of items 2 (turtle doves, of which you got two every day except the first day) and 11 (pipers piping), which you got on day 11 and again on day 12.
So the curve which interested Dave is an inverted parabola; you get the least number of the first and last gifts, and the largest quantity of the two middle gifts: six geese a'laying and seven swans a'swimming. How many geese and swans do you get in the end? Here's the surprising answer:
N_{6,12} = N_{7,12} = 6 * 7 = 42
Douglas Adams fans will immediate recognize this as the solution to the ultimate question of Life, the Universe, and Everything. Now you know what the question was!
One last question: how many items, total, of all types will you have by the end of the twelfth day?
Since you already know how many of each item you have, just add them all up:
12 | 12 | 12 | 12 | ||||
N_{tot} = | Σ j * (13-j) | = | Σ (j * 13 - j^{2}) | = 13 * | Σ j | - | Σ j^{2 } |
j=1 | j=1 | j=1 | j=1 |
Fortunately, we know that
A | |
Σ i | = A (A + 1) / 2 |
i=1 |
A | |
Σ i^{2 } | = A (A + 1) (2A + 1) / 6 |
i=1 |
N_{tot} | = { 13 * (12 * 13) / 2 } - { 12 * 13 * 25 / 6 } |
= 364 |
So it turns out that true love packs a present for just about every day of the year into those twelve days!
(And I found an excuse to play with using HTML tables to display equations.)
[ 11:59 Dec 21, 2006 More science | permalink to this entry ]