Cadence is off today, so time for an off-topic post.

In my post Short Papers last summer, I said:

John Conway is probably most famous to computer scientists for inventing the cellular-automaton-based game of Life, and to mathematicians for his work on the classification of finite groups. He is most famous to

for teaching me first-year linear algebra at Cambridge. He would race through lectures as quickly as he could so that he could tell us about something more interesting than matrix algebra in the remaining 10 or 15 minutes such as ... the Doomsday algorithm for quickly calculating the day of the week for any date in your head.me

So today I'm going to tell you about the Doomsday algorithm, as told to me by Conway in an off-topic wrapup to a linear algebra lecture in about 1973. You will be able to quickly tell any of your friends on what day they were born, or turn any other date into a day of the week.

## Step 1: Doomsday

The first thing you need to know is that Doomsday is that last day of February (so the 28th most years, the 29th in a leap year). The advantage of starting there is that the extra day appears at the end of the loop, and doesn't perturb anything else. This year, 2018, Doomsday was a Wednesday because February 28th was a Wednesday. Conway's algorithm relies on finding other days that are also Doomsday. If you start using this a lot, then you will soon learn lots of days like that—for instance, Independence Day is always Doomsday. 7/4/2018 is a Wednesday—check.

Conway gave us a rule that gave us one day in each month as a starting point:

- for all even months (except February), the day matching the month is Doomsday. So 4/4, 6/6, 8/8, 10/10 and 12/12 are all Doomsday
- for all odd months (except January), you need to add 4 if the month has 31 days, or subtract 4 if the month only has 30

- so for March, 3+4 = 7 means that 3/7 is Doomsday (because March has 31 days)
- Likewise 5/9, 7/11, 9/5 (the first time we have to subtract 4 since September only has 30 days), and 11/7

- for February, we already know that the last day of the month is Doomsday
- for January, the 31st is Doomsday, unless it is a leap year in which the 32nd is Doomsday. Of course, there is no 32nd but just calculate as if it existed

That gives you one day in every month, and using that you can just work out the day of the week given that you know one day in that month already.

## Step 2: What Day is Doomsday for a Given Year?

If you know Doomsday for the given year, then you can work out the day of the week for a date in that year. But how do you find out Doomsday for the year of interest?

- Starting point. You just have to remember these. Doomsday 1900 was a Wednesday. Doomsday 2000 was a Tuesday.
- Given that, you could just work out how many years there were to the year of interest, and how many were leap years
- But here's another shortcut. "A dozen years is but a day". Every twelve years advances the day by 1, taking into account all the leap years too.

## Putting It Together

Let's see how it works in practice. President Kennedy was assassinated on November 22nd 1963. What day was that?

A dozen years is but a day, so 1960 was 5 days. Add on 1961, 1962, 1963 which is 3 more. In total that is 8 more, which is 1 more (since we throw away any 7s since they don't affect the day of the week). So Doomsday 1963 was one day on from Doomsday 1900 which was a Wednesday—so Thursday.

November is an odd month with 30 days, so 11-4 = 7 is the Doomsday that month. So 11/7 was Doomsday. You can either do arithmetic, or I find it quicker just to step through the weeks. If 11/7 was Doomsday, then so is 11/14 and 11/21. Kennedy's assassination was one day after that, so one day after Doomsday, so Frriday.

Let's check with Wikipedia:

Yes, it was a Friday. You can use this approach to work out the day of the week in any 19xx or 20xx year.

Here's another little check. I said Doomsday 1900 was a Wednesday. Let's pretend we don't know Doomsday 2000, and we'll work it out. A dozen years is but a day, so 96 years is 8 days, which is 1 day since we only care about days of the week. We need to add 4 for 1997, 1998, 1999, and 2000, plus 1 more since 2000 is a leap year. So 1+4+1 makes 6. So Doomsday 2000 is 6 days on from Doomsday 1900, so is indeed a Tuesday as I said.

## Julian and Gregorian Calendars

The difference between the Julian and Gregorian calendars is this. In the Julian calendar, all centuries (1900, 2000, 2100...) are leap years. In the Gregorian calendar, they are only leap years if they are not just divisible by 4 but by 400. So 2000 was a leap year, but 2100 will not be (whereas under the Julian calendar it would have been).

The Gregorian calendar is more accurate at keeping the calendar synchronized with the Earth's rotating about the sun. The Julian calendar is off by 11½ minutes. After centuries, using the Julian calendar, the calendar was several days out. Countries all changed to the Gregorian calendar but at different times. For a little background on this, see my post October Revolution which explains why the October Revolution now falls in November. Russia didn't switch until after the revolution, which was really late. France, Italy and some other countries switched centuries earlier in 1582.

Britain switched in 1752, as did the US and Canada (still British colonies). They didn't just switch, they needed to bring themselves back into alignment with the sun (and other countries), so Wednesday 2 September 1752 was followed by Thursday 14 September 1752.

This was legislated by the *Calendar (*new* Style) Act 1750*. In addition to switching from the Julian to Gregorian calendar, this also moved the start of the year from March 25th to January 1st.

Wait. What? Yes, Until then, the year rolled over from one year to the next higher on March 25th, on Lady Day.

The financial industry and tax authorities had to worry about how to handle annual interest. The fiscal year ran from March 25th one year to March 24th the next year, basically all the days with the same year number under the old scheme. They had to decide how to handle annual interest payments and allowances, and they decided simply to run a 365 day year as usual. That meant that from then on, the British financial year ran from April 4th to April 5th of the following year. That was fine until 1800, which would have been a leap year under the Julian calendar but was no longer under the Gregorian. To keep things aligned, another day of adjustment was made, so that the fiscal and tax years ran from April 6th one year to April 5th the following year. It's been like that ever since, all the way to today (for personal tax purposes. For corporations it got moved to April 1st at some point).

If you want to know the day of the week of a given date back in time, you need to take these calendar shifts into account. Different countries switched from Julian to Gregorian at different times. And the day the year rolled-over also varied by country (and era). So, for example, the bill I mentioned above was introduced in what we would now call February 1751, but it would have been 1750 under the old style calendar then still in effect. So it is hard to know, with certainty, exactly what a historic date means. It depends on the country, whether anyone has already made the adjustments mentioned here (and probably whether historians are even fully aware of them).

It's a holiday tomorrow, so we can have a second date.

**Sign up for Sunday Brunch, the weekly Breakfast Bytes email.**