# What day of the week was it?

Among the more esoteric forms of nerd-entertainment is the “day of the week” problem. Specifically, given a date from history, can you determine the day of the week on which it fell? For example, humans first landed on the moon on July 20, 1969, and unless you are old enough and have a great memory, you probably didn’t know that this was a Sunday. Of course you can always look it up somewhere (TimeAndDate.com is my personal favorite), but the challenge is to figure it out in your head.

In one extreme example, it’s said that the mathematician John H. Conway has a password-protection system on his computer that asks him to identify, in rapid succession, the days of the week for three randomly-generated dates. How does he (or anyone) do it?

Well, there are a few convenient and peculiar facts about our calendar that can help us do the math. First, there is a set of “reference dates” that all fall on the same day of the week every year. The first of these are 4/4, 6/6, 8/8, 10/10, and 12/12. For the odd-numbered months, we have some nice dates that also fall on the same day of the week as the first five: 5/9, 7/11, 9/5, and 11/7. (Check out this year’s calendar if you don’t believe me.) Notice that we don’t have any dates for January, February, or March. This is unfortunate, and is partly the result of having a leap day inserted every four years. But there are some ways around that problem. I use the dates 1/9 and 2/6, along with 3/0 (i.e., the last day of February) to do it. Be careful, though—we need to treat January and February of year x as technically being part of year x-1, but the 3/0 date as part of year x.

Thus, once you know the reference day (the day of the week on which all the reference dates will fall) for a given year, you can figure out the day of the week for any date that year by adding and subtracting weeks from a reference day. For example, July 20 is 7/20, which is 9 days after the date 7/11 (which was a Friday). So, 7/20 is one week and 2 days later, on a Sunday.

Next, we need to have a way of finding the reference day from a given year. As you might expect, that reference day moves each year, though this movement is complicated by that leap day every four years. An easy mnemonic is “12 years is but a day”. That is, if you move 12 years forward (say, from July 20 1969 to July 20 1981), the day of the week will move exactly one day forward (from Sunday to Monday). If you take into account that the day of the week skips one day forward in non-leap years and two days in leap years, you can determine the day of the week of a date in any different year. Of course, you can do all of this in reverse if you want to move backward in time.

And that’s it! We can now use the “reference day + “12 years is but a day” + “skip 1-2 days per year” rules to determine the day of the week for historical dates. For example, suppose we want to know what day of the week the stock market crashed in the U.S.—10/29/1929. Here are the steps:

• The reference day for 2016 is Monday.
• This means that 10/10/2016 is Monday, so that 10/29/2016 is 2 weeks and 5 days ahead—i.e., a Saturday.
• Back up seven multiples of 12 from 2016 to 1932 (since 2016 – 7•12 = 1932), so the day of the week shifts 7 days back (to where you started)—still a Saturday.
• Back up three more years, keeping in mind that you passed the leap day on Feb 29 1932, so you move back four days from Saturday—now on a Tuesday.
• There you have it—Oct 29 1929 was a Tuesday (which is why it’s often referred to as Black Tuesday!).

As long as you know the reference day for the current year, you can apply this rule to go forward or backward to any date in the Gregorian calendar. In my case, my birthday happens to fall on that reference day of the week, but any of the reference dates will work. (And, for the calendar nerds out there: for historical events, you need to know whether the country in question was using the Gregorian or Julian calendars, which is a whole other can of worms.)

Thanks for reading! I’ll be back for more at an unspecified date in the future.

# Friday Fun: Calendar Outtakes

The best part of a comedy film is when the actors make small mistakes, and the cast and crew bust out laughing. It’s become common to run outtakes during the credits (by the way, this was first done by Peter Sellers in Being There, in 1979).

Here, I want to share some odd, silly, and independently interesting factoids about how our calendar systems have come up short—sometimes with dire consequences. These factoids all come from Nachum Dershowitz & Edward Reingold’s Calendrical Calculations, which I used last November for my dual posts on Thanksgiving and Hanukkah.

First up, a manufacturing disaster:

“…a computer software error at the Tiwai Point aluminum smelter at midnight on New Year’s Eve [in 1996] caused more than A\$1 million of damage. The software error was the failure to consider 1996 a leap year; the same problem occurred 2 hours later at Comalco’s Bell Bay smelter in Tasmania.” [Reported in New Zealand Herald, 8 January 1997.]

This next one was an inconvenience for business travelers:

“…Microsoft Windows 95, 98, and NT get the start of daylight saving time wrong for years, like 2001, in which April 1 is a Sunday; in such cases, Windows has daylight saving time starting on April 8. An estimated 40 million to 50 million computers are affected, including some in hotels that are used for wake-up calls.” [Reported in New York Times, 12 January 1999.]

These two examples, while significant, had consequences that were relatively short-lived. But would you believe a calendar irregularity caused repeated political crises over the course of several centuries? It’s true, as the Ottoman Sultans would have told you. Some background information first…

The Ottoman Empire used the Islamic calendar, which is a lunar calendar with 12 months of 29 or 30 days. There are 11 leap days added every 30 years, so the average length of the year is 354 11/30 days. Obviously, this means that the Islamic calendar drifts throughout the solar year (about 11 days each year), and so the months don’t have any real connection to the changing seasons. April is always a spring month, but Ramadan can occur in any season.

Back to our story: when it came to finances, the Ottomans used the Islamic calendar for expenditures, but since many of the revenues came from seasonal activity (like farming), they used a solar calendar for tax collection. There are about 32 solar years for every 33 Islamic years, and in the 33rd year—the şiviş year—the government faced a fiscal crisis and ran the risk of failing to pay its employees (most notably the military). The financial crises easily became political crises, which have come to be known as “şiviş year crises”.

Now, in the US, we had a government shutdown where some federal employees went unpaid for 2 weeks, but could you imagine an entire year? Of course not. Any farsighted government would realize that the problem was coming, and action was often taken to adapt head off any revolt—devaluing the currency, deficit spending, spreading out payments for a few years to cover the gap, but these measures didn’t always avoid economic and political turmoil.

To give one example, the şiviş year 1677 (1088 A.H.) was weathered with significant deficit spending, but by 1687 the government was forced to postpone payments to its soldiers, whereupon the army marched to Edirne and deposed the Sultan Mehmed IV. Looking over some of the other şiviş years, it seems that one good way to avoid the crisis was to conquer a foreign country (Mehmed II greatly relieved his financial worries by taking Constantinople). It’s worth mentioning that Mehmed IV may have avoided his eventual downfall if his troops had been able to capture Vienna.

That’s all for now! You can read more about the şiviş year crises here.

# Calendars, Cycles, and Cool Coincidences (Part I)

You might have heard that Hanukkah and Thanksgiving coincide this year. More specifically, you may have heard that the first day of Hanukkah (25 Kislev in the Hebrew calendar) coincides with 28 November, which just happens to be the fourth Thursday of the month. Somewhere along the way, a few clever marketers dubbed this day “Thanksgivukkah”, and America has responded: the LA Times has a recipe for “turbrisket”, kids in South Florida have been designing “menurkeys”, and Zazzle.com has a line of Thanksgivnukkah greeting cards. Christine Byrne has assembled an entire Thanksgivukkah menuI, for one, am enjoying all of the portmanteaus. (Speaking of which, have you heard of Franksgiving?)

But in addition to being a fan of portmanteaus, I’m also a fan of calendars. Some weeks ago, I began to hear from various sources that Hanukkah won’t line up with Thanksgiving for another 70,000 years or so. This got me curious, so I started researching the question myself. It turns out that the relationship between the two holidays has been examined on at least three blogs over the past few years. The first were the Lansey brothers in 2010, followed by  Stephen Morse in 2012 and Jonathan Mizrahi in January of this year. Morse’s post includes a “When Did?” page with a Javascript calendar program, and Eli Lansey kindly includes a Mathematica notebook to help the math-inclined to do the computations themselves.

Morse reports that Thanksgiving will again occur on the first day of Hanukkah in the year 79,043, while Mizrahi says it’ll be in the year 79,811. Mizrahi, by his own admission, is being cute with this number:

In all honesty, though, all of these dates are unfathomably far in the future, which was really the point [of the post].

In this post, I won’t go into exactly how the ≈79,000 number was unearthed. I will, however, sketch out some of the major features of both the Gregorian and Hebrew calendars, and how they have given rise to this strange, new holiday of Thanksgivukkah. In the end, we will find that the year 79,811 is not nearly as unfathomable as we can get.

First of all, the Western calendar as we’ve come to know it began its life as the Egyptian calendar. After the Canopus Decree in c. 238 BCE, each year in the Egyptian calendar was 365 days long, with an additional day added every 4 years. There were twelve 30-day months and five (or six) epagomenal days—days with no year or month assigned to them—to celebrate the coming of the new year. I think Pharaoh Ptolemy III said it best:

This festival is to be celebrated for 5 days: placing wreaths of flowers on their head, and placing things on the altar, and executing the sacrifices and all ceremonies ordered to be done. But that these feast days shall be celebrated in definite seasons for them to keep for ever … one day as feast of Benevolent Gods be from this day after every 4 years added to the 5 epagomenae before the new year, whereby all men shall learn, that what was a little defective in the order as regards the seasons and the year, as also the opinions which are contained in the rules of the learned on the heavenly orbits, are now corrected and improved by the Benevolent Gods.

The Egyptian model came to Rome with Julius Caesar’s calendar reforms in 46 BCE, which fixed the seriously messed up Roman calendar. It all went pretty well for the first several centuries, but there was a tiny fly in the ointment. The average length of a year in the Julian calendar is 365.25 days, while the solar year is approximately 365.24219 days long. So the Julian calendar ran slow—about 11.25 minutes per year—for 1600 years until this problem was fixed by the Gregorian calendar reforms of 1582. More specifically, Pope Gregory XIII issued a papal bull, Inter gravissimas, in which he declared that leap years would continue to occur by 4 would be leap years, except that years divisible by 100 but not by 400 would no longer be leap years. So, 1900 was not a leap year, but 2000 was. This provides an average length of 365.2425, which is only 0.00031 days (about 27 seconds) longer than the solar year. In the 431 years that have passed since the birth of the Gregorian calendar, this error has only accumulated to 3.2 hours. While the calendar isn’t perfect, it’s really quite good, especially considering that the solution amounted merely to omitting 3 leap days every 400 years.

The key concept I’m interested in here is periodicity. In mathematics, a function is said to be periodic if it exactly repeats its values in regular intervals (or, periods). The sine function is an example of this: sin(x) = sin(x+2π) = sin(x+4π) = …, for any value of x in the interval [0,2π]. It’s very important to distinguish between a periodic function and a function that just happens to repeat some of its values. For example, the function f(x) = 1 – x2 repeats itself since f(-1) and f(1) are both equal to zero, but that doesn’t mean the function repeats itself exactly on an interval. Loosely speaking, a function is periodic when the entire curve repeats itself, not just a few select points.

We can transfer this idea to a given calendar without too much trouble:

• A calendar’s cycle is amount of time it takes for the calendar to repeat itself exactly.
• A calendar’s period is the amount of time it takes for the calendar to repeat itself exactly, while also taking the days of the week into account.

For consistency, it’s best to measure both the cycle and period in days, but sometimes I’ll divide by the average length of a year. For example, the Julian calendar has a cycle of 1461 days, and dividing by 365.25 gives a result of 4 years. To get the period, we need to remember that since there are 52 weeks plus 1 or 2 days in any given year, the days of the week won’t line up every 4 years. So we have to take the least common multiple to get the period: lcm(1461, 7) = 10,227 days = 28 years. For the Gregorian calendar, the cycle is 146,097 days (400 years) and the period is lcm(146097, 7) = 146097 days = 400 years—this is because 146097 happens to be a multiple of 7.

400 years is a long time, and this post has gotten pretty long, too. So I’ve broken it into two parts. Come back soon for Part II, where we will examine the mathematical labyrinth that is the Hebrew calendar…