You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Today Is The Day After Doomsday

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/Other publicado por u/JWinslow23 December 20, 2015, 09:02:30 AM
WARNING: The following post includes math concepts and calendar calculations that certainly are NOT for the faint of heart. :P
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 :P


No, not that kind of Doomsday :P

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 Methods

Math 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 Congruence

Christian 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' Algorithm

Johann 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 expression

In 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 Methods

Just 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 Method
Charles 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

Doomsday
A 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:















MonthMemorable DoomsdaysMnemonics
January3 (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 ;)
April4repeated number (4/4)
May9"I work 9 to 5 at 7-11[5]"
June6repeated number (6/6)
July4
11
Independence Day (USA)
"I work 9 to 5 at 7-11[5]"
August8repeated number (8/8)
September5"I work 9 to 5 at 7-11[5]"
October10
31
repeated number (10/10)
Halloween
November7"I work 9 to 5 at 7-11[5]"
December12
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]0123
    Anchor dayTuesdaySundayFridayWednesday
    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 :P , 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 :P
[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. :P
[4]: You lost the game.
* JWinslow23 runs :P
[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.
Last Edit: December 21, 2015, 05:46:56 AM by JWinslow23
Inicia sesión o crea una cuenta para dejar un comentario
u/Snektron December 20, 2015, 10:09:44 AM
That's a lot of math :P You probaly could do something with the amount of days in a year too (no, not 365 or 366, but 365.242199)
u/JWinslow23 December 20, 2015, 10:20:58 AM
Well, that would certainly get you closer towards an astronomical calendar :P . We're concerned with our own at the moment though.

And sure, that's a lot of math, but it's really not so hard to do. The simplest way I've shown is nothing more than a lookup in a table, some addition and division by 2, and counting off days.
u/alexgt December 20, 2015, 02:42:55 PM
O.O nice I personally don'y believe in dooms day but I do believe in math, thanks for teaching me a few things ;)
u/c4ooo December 20, 2015, 07:17:23 PM
Wait what... you where born Jan 23, 2001? O.O
:w00t: :w00t: :w00t: :w00t: :w00t: :w00t: :w00t: :w00t:

About the vowel thing, does that mean that this only works in english? :P
u/JWinslow23 December 20, 2015, 08:06:33 PM
Quote from: alexgt on December 20, 2015, 02:42:55 PM
O.O nice I personally don'y believe in dooms day but I do believe in math, thanks for teaching me a few things ;)
It's not that kind of Doomsday (according to Conway, "anchor day" would have been more appropriate), but you're welcome.
Quote from: c4ooo on December 20, 2015, 07:17:23 PM
Wait what... you where born Jan 23, 2001? O.O
:w00t: :w00t: :w00t: :w00t: :w00t: :w00t: :w00t: :w00t:

About the vowel thing, does that mean that this only works in english? :P
Yes, I was born in 2001. My 15th birthday is coming up in a month and 3 days.

Also, that was just a way for Dodgson (Carroll) to describe the month table...without using a table. What the table really is is this:




MonthJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
Month "value"0315990120151181212243273304334

which is the number of days in that year that passed before the start of that month (with February counting as 28 days). This is equivalent to Dodgson's list in mod 7 (which is all that matters, because adding or subtracting 1 week doesn't change the result).




MonthJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
Dodgson's month "value"03363643423303112

Remember this in whatever pattern you want. You can also use this completely-reduced table for reference, knowing that adding or subtracting 7 has no effect on the "correctness" of the value:




MonthJanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
Reduced month "value"033614625035
u/JWinslow23 December 21, 2015, 01:56:28 AM
Bump.

I have added purely mathematical methods, for those interested. I even gave some TI-BASIC code I wrote over 2 years ago! Times really haven't changed :P
u/alexgt December 21, 2015, 02:14:10 AM
Cool ;), and pun intended?! :P
u/Araidia December 21, 2015, 05:18:39 AM
Thought you guys were talking about the December 21 2012 doomsday scare...
u/JWinslow23 December 21, 2015, 06:40:50 AM
Quote from: alexgt on December 21, 2015, 02:14:10 AM
Cool ;), and pun intended?! :P
Pun not intended. It was Julian accident ;)

Quote from: Araidia on December 21, 2015, 05:18:39 AM
Thought you guys were talking about the December 21 2012 doomsday scare...

As I said in the beginning of the post, it's not that kind of Doomsday :P The timing almost couldn't have been more perfect, though, in hindsight. The Doomsday on December 19 isn't too far off from December 21...hmmm :-|
u/Yuki December 21, 2015, 06:44:40 AM
Quote from: JWinslow23 on December 21, 2015, 06:40:50 AM
Quote from: alexgt on December 21, 2015, 02:14:10 AM
Cool ;), and pun intended?! :P
Pun not intended. It was Julian accident ;)
Are you guys talking about me?
u/JWinslow23 December 21, 2015, 06:46:48 AM
Quote from: Juju on December 21, 2015, 06:44:40 AM
Quote from: JWinslow23 on December 21, 2015, 06:40:50 AM
Quote from: alexgt on December 21, 2015, 02:14:10 AM
Cool ;), and pun intended?! :P
Pun not intended. It was Julian accident ;)
Are you guys talking about me?
Julian -> "truly an". That specific pun was intended. What, your real name is Julian?

In that case, I have some exciting news...there's an obsolete calendar system named after you! :P
u/Yuki December 21, 2015, 06:50:39 AM
It's Julien, actually. Which is French for Julian, which is in turn English for Latin name Julius. A famous bearer of the name is Julius Caesar, for which the Julian calendar and the month of July has been named for.
u/JWinslow23 December 21, 2015, 06:56:10 AM
Quote from: Juju on December 21, 2015, 06:50:39 AM
It's Julien, actually. Which is French for Julian, which is in turn English for Latin name Julius. A famous bearer of the name is Julius Caesar, for which the Julian calendar and the month of July has been named for.
Oh. Your name is Julien. Now Juju makes sense :P

And I knew that Julius Caesar was the namesake of the calendar system and July. Just like August was named after Augustus Caesar. And September through December were named because they used to be the 7th through 10th months (and the names stuck :P ). I just like to have fun with people. :P
u/c4ooo December 21, 2015, 04:06:03 PM
Welp, and there i was pronouncing Juju's name wrong :P
(since latin has no 'J' or 'K' Julius Caesar was spelled "Iulius Caesar" and pronounced 'Yulias Kayzar")
Last Edit: December 21, 2015, 04:09:44 PM by c4ooo
Start a Discussion

b/Other

Any discussion that doesn't fit in other categories go here. Also, don't forget to introduce yourself. :)

232
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal