## Sunday, June 13, 2010

### The days of the week (or how to pretend like you are a savant)

Being able to tell what day of the week a date like October 28, 2012, will fall on seems like an impressive feet of computation. It is actually quite simple if you can memorize a few numbers.

My younger daughter Elizabeth and I have made a system whose only mental calculation is the addition of three numbers, all of which are less than seven. The sum of the three numbers indicates the day of the week. Sunday = 0, Monday = 1, and so on up to Saturday = 6. To complete the "savant" effect, say things like "Oh, that one is kinda bumpy so it is a Wednesday," or "Friday, it's blue and cold, definitely a Friday." If you decide to give it a go, be sure to try out my days of the week quiz program in the previous post to test yourself.

All of this math, takes place in the group of integers modulo 7, which simply means that we only care about the remainder of the number after dividing by 7. In this group, 8 and 1 are "equivalent" since 1 / 7 = 0 remainder 1, and 8 / 7 = 1 remainder 1. They both have the same remainder of one, after dividing by 7 so they are "equivalent" for our purposes. This boils down to the fact the we care ONLY about the day of the week, not how many weeks have passed or will pass between now and then. So we throw out the quotient and keep the remainder. To indicate that the computations are specific to integers modulo 7, "mod 7" is appended to each line. Here are some example calculations in this arithmetic:

0 + 0 = 0 mod 7
1 + 1 = 2 mod 7
4 + 3 = 0 mod 7
6 + 6 = 5 mod 7.

Try a few on your own:
3 + 3 = ? mod 7
5 + 2 = ? mod 7

Sometimes it is convenient to represent 6 as -1 mod 7. Since they share the same remainder after dividing by 7. With this in mind 6 + 6 = -1 + -1 mod 7 = -2 mod 7. Likewise -2 = 5 mod 7 and so on.

Each day, month, and year gets assigned an integer modulo 7. For instance in the carefully chosen example above:
October = > 0
28 = > 0
2012 = > 0,
so October 28, 2012 falls on a Sunday (0 + 0 + 0 = 0 mod 7).

So the arithmetic is simple. The tricky part is memorizing the number assignments for the months and years. Let's make it simple by only considering dates in the current year (2010) and focus on the months and day assignments. The year 2010 gets assigned a 4 (we will talk about why later).

The day assignments are the easiest: just take the day number modulo 7. The 15th of the month gets a 1 for instance since 15 = 1 mod 7.

The month assignments, in row order are:

Jan:0 Feb:3 Mar:3
Apr:6 May:1 Jun:4
Jul:6 Aug:2 Sep:5
Oct:0 Nov:3 Dec:5

or leaving off the month names for compactness:
0 3 3
6 1 4
6 2 4
0 3 5

In this system, this block of 12 numbers must be memorized backwards and forwards, by rows and by columns, inside, outside and upside-down. Some months are easier for me to remember than others:
January is a 0 (it starts everything off)
March is a 3 (third month of the year)
May is a 1 (May Day falls on May 1)
October is a 0 (The big O in October looks like a zero).

The others just need to be memorized. It's not actually that bad, but if you think of a good mnemonic, let me know.

A brief note on how the month assignments are made. January gets assigned a 0 to start things off. This is somewhat an arbitrary choice, but if you change it, you will also have to change the year assignments. Since January has 31 days and 31 = 3 mod 7, the first of Feb is three days of the week offset from the first of January, thus February gets assigned a 3. February has 28 days (exactly 4 weeks) most years so March 1st will fall on the same day as February 1st most years. Thus, we assign a 3 to March. March has 31 days which makes April 3 days offset from March (which was already 3 days offset from January 1st) , so April gets assigned a 6 (3 + 3 = 6 mod 7). Carry this process forward to compute the assignments for the other months.

With this in hand, you can compute any day of the week for the year 2010:
Oct 14, 2010 = > 0 + 0 + 4 = 4 mod 7, a Thursday
Mar 10, 2010 = > 3 + 3 + 4 = 3 mod 7, a Wednesday
July 4, 2010 = > 6 + 4 + 4 = 0 mod 7, a Sunday
...

Now to tackle the year assignments. Be sure to get really fast for the current year before you go any further.

For reasons that might become clear later, the year assignment is the day of the week that March 4th falls on. March 4, 2010, happens to be a Thursday, so 2010 is a 4. Using a calendar we get the following assignments for some nearby years:

2007 = > 0
2008 = > 2
2009 = > 3
2010 = > 4
2011 = > 5
2012 = > 0
2013 = > 1
2014 = > 2

Observe that the years go up by one whenever the year is NOT a leap year. For a leap year the assignments are 2 larger than the previous year. This makes since since 365 = 1 mod 7 for a normal year, and 366 = 2 mod 7 for a leap year. Zero years are thus convenient milestones to anchor the assignments for neighboring years. Elizabeth and I have dubbed a zero assigned year, like 2007, as a zear.

Every 28 years a zear falls on a leap year like 2012. These special years get a special name in this system. When a zear is also a leap year, it is refferred to as a le-zear pronounced "le" as in French with great flourish and accent on the second syllable: le-Zear!

Leap years require additional caution (Elizabeth always gets me on this!). If the date of interest is is in January or February of a leap year, subtract 1 from the count. Example:
January 25, 2012 = > 0 + 4 + 0 = 4 mod 7 - 1 = 3 Mod 7, a Wednesday.