The Doomsday Rule

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

User avatar
lu6cifer
Posts: 230
Joined: Fri Mar 20, 2009 4:03 am UTC
Location: That state with the all-important stone

The Doomsday Rule

Postby lu6cifer » Wed Nov 10, 2010 11:45 pm UTC

The Doomsday algorithm, created by John Conway, is a way to calculate the day of the week of any given date.
Wikipedia Link

Does anyone know why this works? Conway's algorithms aren't making much sense to me, and the wikipedia page doesn't offer much explanation. Besides his calculations, one thing I'm having trouble with is this:

It takes advantage of the fact that within any calendar year, the days of 4/4, 6/6, 8/8, 10/10, 12/12, and the last day of February always occur on the same day of the week—the so-called "doomsday" (and furthermore that other months have "doomsday" on the pairs 5/9 and 9/5 as well as 7/11 and 11/7


This is true--In 2010, all those listed days were a Sunday, and wikipedia says that January 3rd and the last day of non-leap year Februarys are the doomsday...But how is that true? How does that just happen to line up?

And why do you need an "anchor" day?

I've copied some of the math below, if anyone's interested:

Spoiler:

1. Divide the year's last two digits (call this y) by 12 and let a be the floor of the quotient.
2. Let b be the remainder of the same quotient.
3. Divide that remainder by 4 and let c be the floor of the quotient.
4. Let d be the sum of the three numbers (d = a + b + c). (It is again possible here to divide by seven and take the remainder. This number is equivalent, as it must be, to the sum of the last two digits of the year taken collectively plus the floor of those collective digits divided by four.)
5. Count forward the specified number of days (d or the remainder of d/7) from the anchor day to get the year's Doomsday.

And an easier method to get the Doomsday is [imath](y + \lfloor y/4 \rfloor) \bmod 7 + anchor day[/imath], where y is the last two digits of the year.
lu6cifer wrote:"Derive" in place of "differentiate" is even worse.

doogly wrote:I'm partial to "throw some d's on that bitch."

User avatar
gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: The Doomsday Rule

Postby gmalivuk » Wed Nov 10, 2010 11:58 pm UTC

What is it, specifically, that you don't understand? They line up because 4/4, 6/6, 8/8, 10/10, and 12/12 are all 63 days apart, which is divisible by 7. (And the last day of February is 35 days before 4/4, whether it happens to be the 28th or 29th.)
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

User avatar
lu6cifer
Posts: 230
Joined: Fri Mar 20, 2009 4:03 am UTC
Location: That state with the all-important stone

Re: The Doomsday Rule

Postby lu6cifer » Thu Nov 11, 2010 12:19 am UTC

gmalivuk wrote:What is it, specifically, that you don't understand? They line up because 4/4, 6/6, 8/8, 10/10, and 12/12 are all 63 days apart, which is divisible by 7. (And the last day of February is 35 days before 4/4, whether it happens to be the 28th or 29th.)


hrmmm, I guess that was kinda laziness on my part.

My main confusion is probably how everything fits together in his algorithm:

I see the necessity of an anchor day, but I don't think I understand the rationale for its calculation
Also, there's this calculation with the last two digits of the year--floor (y/12) + y mod 12 + floor(y mod12 / 4, but how does that result end up as the Doomsday?
lu6cifer wrote:"Derive" in place of "differentiate" is even worse.

doogly wrote:I'm partial to "throw some d's on that bitch."

User avatar
gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: The Doomsday Rule

Postby gmalivuk » Thu Nov 11, 2010 3:46 am UTC

I haven't actually bothered looking much into this particular algorithm, though I've fiddled with (and come up with) others, and it all basically comes down to the fact that the calendar is pretty simple and cyclical. Floor functions and modular arithmetic then basically deal with that fact.

Incidentally, if it only counts the last two digits of the year, then it seems like it'd run into problems before 1900 or after 2099, since 1900 and 2100 aren't leap years, even though they're divisible by 4.
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

User avatar
kcaze
Posts: 57
Joined: Sat Jul 24, 2010 2:23 am UTC

Re: The Doomsday Rule

Postby kcaze » Thu Nov 11, 2010 9:04 am UTC

lu6cifer wrote:I see the necessity of an anchor day, but I don't think I understand the rationale for its calculation
Also, there's this calculation with the last two digits of the year--floor (y/12) + y mod 12 + floor(y mod12 / 4, but how does that result end up as the Doomsday?


Basically, Doomsday in year 0 is a Thursday. Each year shifts Doomsday by 1 day except on leap years in which case it's shifted 2 days. Using this, we can see that every century, Doomsday shifts by 5 days every century, plus an extra day every 4 centuries because of the whole no leap year every 100 years EXCEPT every 400th year thing (although, is the year 0 AD a leap year?).

Then the anchor day (doomsday for the beginning of a century) can be calculated using the formula on wikipedia: [math](5c + \lfloor\frac{c-1}{4}\rfloor) mod 7 + Thursday[/math]

Token
Posts: 1481
Joined: Fri Dec 01, 2006 5:07 pm UTC
Location: London

Re: The Doomsday Rule

Postby Token » Thu Nov 11, 2010 12:00 pm UTC

kcaze wrote:(although, is the year 0 AD a leap year?).

There is no 0 AD. It goes from 1 BC to 1 AD. Besides, the Gregorian calendar wasn't around 2000 years ago :p
All posts are works in progress. If I posted something within the last hour, chances are I'm still editing it.

User avatar
gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: The Doomsday Rule

Postby gmalivuk » Thu Nov 11, 2010 12:44 pm UTC

That said, yes, 0 AD would be a leap year, since it's a multiple of 400.
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

User avatar
kcaze
Posts: 57
Joined: Sat Jul 24, 2010 2:23 am UTC

Re: The Doomsday Rule

Postby kcaze » Thu Nov 11, 2010 12:52 pm UTC

Token wrote:
kcaze wrote:(although, is the year 0 AD a leap year?).

There is no 0 AD. It goes from 1 BC to 1 AD. Besides, the Gregorian calendar wasn't around 2000 years ago :p


So what day of the week was January 1st, 1 AD? I'll bet it's just an arbitrary day (say Monday or Sunday).

User avatar
phlip
Restorer of Worlds
Posts: 7569
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The Doomsday Rule

Postby phlip » Thu Nov 11, 2010 1:30 pm UTC

My calendar says that 1 January, AD 1 was a Saturday. Though, of course, they didn't call it "1 January, AD 1" at the time. And possibly didn't even call it "Saturday", I don't know how far back the history of those names goes.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: The Doomsday Rule

Postby gmalivuk » Thu Nov 11, 2010 2:07 pm UTC

Well I know Jews at least had the 7-day week long before Jesus, but of course they didn't use Anglo-Saxon names for said days.

Also, that's probably extending the Gregorian Calendar backward, but it was the Julian until 1582. (On the other hand, I think maybe in that year the date was shifted so that it would match up during Jesus' life, so perhaps that is still accurate.)
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: The Doomsday Rule

Postby jestingrabbit » Thu Nov 11, 2010 2:57 pm UTC

I seem to remember that the standard *nix cal program transitions from Gregorian to Julian at the appropriate time, so depending on what phlip used that might not be what a Gregorian 1 AD would be.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

User avatar
phlip
Restorer of Worlds
Posts: 7569
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: The Doomsday Rule

Postby phlip » Thu Nov 11, 2010 10:16 pm UTC

Hmm, you seem to be right... "cal 100" gives a leap year, but "cal 1900" doesn't.

But it's not perfect, it reports the year AD 4 as a leap year, but according to Wikipedia, it wasn't a leap year, 'cause they were still working out the kinks at that time. So all the dates up to 28 February 4 are presumably off by one, and 1 January AD 1, in the Julian calendar (more accurately, 1 January in the Julian calendar in the year later called AD 1) was a Sunday, not a Saturday.

In the Gregorian calendar, the days follow a 400-year cycle... the calendar for 1600 and the calendar for 2000 are identical, for example. So what the Gregorian calendar would call AD 1 starts on the same day as, say, AD 2001, which started on a Monday.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
gmalivuk
GNU Terry Pratchett
Posts: 26739
Joined: Wed Feb 28, 2007 6:02 pm UTC
Location: Here and There
Contact:

Re: The Doomsday Rule

Postby gmalivuk » Thu Nov 11, 2010 10:35 pm UTC

phlip wrote:In the Gregorian calendar, the days follow a 400-year cycle...
Yeah, though within each century the 28-year cycle is more useful to work with mentally (also the fact that every 12 years, dates move one day forward in the week).
Unless stated otherwise, I do not care whether a statement, by itself, constitutes a persuasive political argument. I care whether it's true.
---
If this post has math that doesn't work for you, use TeX the World for Firefox or Chrome

(he/him/his)

User avatar
GenericPseudonym
Posts: 206
Joined: Thu Nov 11, 2010 12:30 am UTC
Location: Wherever I happen to be.

Re: The Doomsday Rule

Postby GenericPseudonym » Fri Nov 12, 2010 1:59 am UTC

So, there's 2 equations in the article that get the same result, and I'll be explaining the simpler-looking one: [math]doomsday = [y + floor(y / 4)]mod7 + anchor[/math]
In here, the anchor day is the doomsday of the last xx00 year (i.e. 1900, 2000, 2100, etc.)
[imath]y[/imath] is the last 2 numbers in the year, which also happens to be the number of years since the anchor day.
Basically what this does, is find the number of days since any day of the year the anchor's in, to that same day this year. [imath](365y)mod7 = [(52 * 7 + 1)y]mod7[/imath], and since it IS mod7 you can take out the [imath]52*7[/imath] bit, leaving you with [imath](1 * y) mod7[/imath] or [imath](y)mod7[/imath]
The [imath]floor(y/4)[/imath] bit is kinda obvious, it just adds an extra day every 4 years to account for leap day.
So those two together, and you get [imath][y + floor(y/4)]mod7[/imath]. The [imath]mod7[/imath], in case you hadn't guessed yet, converts the number of days passed into the offset of doomsday from the anchor, which you'll add on now, giving the equation waaay at the top of this post, and on the Wikipedia page.

So that's that. If you see any errors, please point them out so I don't look like an idiot.


Return to “Mathematics”

Who is online

Users browsing this forum: No registered users and 14 guests