Calendar

Magic Matrix Force

Calendar

Observe the calendar page below. If you are willing to follow a few simple rules, I can "force" you to pick the number 0. Here are the rules:

  1. Click on any number in the blue outlined square.
  2. All other numbers in the same row and column will be eliminated.
  3. Select any other number in the square and repeat the process until four numbers have been selected.
  4. Note that the sum is equal to 0.
Reset

This trick is known as a force since even though you can choose different numbers, a certain sum is "forced" to be produced. This trick also falls into a class of tricks called self-working tricks (the best kind). In these types of tricks, as long as you follow the set proceedure, it always works.

It turns out that this the magic matrix force works for any calendar month and for any 4 x 4 square of numbers on a calendar page. The calendar below will allow you to select any month and any square of numbers. You can change the month by clicking on the "Next Month" and "Previous Month" buttons. Likewise, you may move the selection square left and right by clicking on the appropriate buttons. Note that the "Magic Number" (i.e. forced sum) will update appropriately.

Magic Number: 0
Previous Month Next Month Square Left Square Right
Reset

If you want to try this on your friends (and win their admiration -- actually, more likely their contempt), you will need to know how to compute the magic number. This is actually quite simple. Just take the number in the upper left hand corner of the square (known as the anchor), multiply it by 4 and add 48.

Show Me the Magic!

At this point you may probably wondering how this works. (Math Alert! This section requires a some math, but nothing beyond what you (should have) learned in high school -- I promise I'll be gentle.)

In the first table we have the numbers from the selected square in the calendar page. In the second table, each cell has a two digit number. To form the numbers in the second table take the anchor number (in this case 0) and subtract it from each number in the first table. The two digit number in the second table is then given by computing the quotient (first digit) and remainder (second digit) after dividing the numbers in the first table by seven.

There are several interesting things about the second table. The first, is that the first digit is the same for all numbers in the same row and the second digit is the same for all the numbers in the same column. More importantly, the entire table stays the same no matter which square is used in the calendar or which month is used (mathematicians call this property invariance -- as if you cared). In any case to demonstrate this, position this web page such that you can see both the calendar page and the tables. Try changing the dates and the position of the square. You will see that no matter what you select, the values in the table on the right stay the same! (For the sceptics out there, if look at the JavaScript for this page, you will see that it is actually coded to update both tables.)

"This is very interesting," you might say, "but what does this have to do with the price of tea in China?" That is, "How does this help explain how the trick really works?" Well, the numbers in the table on the right actually represents numbers in the base 7 number system. That is, the second digit is the one's position and the first digit is the seven's position. Since you are forced to select a number from each column, using from the one's position, you always have the number 6 = 0 + 1 + 2 + 3 in the sum. Likewise, by being forced to select a number from each row (i.e. the seven's position), you will have the number 42 = 0·7 + 1·7 + 2·7 + 3·7 in the sum. 6 + 42 = 48. Throw in the anchor number times 4 (once for each square) and there's your magic number!

More Math

Okay, I'll admit it, this part is for geeks (I prefer the term mathematical sophisticate). It still does not require any more than high school math, but if you aren't into algebra stop reading now. As you know, a remainder after dividing by 7 can yield any number between 0 and 6, but in the table above we only see the numbers 0, 1, 2, 3 in the one's position. The answer is elementary my dear Watson! Once we subtract the anchor from all the numbers, the first row only contains the numbers 0, 1, 2, 3. To form each number in a given column, 7 is added to the number in the previous row, but as you will recall, adding 7 to a number does not affect the remainder after dividing by 7. Hence, all numbers in the same column have the same number in the one's position, and are restricted to the values 0, 1, 2, and 3 that are in the first row.

A magic matrix is very easy to produce. Any array of numbers of the form

a0m + b0 a0m + b1 a0m + b2 ··· a0m + bn-1
a1m + b0 a1m + b1 a1m + b2 ··· a1m + bn-1
a2m + b0 a2m + b1 a2m + b2 ··· a2m + bn-1
··· ··· ··· ··· ···
an-1m + b0 an-1m + b1 an-1m + b2 ··· an-1m + bn-1

where m > b0, b1,..., bn-1, and a0a1 ≠ ··· ≠ an-1, and b0b1 ≠ ··· ≠ bn-1, is a magic matrix.

The sum (i.e. magic number) of any such matrix is given by the formula

Sum = Σ(aim + bi),

where i ranges over 0 to n-1. Note that for the calendar trick, ai = 7·i + a, and bi = i, where a is the anchor number and n = 4. Using the Sum formula above, this works out to the expected Sum = 4·a0 + 48.

Another interesting diversion can be created by producing a magic square for (almost) any desired magic number. Just to make the math easier, we will apply some simplifications. First, we will assume that bi = i just as in the calendar problem. Next, we will assume m = n and ai = n·i + a, where n is the size of one side of the square. Given these simplifications our Sum formula reduces to:

Sum = Σ (n i + a + i) = n a + Σ (n + 1) i = n a + (n + 1) Σ i.

The last summation on the right is well known and is equal to Σ i = (n2-n) / 2. Plugging this back in to the equation above gives

Sum = n a + (n + 1) (n2-n) / 2.

While this looks a bit complex, it is fairly simple to apply in practice. For a 4 x 4 square, the formula becomes Sum = 4a + 30. If we seek a particular sum, we need to find the anchor number a, i.e. a = (Sum - 30) / 4 (note that Sum must be selected so that Sum-30 is divisible by four). Once a has been determined, compute the numbers for the matrix using ai = n·i + a and bi = i. To continue the 4 x 4 example, if we wanted a matrix with the sum 42, we compute a = (42 - 30) / 4 = 3. Plugging this into the matrix formulas give

3 4 5 6
7 8 9 10
11 12 13 14
15 16 17 18

Such a matrix can be "disguised" by swapping rows and columns (this will clearly not affect the sum) as shown below.

17 15 16 18
5 3 4 6
13 11 12 14
9 7 8 10

More complex (and less obvious) matrices can be created by using the more general form of the matrix equations (I'll leave that as an exercise for you).

Home

Home Page