Sunday, September 12, 2010

A Perpetual Calendar in Your Head
By Dr. YingKing Yu
(Original Date: 9/12/2010)


Summary

This article presents an improved method for finding the day of the week for any given date of the form mm/dd/yyyy.  This method is based on the Doomsday Algorithm as proposed by Dr. John H. Conway in 1982[10][8][5].  It introduces five major concepts:

1.   An observation for identifying quickly 2-digit multiples of 4 based on the tens digits of the numbers.
2.   Using the concept of the highest multiple of 4 less than or equal to a given 2-digit number to quickly figure out the Doomsdays of centennial years.
3.   Using the same concept to quickly figure out the Doomsday of any year in a century.
4.   Introduce a quick way to find the Doomsday of any year in a century based on the tens digit and the ones digit of the year.
5.   Introduction of easy-to-remember days in January and February that have the same day-of-the-week as the Doomsday of the year.

In short, we believe this article presents a pretty comprehensive improvement that covers algorithms dealing with all different parts of a given date.


Introduction

If a friend tells you that he/she is going to move on the last day of September, you may wonder what day-of-the-week it lands on.  What is the date for Memorial Day this year?  Or you may even wonder what date today is.  There are a lot of other situations you want to look at a calendar.  What if a calendar is not handy? What if you can easily figure out the date or the day of the week in your head?  This article is trying to help you to do the latter.  With a little practice, it will be like you are carrying a perpetual calendar in your head!

Our Gregorian calendar would be easy to remember if we ignore the days of the week.  In each year, there are twelve months and each month has a fixed number of days except February.  February has 28 days in a common year and has 29 days in a leap year.  The calendar becomes complicated (and interesting) when we want to know which day of the week a day in a year belongs to.

First some definitions:

Month-day – a day of a month numbered by 1st, 2nd, …
Week-day – one of the seven days of the week (Sun, Mon, Tues, …, Sat)
Doomsday – the week-day of the last day of February

Well, this year is year 2010.  Do you know the week-day for July 4?  It is a Sunday!  I know it because, with a simple calculation in my head, I find out it has the same week-day as the Doomsday of this year which is Sunday.

Dr. John H. Conway[10] was the first person to introduce the concept of Doomsday along with a method for mentally figuring out the week-day of any given date.  In particular, he discovered that almost all the months in a year have at least one easy-to-remember day that has the same week-day as the Doomsday of the year.  This has been an enabling force for mentally figuring out the week-day of a given date.  In recent years, a few people have made proposals for improving his method[1][2][3].  This article presents yet another proposal for improvement.  We believe the improvement is pretty comprehensive in that it provides improved algorithms that deal with all different parts of a date of the form mm/dd/yyyy.


1.   Doomsdays

The term "Doomsday" has been used in existing literatures in a somewhat loose manner.  Most of the time, it means the week-day of the last day of February.  Many times, it may also mean a day of a month that has the same week-day as that of the last day of February.  To minimize confusion, we are going to use the term "Doomsday" (with capitalized initial) only for the week-day the last day of February lands on.  This will allow us to talk about "the" Doomsday of a given year.  We define "doomsday" (with lower-case initial) to be a day of a month having the same week-day as the Doomsday of the year.  So "Doomsday" is a week-day and "doomsday" is a month-day. 

While there is only one Doomsday, there are many doomsdays in a year.  As a matter of fact, every week there is a doomsday.  So, you can figure out the week-day of any day in a year if you know a nearby doomsday.  Some doomsdays are easy to find.  The last day of February is a doomsday by definition. From this we know all month-days of multiples of 7 (7th, 14th, …) of March are doomsdays.  Same for the days of February in a common year.  For a leap year, just add 1 to the days of multiples of 7 (1st, 8th, …) 

What about other months?  It turns out most months have at least one doomsday that is easy to remember as pointed out by Dr. John H. Conway[10].  First, for even months, the days 4/4, 6/6, 8/8, 10/10 and 12/12 are all doomsdays. What a wonderful discovery!

In order to remember the doomsdays for the odd months, try to remember the following sentence:

          "I work from 9 to 5 at the 7-11."

Here '7-11' refers to the almost ubiquitous 7-Eleven convenient store chain.  It will help you to remember that 5/9, 9/5, 7/11 and 11/7 are all doomsdays.  Also notice that, like March, all month-days of multiples of 7 in November are doomsdays.

January is probably the hardest month for finding an easy-to-remember doomsday.  Many attempts have been made, but none is nearly as easy as the other months.  One proposal is based on the fact that February has 28 or 29 days.  The day 1/31 is a doomsday if the year is a common year.   Otherwise, 1/32 is a doomsday.  Well, 1/32 is not really a day in January, so we subtract a week from it and get 1/25.  Not too bad, right?  Another proposal is to remember the fact that 1/3 is a doomsday 3 out of 4 years (in common years.)  And 1/4 is a doomsday only in a leap year.  It sounds like it is just playing around with the numbers 3 and 4.

I have come up with a proposal which tries to tie together the two months (January and February) whose doomsdays are leap year dependent.  Look at Jan 11 (1/11) and Feb 22 (2/22).  Can you see a pattern here?  They happen to be doomsdays in leap years.   For common years, just subtract 1 from each and get the doomsdays 1/10 and 2/21.  This proposal has the advantage of having a pattern that gets along well with the pattern 4/4, 6/6, 8/8, 10/10 and 12/12.  Notice that these last 5 doomsdays are leap year independent, while  1/11 and 2/22 are leap year dependent. (That's why they have a slightly different pattern. Right?)

Note that only the doomsdays in January and February are leap year dependent.  Those in other months are not.  Let us summarize with the following

The Doomsday Algorithm:

  1. The Doomsday of a year is the week-day of the last day of February.
  2. A day in a year is called a doomsday if its week-day is the same as the Doomsday of the year.
  3. Each month has at least one doomsday that is easy to remember:

    1. Jan and Feb: 1/11, 2/22 for leap years, subtract 1 day from each otherwise
    2. March: all days that are multiples of 7 (3/7, 3/14, 3/21, 3/28)
    3. Other even months: 4/4, 6/6, 8/8, 10/10, 12/12 (none easier!)
    4. Other odd months:  5/9, 9/5, 7/11, 11/7 ('I work from 9 to 5 at the 7-11')

  1. If we know the Doomsday of a year, then we can figure out the week-day of any day in the year.  We do this by stepping forward or backward from a nearby doomsday in the same month as that of the given day.

Let us look at a few examples. 

  1. What is the week-day for Independence Day (7/4) this year (2010)?  Knowing 7/11 is a doomsday (its week-day is Sunday), 7/4 should also be a Sunday since it is a week before 7/11.  Can you see from the argument here that July 4 is a doomsday in any year?

  1. What is the date for Labor Day in USA (first Monday in September) this year?  Well, since 9/5 is a doomsday, the next day (9/6) should be the first Monday of September.

  1. The Doomsday for year 2000 is Tuesday.  What is the week-day for 5/22/2000?  Since 5/9 of that year is Tuesday, we know 5/14 should be a Sunday by adding 5 more days to the 9th.  Therefore, 5/21 is a Sunday and 5/22 is a Monday.  By the way, finding the date of a Sunday in a month first may make it easier to identify the week-day of a desired day in the month.

As you can see, using the Doomsday Algorithm, it is not hard at all to determine the week-day of any given date in a year as long as you know the Doomsday of the year.

The question now is: Can we figure out the Doomsday of any year in our heads?  The answer is a definite 'Yes'!  Read on.

2. The Simple Fact

We want to point out the following

The Simple Fact: The Doomsday advances by 1 each common year and by 2 each leap year.

This means that we increase the Doomsday of a year by 1 to get to the Doomsday of the following year, if the latter is a common year, by 2 otherwise.  This is because there are 365 days (52 weeks plus 1 day) in a common year and 366 days (52 weeks plus 2 days) in a leap year. 

You will see that all Doomsday calculations are essentially based on this simple fact.

The Doomsday for 2010 is Sunday. The Doomsday for next year should be Monday because 2011 is a common year.  Stepping backward, the Doomsday should be decremented by 1 if the current year is a common year and by 2 otherwise.  Hence the Doomsday for 2009 should be Saturday and the Doomsday for 2008 is Friday.  Since year 2008 is a leap year, the Doomsday for 2007 should be Wednesday. 

Reasoning along this line, we should be able to find out easily the Doomsdays of the few years before and after a year with known Doomsday. 

So, let us figure out the week-day for 8/3/2005 knowing that the Doomsday of 2010 is Sunday.  First, we have to find the Doomsday for year 2005.  During the stepping back of 5 years to get to year 2005, we encounter only one leap year (2008).  So we have to subtract 6 week-days from Sunday and get Monday and this is the Doomsday of 2005.  That means 8/8 of this year is a Monday.  The week-day of 8/3 can be found by subtracting 5 days from Monday and get Wednesday.  By the way, subtracting 5 days from a week-day to get a new week-day is the same as adding 2 days.  In general, subtracting n week-days is the same as adding (7 – n)  days, where (7 – n) is called the 7-complement of n.

3.  Doomsdays of the Years Within a Century

Next, we want find the Doomsday of any year within a century.  We know that the Doomsday of year 2000 is Tuesday.  Using The Simple Fact, we should be able to find the Doomsday of any year in this century albeit it may be tedious and hard to do so in your head.  So let us find a better way.

We will represent a year with a 4-digit number of the form cdyz.  The number formed by first two digits cd is called the century number while the number formed by the last two digits yz is called the year number (within the century).   Here are some words of caution.  In this article, when cd or yz appears in an arithmetic expression or an equation, it always represents a two-digit number not a product of two numbers.

We will use the numbers from 0 to 6 to represent Sunday, ..., Saturday respectively when a week-day is involved in a calculation.  We also use an expression of the form abc(n) to remind us that the week-day abc is represented by the number n. For example, we sometimes write Monday as Mon(1).

When a number representing a week-day is in the range 0 to 6, it is called the normal week-day representation.  During computation, a week-day is often represented by a number N other than one of 0 to 6 perhaps as a result of adding or subtracting days.  In such cases, we can always reduce N to a normal representation by adding or subtracting a large enough multiple of 7 since each increment or decrement of 7 days ends up with the same week-day.  Effectively, this is the remainder, on division of the number N by 7 if N is a non-negative integer.  For readers familiar with modular arithmetic, this remainder is represented by (N mod 7).  If two numbers x and y have the same normal representation, then we will say that x and y are equivalent.  We often use the notation x ~ y to indicate such a relationship.  It can be shown that x ~ y if and only if x = 7n + y for some n.

3.1  The Basic Algorithm for Finding Doomsdays for Years Within a Century

For now, we will focus only on the year number yz which has values ranging from 00 to 99.  We will assume that we already know the Doomsday of cd00 to be C (a number in the range 0 – 6).  We will use this year (a centennial year) together with its Doomsday as a reference point.  To find the Doomsday of year cdyz, we would ask ourselves: what is the size of the increment we have to make to the Doomsday of year cd00 (C) when we reach year cdyz?  According to The Simple Fact, for each passing year, we have to increment the Doomsday by 1 day and an extra day if the year is a leap year.  From cd01 to cdyz, every fourth year is a leap year.  If we divide yz by 4 and get the quotient Q, then Q is the number of leap years.  Let I be the size of increment we have to make. Then I = yz + Q.  The Doomsday of year cdyz  should be C + I.  This number would most likely be greater than 7.  We can reduce it to a normal representation by dividing (C + I) by 7 and getting the remainder D.  We can summarize this with these steps:

The Basic Algorithm for Finding Doomsdays of Years Within a Century:

  1. Assume the Doomsday of cd00 is C.
  2. Divide yz by 4 to get the quotient Q.
  3. Compute the size of increment I = yz + Q.
  4. Add I to the centennial Doomsday: C + I
  5. Divide (C + I) by 7 to get the remainder D.  Then, D is the Doomsday of cdyz.

For convenient, we will sometimes use the symbols, x/y and x\y to represent the quotient and the remainder respectively when a number x is divided by another number y. 

The basic algorithm can now be stated in a simpler form:

Doomsday of cdyz = (C + yz + yz/4)\7, where C is the Doomsday of cd00

If we are interested in the increment only, then it can be written as:

(yz + yz/4)\7

If we do not need a normal representation, the following even simpler form will do:

yz +yz/4

Let us find the Doomsday for year 2087 step by step.
 
  1. The Doomsday of year 2000 is Tue(2)
  2. Divide 87 by 4 and get the quotient Q = 21. 
  3. The size of increment I = 87 + 21 = 108
  4. I + 2 = 108 + 2 = 110.
  5. Dividing 110 by 7 and get the remainder D = 5. 

Therefore the Doomsday for year 2087 is Fri(5).  That means 2/28/2087 is a Friday.

As a shortcut, we actually can start throwing away multiples of 7 from I after we get the quotient Q.  In the previous example, we see I = 87 + 21 in Step 3.  Instead of doing the addition, we can throw away 70 from 87 and all of 21.  Then we have I = 17 + 0 = 17 = 14 + 3 ~ 3. 

As you can see from the example above, The Basic Algorithm, though simple and easy to understand, may not be suitable for mental computation when the year number yz is high. 

Now let us look at the increment I = yz + Q.  If R is the remainder from dividing yz by 4, then yz = 4Q + R.  Notice here that 4Q is also the highest multiple of 4 <= yz.  The total increment I can also be computed as:

The 5Q Equation:                       I = 5Q + R

This simply reiterates the fact that we have to increment the Doomsday of cd00 by 5 days for each 4 years until we get to year yz within the century cd00.  In particular, I = 5Q if yz is a multiple of 4.  This equation plays a crucial role in deriving the algorithms that follow.

3.2  The Highest Multiple of 4 Algorithm

Armed with the help of The 5Q Equation just described, we are going to derive a much easier algorithm for finding Doomsday increments for years within a century. 

Recall the 5Q Equation: I = 5Q + R.  Since 5Q = 7Q – 2Q, we have I = 7Q – 2Q + R.  But this is equivalent to -2Q + R since we can throw away the multiple of 7 7Q.  Suppose S is the smallest multiple of 7 >= 2Q.  Then S – 2Q is the normal representation of -2Q.  And we would have (-2Q + R) equivalent to (S – 2Q) + R. 

Note: The introduction of -2Q and (S - 2Q) has been inspired by the work of Mike Walters[3].

This gives us the following algorithm for finding an equivalent increment:

The Highest Multiple of 4 Algorithm:

Given any year cdyz, to find an equivalent increment I to be added to the Doomsday of cd00,
  1. Find the highest multiple of 4 <= yz: 4Q
  2. Subtract yz by this number and get the remainder: R
  3. Halve 4Q: 2Q
  4. Find the smallest multiple of 7 >= 2Q: S
  5. Add the difference (S – 2Q) to R to get the increment: I

For a 2-digit number like yz, there is a shortcut to find 4Q in steps 1 using the following observations for numbers ranging from y0 to y9:

2-digit Multiples of 4 Observations:

For any two-digit number yz, where y is the tens digit and z is the ones digit,
         i.    If y is an even number, then yz is a multiple of 4 if and only if z = 0, 4 or 8.
        ii.    If y is an odd number, then yz is a multiple of 4 if and only if z = 2 or 6.

For examples, the highest multiple of 4 <= 58 is 56 according to observation (ii) and the highest multiple of 4 <= 68 is 68 itself according to observation (i).

To find the week-day of a day in January or February, we will need to know whether the year in question is a leap year.  You will find that these observations come in handy.

Let us combine The Highest Multiple of 4 Algorithm and the 2-digit Multiples of 4 Observations to find the Doomsday increment for 87:

  1. Since the tens digit of 87 is even, the highest multiple of 4 <= 87: 4Q = 84
  2. The remainder: R = 87 – 84 = 3
  3. Half of 84: 2Q = 42
  4. The smallest multiple of 7 >= 42: S = 42
  5. S – 2Q = 42 - 42 = 0
  6. I = (S – 2Q) + R = 0 + 3  = 3

Adding the increment 3 to the Doomsday of 2000 (2), we get Fri(5), the Doomsday of 2087.

Next, we want to present a table-look-up algorithm originally introduced by Fong[1].  We will make a proposal for improving it and provide a proof.

3.3  A Table Lookup Algorithm

In a recent document[1],  Chamberlain Fong proposed a table lookup method for finding Doomsdays of years within a century. In this section, we are going to see how we find an alternative table lookup algorithm based on The 5Q Equation.  We begin by providing a mathematical proof of Fong's method which was only proved with brute force.

Given a 2-digit year number yz, where y is the tens digit and z is the ones digit.  Let z = 0 for now.  We can write yz = 10y.  (Caution: yz is a 2-digit number, not the product of y and z.) 

If y is even, let y = 2n for some n.  Then, yz = 10y = 10x2n = 4x5n.  Since yz is now a multiple of 4, according to The 5Q Equation, it has an equivalent Doomsday increment

                   I = 5x5n = 25n = 21n +4n ~ 4n = 2y

If y is odd, let y = 2n + 1 for some n.  Then

yz = 10y = 10(2n + 1) = 20n + 10 = 4x5n + 4x2 + 2 = 4(5n + 2) + 2

According to The 5Q Equation, it has an equivalent Doomsday increment

                   I = 5(5n + 2) + 2 = 25n + 10 + 2 = 21n + 4n + 7 + 5 ~ 4n + 5

This gives us I = 4n + 2 + 3 = 2(2n + 1) + 3 = 2y + 3.  To summarize:

          I = 2y          if y is even
          I = 2y + 3   if is odd

This covers the tens digit part of the expression given in Fong's document:

2y + 3(y mod 2)

The increment determined by ones digit part z is pretty straight forward.  Let J be the increment we have to add for the ones digit z.  According to the 2-digit Multiples of 4 Observations,

                             i.        When y is odd,
J  =    z                  if   0 <= z < 2
z + 1           if   2 <= z < 6
z + 2           if   6 <= z

                            ii.        When y is even,
J  =    z                  if   0 <= z < 4
          z + 1           if   4 <= z < 8
          z + 2           if   8 <= z
     
This J covers the ones digit part of the expression given in Fong's document:

z + [2(y mod 2) + z] / 4

Having proven the validity of Fong's formula, we proceed to propose an alternative table lookup method which some people may find it easier.  Instead of using the following tens digit table (as suggested by Fong)

y
0
1
2
3
4
5
6
7
8
9
I
0
5
4
2
1
6
5
3
2
0

we are proposing:

Tens Digit Table

y
0
1
2
3
4
5
6
7
8
9
I
0
3
4
0
1
4
5
1
2
5

Notice that the values for I are the same in both tables when y is even.  Here is the rationale behind the construction of this last table.  For all odd y, we think of y0 as x8, where x = y – 1.  The number x8 is 2 less than y0 and is always a multiple of 4.  The I value in the proposed table is computed as though y is x8.  For example, 70 is thought of as 68.  Since 68 = 4x17, I = 5x17 according to the 5Q Equation.  Therefore I = 5x17 = 7x17 – 2x17 ~ -2x17 = - 34 ~ 35 – 34 = 1.  And this is the value for I when y = 7. 

The table below is for the ones digit.  The only requirement is to add 2 to the ones digit before using the table when the tens digit is odd.

Ones Digit Table

z
0
1
2
3
4
5
6
7
8
9
10
11
J
0
1
2
3
5
6
7
8
10
11
12
13

Notice this table is simply saying that J = z + (# of non-zero multiples of 4 <= z).  So it is probably easier to figure out J this way than remembering the table.

Let us find a Doomsday increment I for yz = 75 using this table lookup method.  From the Tens Digit Table, we get I = 1 for y = 7.  Since y is odd, we add 2 to the ones digit 5 and get z = 7.  Now consult the Ones Digit Table, we get the second increment J = 8.  Therefore an equivalent Doomsday increment for yz = 75 is I + J = 1 + 8 = 9 ~ 2.   So, if we are looking for the Doomsday for 2075, it should be 2 + 2 = 4 (Thursday!)

What is left now is to try to find some easy way to remember the Tens Digit Table.  We are proposing to split the table into two halves, one for the even values of y and one for the odd values of y.

Tens Digit Table (even)

y
0
2
4
6
8
I = 2y
0
4
8 or1
12 or 5
16 or 2

Tens Digit Table (odd)

y
1
3
5
7
9
I = 2y+1
3
7 or 0
11 or 4
15 or 1
19 or 5


As shown in the two tables, we can simply get the value of I by doubling y and adding 1 only if y is odd.  Again, we may not even need the tables anymore!  Of course, if you want to do it super fast, memorizing the table may still make sense.

Let us summarize the above with

The Table Lookup Algorithm:

To find an equivalent Doomsday increment for a 2-digit year number yz within a century,
  1. Look up a corresponding I value for the tens digit y in the Tens Digit Table
  2. If y is an odd number, add 2 to z: z = z + 2
  3. Look up a corresponding J value for z in the Ones Digit Table
  4. The sum I + J is an equivalent Doomsday increment

If you find it hard to remember the tables, you can use the following alternative form of the algorithm.
  1. Double the tens digit y and get I = 2y
  2. If y is odd, add 1 to I and add 2 to z: I = I + 1, z = z + 2
  3. Determine the number m of non-zero multiples of 4 <= z
  4. Add m to z and get J = z + m
  5. The sum I + J is an equivalent Doomsday increment

Let us look at two examples:

1.   Find an equivalent Doomsday increment for yz = 58. 
From the Tens Digit Table, the corresponding I value for 5 is 4.  Since 5 is odd, add 2 to the ones digit 8 and get 10.  From the Ones Digit Table, the corresponding J value for 10 is 5.  This gives us the Doomsday increment = 4 + 5 = 9 ~ 2 (Tuesday).

2.   Knowing the Doomsday of 2000 is Tue(2), find the Doomsday for 2089. 
Since yz = 89 and y is even, double 8 and get I = 16 ~ 2.  There are 2 multiples of 4 <= 9.  So J = 9 + 2 = 11 ~ 4.  Therefore, an equivalent Doomsday increment = I + J = 2 + 4 = 6.  Add this to the centennial Doomsday to get the Doomsday of 2089: 6 + 2 = 8 ~1 (Monday)

One great advantage of computing Doomsday increment this way is that we only have to deal with relatively small numbers and most people can do it easily in their heads.

4. Finding Doomsdays for centennial years

So far, we have been assuming that we already know the Doomsday of cd00 in order to find the Doomsday of any year cdyz in the century.  Years of the form cd00 are called centennial years.  How do we figure out their Doomsdays?

Two important facts about our Gregorian Calendar system:

1.   A centennial year is a NOT a leap year unless it is evenly divisible by 400.  Hence the years 2000 and 2400 are leap years, while the years 1900 and 2100 are not.

2.   The Gregorian calendar repeats itself every 400 years.  This means that years 1600, 2000 and 2400 all have the same calendar.  So do the years 1944 and 2344.

From the last fact, we know we can find the Doomsday of any centennial year if we know the Doomsdays of four consecutive centennial years like 2000, 2100, 2200 and 2300.  We already know that the Doomsday of year 2000 is Tue(2).  It will serve as a reference point.  To find the Doomsday of year 2100, we are going to use The Simple Fact mentioned earlier: Doomsday advances by 1 each common year and by 2 each leap year. 

Year 2100 is 100 years after year 2000.  Every fourth year is a leap year except the last year (2100) since it is centennial year not evenly divisible by 400. This gives us a total of 24 leap years.  So the Doomsday of year 2100 is obtained by advancing the Doomsday of year 2000 by 124 (100 + 24).  That is 2 + 124 = 126. Now divide 126 by 7 and get the remainder 0.  This means that the Doomsday of year 2100 is Sunday(0).  Effectively, the Doomsday is increased by 5 for these 100 years.  In general, we can show that from one centennial year to the next, the Doomsday is increased by 5 if the ending centennial year is a common year and by 6 otherwise.  So the Doomsday for the centennial year 2200 is 0 + 5 = 5 meaning it is Friday(5).  The Doomsday for 2300 is 5 + 5 = 10. Throwing away 7, we get 3.  Therefore, it is Wednesday(3).  The Doomsday for 2400 is 3 + 6 = 9 (why?).  Throwing away 7, we get 2 (Tuesday) which is the same as the Doomsday of 2000.  This is compatible with the fact that the Gregorian calendar repeats itself every 400 years.  The following table summarizes what we have found out for some centennial years:

Year
Doomsday
2000
2
2100
0
2200
5
2300
3
2400
2
2500
0
2600
5
2700
3

Since our calendar repeats itself every 400 years, we see that, starting with a centennial year that is a leap year, the Doomsdays of centennial years keep repeating the sequence: 2, 0, 5, 3. 

In general, it can be shown that we can use the following algorithm for finding the Doomsday of a centennial year cd00.

Centennial Year Doomsday Algorithm:

  1. Divide cd by 4 to get the remainder r
  2. Compute 2 + 5r
  3. Divide (2 + 5r) by 7 to get the remainder.  This remainder is the Doomsday of year cd00.

Notice that the centennial year cd00 is a leap year if and only if the remainder r = 0.

Although the sequence 2, 0, 5, 3 is not that hard to remember, we can actually replace it with an even easier sequence: 9, 7, 5, 3. This is because 9 = 2 + 7 and 7 = 0 + 7.

You may find it easier to use the following table to get the correct Doomsday after finding the remainder r in step 1:

Centennial Remainder-Doomsday Table

Remainder
Doomsday
0
2 or 9
1
0 or 7
2
5
3
3


If you recall the shortcut for finding the highest multiple of 4 <= a given 2-digit number, we can use it here to find the remainder on division of cd by 4.   With this shortcut, we have an alternative form of Centennial Year Doomsday Algorithm:

Centennial Year Doomsday Algorithm (Alternative Form):

To find the Doomsday of cd00:
  1. Use 2-digit Multiples of 4 Observations to get the remainder r on the division of cd by 4.
  2. Map r into a Doomsday using Centennial Remainder-Doomsday Table.

For example, to find the Doomsday of year 6900,

  1. Since 6 is even, the highest multiple of 4 <= 69 is 68. The remainder is 69 – 68 = 1
  2. This remainder (1) is mapped to 0 or 7. Therefore the Doomsday of 6900 is Sun(0)

5. Finding the week-day of an arbitrary date

By now, we should know there are three major steps in finding the week-day of an arbitrary date of the form mm/dd/cdyz.  First, we have to find the Doomsday of the centennial year cd00.  The Centennial Year Doomsday Algorithm helps us to accomplish this.  Most of the times, we probably will be interested in dates only in this century (2000s) or the last (1900s).  In this case, you can skip this step just by remembering that the Doomsday of 1900 is Wed(3) and that of 2000 is Tue(2).  Next, we have to find an equivalent Doomsday increment using the 2-digit year number yz.  Here we can make use of either The Highest Multiple of 4 Algorithm or The Table Lookup Algorithm.  Adding the increment to the centennial Doomsday will give us the Doomsday for the year cdyz.  Finally, we can use the Doomsday Algorithm to determine the week-day for the month-day mm/dd in year cdyz.

Let's look at a few of examples. 

Example 1. To find the week-day for 5/20/1985:

1)     Determine the Doomsday of 1900: C  (using The Centennial Year Doomsday Algorithm)
a.    Since the tens digit of 19 is odd, the highest multiple of 4 <= 19 is 16
b.    The remainder r = 19 – 16 = 3
c.    C = 2 + 5r = 2 + 5x3 = 17 ~ 3
2)     Determine the Doomsday increment for yz = 85: I  (using The Highest Multiple of 4 Algorithm)
a.    Since the tens digit of 85 is even, the highest multipe of 4 <= 85: 4Q = 84
b.    The remainder R = 85 – 84 = 1
c.    Half 4Q: 2Q = 42
d.   The smallest multiple of 7 >= 42: S = 42
e.    I = S – 2Q + R = 42 -42 + 1 = 1
3)     Determine the week-day for 5/20/1985
a.    The Doomsday for 1985 = C + I = 3 + 1 = 4 (Thursday)
b.    For the month of May, 5/9 is a doomsday (its week-day is a Thursday). 
c.    Three days later 5/12 is a Sunday. Another week later, 5/19 is also a Sunday. Therefore the week-day for 5/20/1985 should be a Monday.

Example 2. To find the week-day for 1/2/3456:

1)     Determine the Doomsday of 3400: C  (using the alternative form of Centennial Year Doomsday Algorithm)
a.    Since the tens digit of 34 is odd, the highest multiple of 4 <= 34 is 32
b.    The remainder is 34 – 32 = 2
c.    According to Centennial Remainder-Doomsday Table, the remainder 2  is mapped to Doomsday 5.  That is, C = 5.
2)     Determine the Doomsday increment for yz = 56: I  (using The Table Lookup Algorithm)
a.    From the Tens Digit Table, locate the corresponding I value for 5: I = 4
b.    Since 5 is odd, add 2 to z: z = 6 + 2 = 8
c.    From the Ones Digit Table, locate the corresponding J value for 8: J = 10 ~ 3
d.   The Doomsday increment: I = I + J = 4 + 3 = 7 ~ 0
3)     Determine the week-day for 1/2/3456
a.    The Doomsday of 3456 = C + I = 5 + 0 = 5 (Friday)
b.    For the month January, 1/11 is a doomsday because year 3456 is a leap year (with the help of 2-digit Multiples of 4 Observations.)  That means the week-day for 1/11 is a Friday.
c.    Then 1/4 is also a Friday (the week before).  Hence 1/2 is a Wednesday.

Example 3.  To find the date for the Memorial Day of 2233:

1)       Determine the Doomsday of 2200: C  (using the alternative form of Centennial Year Doomsday Algorithm)
a.    Since the tens digit of 22 is even, the highest multiple of 4 <= 22 is 20
b.    The remainder is 22 – 20 = 2
c.    According to Centennial Remainder-Doomsday Table, the remainder 2  is mapped to Doomsday C = 5
2)       Determine the Doomsday increment for yz = 33: I  (using the alternative form of The Table Lookup Algorithm)
a.    Double the tens digit: I = 2x3 = 6
b.    Since the tens digit 3 is odd, add 1 to I: I = I + 1 = 6 + 1 ~ 0
c.    Since the tens digit 3 is odd, add 2 to z: z = z + 2 = 3 + 2 = 5
d.   Determine the number m of non-zero multiples of 4 <= 5: m = 1
e.    Add m to z: J = z + m = 5 + 1 = 6
f.     Add J to I to get the Doomsday increment: I = I + J = 0 + 6 = 6
3)       Determine the date for the Memorial Day in 2233
a.    The Doomsday of 2233 = C + I = 5 + 6 = 11.   This is equivalent to 4 (Thursday)
b.    Memorial Day is the last Monday of May.  For the month of May, 5/9 is a doomsday.  That means the week-day for 5/9 is a Thursday. 
c.    Therefore three days earlier 5/6 is a Monday.  Three weeks (21 days) later 5/27 should also be a Monday and this is Memorial Day of 2233.

If we are still using the Gregorian Calendar system in years beyond 9999, then we have to deal with year numbers with 5 or more digits.  However, there is no need to worry!  It turns out that the Doomsday of any year with year number ending with four zeros, such as year 3450000, is always Tue(2).  This is because such a year number is evenly divisible by 400.  Since the Gregorian calendar repeats every 400 years, the Doomsday of any two years with the same last 4 digits are the same.  For example, the Doomsday of year 123456 is the same as that of 3456.  In other words, the algorithms we have learned in this article apply to years beyond 9999.

Note: To find the week-day of any date, you may want to keep in mind that the Gregorian calendar system was not adopted until Friday October 15, 1582.  At the beginning, only a few European countries including Italy and Spain adopted the system.  The British Empire (United States included) did not adopt it until 1752.



References and Links

3.   An Improved Doomsday Algorithm by Mike Walters
7.   What is the day of the week, given any date? by William H. Jefferys
10.        Winning Ways: For Your Mathematical Plays, Vol. 2, by Richard Guy, John Horton Conway, Elwyn Berlekamp, Academic Press (August 1982)
















3 comments:

  1. You are welcome to leave a comment.

    ReplyDelete
  2. Thank Bob Goddard for pointing out the misuse of the Doomsday/doomsday convention in the last 3 examples. I've made the correction on this and on other typos.

    ReplyDelete
  3. Dr YingKing,

    This is truly an amazing Blog. Great Work

    ReplyDelete