WARNING: The following post includes math concepts and calendar calculations that certainly are NOT for the faint of heart.
As well, at request of c4ooo, I have put the equivalent mathematical equations in spoilers below each method. Please don't hate me...I eat my cereal dryyyyyyyy No, not that kind of Doomsday
As a geek, I have some weird, strange, burning obsessions from time to time. A lot of these have to do with math. This time, it is calendar math. Specifically, a way to calculate the day of the week for any given date. Since we haven't adopted
the World Calendar system yet, it's hard to find the day of the week if you're given a random date. For example, what day of the week was March 10, 1985? Don't use a calendar!
Give up?
It was Sunday.
See, it's hard to figure it out. And you only have a ~14.28% chance of guessing randomly, which isn't great. So what do we do? Well...in short, that depends on who you're talking to.
Purely Mathematical MethodsMath is a wonderful tool. You can use it for many different practical purposes...including and especially finding the day of the week. Here are a few popular methods for computing this.
Zeller's CongruenceChristian Zeller is a German mathematician, who specialized in this sort of mathematics. He had created a method for calculating the day of the week, given in a formula that goes like this:
The one disadvantage of this method is the unusual month counting convention; any date in January or February is treated as months 13 and 14 in the previous year. However, feeding in the "correct" numbers for
month,
day, and
year will adjust for you.
Gauss' AlgorithmJohann Carl Friedrich Gauss, another German mathematician, had described a method for calculating the day of the week for January 1st in any given year (only applicable to the Gregorian calendar), which was never published. The formula is this:
There have been modifications made to this to apply to any date, instead of only January 1st, which works in any calendar system. One such modification is as follows:
Mike Keith's C expressionIn 1990, an American mathematician and constrained-writing author named Mike Keith published the following terse self-contained C expression for calculating the day of the week of any day in the Gregorian calculator:
(d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7
This is equivalent to the following mathematical expressions:
This is equivalent to the following TI-BASIC code (with month, day, and year stored in M, D, and Y, and the result will be in Ans)
[1]:
:Y-(M<3
:round(7fPart((int(23M/9)+D+4+Y+int(Ans/4)-int(Ans/ᴇ2)+int(Ans/400)-2(M≥3))/7),0
Mental Calculation MethodsJust in case you don't have a high-speed computer (or TI-83+ calculator) with you at all times, here are some methods ENTIRELY involving memorization and mental calculation. You know...if you're into that sort of thing
Carrollian MethodCharles Lutwidge Dodgson (aka Lewis Carroll, famous for
Alice's Adventures in Wonderland and
Through the Looking Glass) was an insane writer by day, and an insane mathematician by day also. He had discovered
his own method of determining this (which was in Martin Gardner's book
The Universe in a Handkerchief: Lewis Carroll's mathematical recreations, games, puzzles, and word plays ), which goes as follows (my attempt to put it in clear English language):
- Calculate 4 numbers based on the century, the years past the century, the month, and the day of the month.
- #1: Century
- For "Old Style" (Julian[2]; valid up to September 2, 1752[3]), subtract the century from 18.
- For "New Style" (Gregorian; valid from September 14, 1752 onwards[3]), divide the century by 4, subtract the remainder from 3, then double that.
- #2: Year
- Add the number of "dozens" that go in the year, the remainder, and the number of 4s that go in that remainder.
- #3: Month
- If the month is January, the number is 0.
- If the month is February or March, the number is 3.
- If the month is December, the number is 12.
- If the month starts or ends in a vowel (y excluded), subtract the month number from 10 (i.e. April is month 4, so for April, 10-4=6).
- For any other month, take the number for the month before it, and add the number of days in that month (i.e. April=6, so May=6+30=36).
- #4: Day
- The item is simply the day number.
- HOWEVER, you must subtract 1 if the date is January or February in a leap year.
- Reminder: Every year divisible by 4 is a leap year, except an even century in "New Style" (Gregorian) where the number of centuries is not divisible by 4 (i.e. 1976 is, 2000 is, 1900 is not).
- Sum these 4 numbers, divide by 7, and take the remainder.
- The total is the day of the week (0=Sunday, 1=Monday, etc.)
Examples
September 18, 1783 (Gregorian)
17/4=4, remainder 1. 3-1=2. Double 2 is 4.
83/12=6, remainder 11. 11/4=2, remainder 3. 6+11+2=19.
The number for August is 10-8=2. August has 31 days. 2+31=33.
The day is 18.
4+19+33+18=74. 74/7=10 remainder 4.
Therefore, September 18, 1783 was a Thursday.
February 23, 1676 (Julian)
18-16=2.
76/12=6 remainder 4. 4/4=1. 6+4+1=11.
The number for February is 3.
The day is 23, but subtracting 1 (because 1676 is a Julian leap year) gives 22.
2+11+3+22=38. 38/7=5 remainder 3.
Therefore, February 23, 1676 was a Wednesday.
This is very cryptic, and hard to understand why it works (vowels in a month name have significance?), but it works!
Relevant formulae for "Carrollian" method:
Carrollian method
DoomsdayA much-simpler-to-understand-why-it-works formula comes from John Horton Conway (famous for his cellular automaton called
The Game of Life[4]), and is called the Doomsday Algorithm (named so because he wanted the name to end in -day, and "Dooms-" was the first thing that popped in his head). The principle is this: "Doomsday" is the day of the week of the last day in February in any year, and many easy-to-remember dates fall on Doomsday each year.
A list of some memorable Doomsdays in a year:
Month | Memorable Doomsdays | Mnemonics |
January | 3 (common), 4 (leap) 10 (common), 11 (leap) 31 (common), "32" (leap) | the 3rd for 3 years, and the 4th every 4 repeated number (1/11) in leap years, 1 day before in common years last day of January (but pretend January has 32 days in leap years) |
February | "0" (common), 1 (leap) 14 (common) 21 (common), 22 (leap) 28 (common), 29 (leap) | binary: is this year a leap year? (0=false, 1=true) Valentine's Day repeated number (2/22) in leap years, 1 day before in common years last day of February |
March | "0" 14 | last day of February (i.e. the day before March 1) Pi Day |
April | 4 | repeated number (4/4) |
May | 9 | "I work 9 to 5 at 7-11[5]" |
June | 6 | repeated number (6/6) |
July | 4 11 | Independence Day (USA) "I work 9 to 5 at 7-11[5]" |
August | 8 | repeated number (8/8) |
September | 5 | "I work 9 to 5 at 7-11[5]" |
October | 10 31 | repeated number (10/10) Halloween |
November | 7 | "I work 9 to 5 at 7-11[5]" |
December | 12 26 | repeated number (12/12) Boxing Day (i.e. the day after Christmas Day) |
All of the dates above (and many more, yet less memorable, ones) all fall on Doomsday in a year.
To calculate Doomsday, Conway presents this method:
- Take the "anchor day" for the century from a lookup table.
Century mod 4[6] | 0 | 1 | 2 | 3 |
Anchor day | Tuesday | Sunday | Friday | Wednesday |
e.g. From 1900 to 1999, the century mod 4 is 19 mod 4 = 3, so the anchor day is Wednesday. - Add the number of "dozens" that go in the year, the remainder, and the number of 4s that go in that remainder.[7]
- Count that many days from the anchor day. That day is Doomsday.
e.g. For 1958, 58/12=4, remainder 10. 10/4=2, remainder 2. 4+10+2=16=2 mod 7.
2 days from Wednesday=Friday.
From here, it's a matter of day and week counting in your head from the Doomsday and dates you've remembered.
Relevent formulae for Conway Doomsday method:
Conway Doomsday method
"Odd+11"Of course, there's always a better way
, and in this instance, the processes of dividing by 12 and 4 in step 2 of BOTH mental methods so far can be simplified further for mental calculation. It's been
done three times to my knowledge, but one of the easiest methods, called the
Odd+11 method, is described here:
- Let Y be the 2-digit year.
- If Y is odd, add 11.
- Divide Y by 2.
- If Y is odd, add 11.
- Take Y mod 7.
- Get the 7's complement, i.e. subtract from 7 (unless the number is 0, in which case the 7's complement is 0).
- The final result is your offset.
- e.g. For 1958:
- 58 is even, so do nothing.
- 58/2=29.
- 29 is odd, so 29+11=40.
- 40 mod 7=5.
- 7-5=2.
Relevant formulae for Odd+11 Doomsday method:
Odd+11 Doomsday method
I have a challenge for you: take your birthday (or any other day, so long as you tell me its significance), and find the day of the week it occurred on. Use any of the methods described above, but show your work!
Example: My birthday is January 23, 2001.
Using Doomsday with the Odd+11 method:
Anchor day for 2000 = Tuesday
1 is odd, so 1+11=12.
12/2=6.
6 is even.
7's complement of 6 is
1.
Doomsday 2001 = Tuesday+
1 =
Wednesday.
Closest memorable Doomsday: January 31 (common year)
January 31, as well as January 31 - 1 week = January 24, is a
Wednesday.
January 23 is 1 day before January 24.
Therefore, January 23 is 1 day before
Wednesday =
Tuesday.
Well, that's the end of my rant about my latest math geek obsession. Have fun with it, and I hope you find it useful! Also, if you have any questions, ask me and I'll explain.
[1]: I actually wrote this code back in November 2013! Wow, I guess this "obsession" of mine is old
[2]: Julian is referring to New Style Julian, which means that the New Year starts on January 1 (in contrast to Old Style Julian, which means that the New Year starts on March 23).
[3]: September 2, 1752 in Julian is the day before September 14, 1752 in Gregorian. The switch between calendar systems in most regions (not all) happened between those days. That's right, there's another calendar discrepancy to worry about.
[4]: You lost the game.
* JWinslow23 runs
[5]: 9:00 AM to 5:00 PM are traditional working hours, and this has evolved into the slang expression "9 to 5". 7-Eleven is a chain of convenience stores around the world.
[6]:
mod refers to modular arithmetic, i.e. numbers wrapping around after a certain point. For example, 8 bit numbers on an NES or TI-84+ work in modulo 256 arithmetic, because values go from 0 to 255, and wrap around.
[7]: Yes, this step is the same as in the Lewis Carroll algorithm! Both are actually a simplification of the "true" formula, y+int(y/4) . It's hard to divide large values by 4 in your head.