Saturday, November 26, 2011

Mathematics of the Calendar

Here is a note from Facebook that a friend posted. I responded with the answer in two comments. I’m saving the entire “conversation” here in my Notes to keep it intact. I edited my response somewhat to make it more clear (hopefully) and more complete.

I’m constantly the teacher imparting new knowledge. Please enjoy this analysis.

Thanksgiving day on the 28th of November 1901-2126
by Chuck Short on Friday, November 25, 2011 at 7:39am
Things I need to know, please....

A: Days Thanksgiving (US) has been and will be on November 28

B: Why the 11 year cycle, why the 6 year cycle in contrast to the 11 year cycle, and why is the cycle 12 years in 2109?

C: This has only occurred 3 times in my lifetime, and won't happen again until 2013, and then again 6 years later in 2019..

D: How would leap years figure into these cycles?

Year Compared to year 2013 Since last
1895 118 years before

1901 112 years before + 6 years
1907 106 years before + 6 years
1918 95 years before + 11 years
1929 84 years before + 11 years
1935 78 years before + 6 years
1946 67 years before + 11 years
1957 56 years before + 11 years
1963 50 years before + 6 years
1974 39 years before + 11 years
1985 28 years before + 11 years
1991 22 years before + 6 years
2002 11 years before + 11 years
2013 selected year + 11 years 49
2019 6 years after + 6 years 55
2030 17 years after + 11 years 66
2041 28 years after + 11 years 77
2047 34 years after + 6 years 83
2058 45 years after + 11 years 94
2069 56 years after + 11 years 105
2075 62 years after + 6 years 111
2086 73 years after + 11 years
2097 84 years after + 11 years
2109 96 years after + 12 years
2115 102 years after + 6 years
2126 113 years after + 11 years

And I know that Thanksgiving didn't become the last Thursday in November until the 40s. and longevity or getting old jokes are simply not welcome, so don't do it, I will simply never speak to you again, no matter who you are. Period. Thanks!!!

OK. You asked!

Well, that question really takes me back: 1966, Montana School of Mines, my first programming class, IBM 1401 – programming with punch cards using FORTRAN IV.

The class assignment was to list all of the dates for Thanksgiving until the “turn of the century.” So that was all the Thanksgiving days from 1967 until 2000.

In those days you wrote a program on a “coding sheet” which looks like a crossword puzzle all full of lines of squares. Then the program is copied on a punch card machine producing the program on cards. You then submit the cards at the window in the computer center and they run it on the mainframe computer. An hour or so later you would pick up your output which was a giant “fan-folded” paper with green bar background and see what mistakes you had made. Repeat this process until program runs. It could take days if the program was complex. As I recall it took me two days to get the program to run correctly.

The mathematics involved is called “modulo arithmetic” or “clock arithmetic.” Since the days of the week repeat on a seven day cycle, it is much like a clock that goes from 1 to 12 and then starts over at 1. The concept of modulo arithmetic is tied to division and using the REMAINDER. In the case of clocks you divide by 12 and the remainder gives the “answer.” With the days of the week, you divide by 7 and use the remainder.

So, let’s start with an easier question, what day of the week does Christmas, Dec. 25, fall on in a given year. Let’s start with last year. In 2010, Christmas was on a Saturday. Now, take 365 days in a year and divide by 7. You get 52 and a remainder of 1. So add the 1 to Saturday and you get Sunday. Yes, Christmas, this year, will be on a Sunday.

(Mathematically we way 365 div 7 = 52 and 365 mod 7 = 1. See, “mod” is just the remainder [and “div” is the quotient part as a whole number]. )

So, what about next year? Will Christmas be on a Monday? Uhhhh … no! It will be on Tuesday. WHAT! You forgot, next year is a leap year and the number of days in 2012 will be 366. Divide that by 7 and you get remainder of 2. Add 2 days to Sunday and you get Tuesday. So the cycle of days of Christmas is a simple +1, +1, +1, +2, +1, +1, +1, +2, …

So let’s start this cycle and see how long it takes to repeat.

Start with 2012 when Christmas is on Tuesday:
So, in 2013, Wednesday (+1),
2014, Thursday (+1),
2015, Friday (+1),
2016, leap year, Sunday (+2),
2017, Monday (+1)
2018, Tuesday (+1) — aha, we’ve circled back to Tuesday where we started in 2012. But is this really the complete cycle?

NO. Keep going:
2019, Wednesday (+1),
2020, Friday (+2).

So the first cycle went Tue., Wed., Thur., Fri., Sun., Mon.; and the second cycle is starting out Tue., Wed., Fri.! Note the pattern is varying. In fact, the total pattern is 4 x 7 or 28 years in length.

So why are the patterns in your Thanksgiving calculation following cycles of 6 and 11 years. Well, Thanksgiving is a little more complicated than Christmas because the cycle “sort of” resets itself periodically because it must always be the FOURTH Thursday of the Month.

Now it is more complicated figuring a holiday like Thanksgiving which is the fourth Thursday of the month of November, but the math is similar. So, if you apply all the rules and modulo arithmetic, you get the crazy chart you noted. That is where the cycle you noted come from. As Thanksgiving “rolls” off the end of November in the 28 year cycle, it gets “reset” with a minus 7. The math for that is a little more complicated and I won’t repeat it here.

By the way, your calendar went past the next century, 2100, so you have to make the “skip the leap year” calculation. What is the “skip the leap year calculation?” you ask.

Leap year is skipped in any year even divisible by 100. That is every century year such as 1900 and 2100. Note that 100 is divisible by 4, so it should be a leap year, but the leap year is skipped every 100 years to keep the calendar in sync. Now comes the big kicker. What about 2000? I think it was a leap year! That’s right!!

2000 was evenly divisible by 100, yet it WAS a leap year. You don’t skip the leap year in any year evenly divisible by 400. Now, check if you’ve got this figured out: Add a day to the year every 4 years (since the earth takes about 365 ¼ days to orbit the sun). But, skip the leap year every 100 years, BUT don’t skip it every 400 years. Wheww, I’m out of breath.

Once you have conquered the calculations for Thanksgiving (or Memorial Day or Labor Day), you are ready to calculate Easter which has a seasonal variation too. I’ll save that as an exercise left for the reader.

So there you have it, using only fifth grade math.

Comment 2, EXERCISE:

Ok, here is the part left as an exercise for the reader. Why the 6 and 11 year cyclic patterns? Recall from my last comment that the effect of there being 365 days in a non-leap year is to “advance” the day of a week of a given date, such as Christmas, by one day a year. And that a leap year, occurring every four years, advances the day by two. You also may have noted the earlier series of “Tue., Wed., Thur., Fri., Sun., Mon.” has six terms. That is a powerful hint. But what about the eleven year cycle?

Start with the fact that Thanksgiving is the fourth Thursday of November. Let’s convert that to a given date like the Christmas example by focusing on Nov. 1. If Nov. 1 is a Friday, then the first Thursday of November is six days later, Nov. 7. And the second Thur. is Nov. 14, and the third Thursday is Nov. 21, and the fourth Thur. is the Nov. 28 you are focused on. Note that Nov. 28 is the latest that Thanksgiving can ever be.

For comparison, assume Nov. 1 was on Thur. Then the second Thur. of the month would be Nov. 8, the third Nov. 15, and the fourth would be Nov. 22 – the earliest date that Thanksgiving ever falls on.

Now, again, consider the “progression” over the years of a given date as to its day of the week which is the series 1,1,1,2,1,1,1,2, … Now assume in a particular Nov. is a leap year (and therefore Nov. is “after” the extra day in February). That means the progression would start at the first 1 (of the 1,1,1,2 repeating series). Further, assume that Nov. 1 is a Friday. As we already saw, that would mean that Nov. 28 would be Thanksgiving that year.

Now the following year Nov. 1 is Sat. The year after that it is a Sun. The year after that it is a Mon. The next year is a leap year so it jumps to Wed. The year after that it is a Thur. and the year after that it is back to a Friday. Count those up. It cycled through the days of the week of which there are seven, but it skipped one day in the cycle. There is your six day cycle.

The 11 day cycle occurs when the leap year causes a skip over the Nov. 1 = Friday part. So now it has to cycle through “two weeks” or fourteen days of the week, but during that period it goes through three leap years, so subtract 3 from 14 and you get 11. (If you write out the series you’ll note one leap year in the first few years, one leap year that skipped over the Nov. 1 = Friday, and one leap year in the series of six after that. To make that clear, and as an exercise left to the reader, which term of the series would you start on to “skip over” the Nov. 1 = Friday? Is it 1(1), 1(2), 1(3), or 2(4)?)

I explained that non-mathematically without formulas and words can be … well … sort of wordy, but I think you see what is driving the two repeat numbers of 6 and 11. By the way, the one time you got 12 for the cycle time was 2109 and that’s because that period or cycle included the non-leap year of 2100. There by losing one +2 in the series and so it took one more day.

By the way, the first step to analyzing these kinds of things mathematically is exactly what you did. Write out several terms of the series and look for patterns. This ability to recognize and analyze patterns that is so common in mathematics and with mathematicians is one reason so many mathematicians are also musicians. After all, music is all about the patterns too. The scales(major, minor, Devonian, etc.) and the chord structure (major, minor, diminished, seventh) and the chord rotation (I, IV, I, V,IV, I).

In fact, when I was teaching programming and training programmers, we always selected the musicians and the mathematicians because they had these basic gifts or skills that also made them good programmers.