Charles in NJ
HPR Episode: Doomsday Perpetual Calendar Method What is it? http://en.wikipedia.org/wiki/Doomsday_rule (due to John H. Conway, a mathematician born in Liverpool) * He's done other research that hackers might like to check out. * Look up the "Game of Life" and "cellular automata". * There may be episodes on these topics, but those should come with visualization software. John H. Conway http://en.wikipedia.org/wiki/John_Horton_Conway Game of Life http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Doomsday Rule lets you find the day of the week for any date * Dates in history, in immediate past or in future are all good. * Works for both the Gregorian and Julian calendar. - I'll only be looking at Gregorian dates for now. - Method should work well for dates from 1800 onward. - If dates for non-Gregorian calendars are converted to their (extrapolated) Gregorian equivalents, this method works. Wikipedia entry (includes recent optimization): http://en.wikipedia.org/wiki/Doomsday_algorithm Why do this? It came up in Episode Zero of my "N Days" show on calendar counting, where I used it without explanation. http://hackerpublicradio.org/eps.php?id=1143 Demos: Check these answers at www.day-calculator.com * Some listeners may now adjourn to the latest Linux Outlaws episode. Method: Get Century Anchor Day, calculate offset for the year to find Doomsday's reference location for current year, find closest reference date to target date, and count off to the answer. a) Isaac Newton's date of birth: - 25 December 1642 - 1600's Tuesday. Year 42 = 3*12 + 6 and (6/4) = 1. Hence 3 + 6 + 1 = 10 for an offset of 3. Tuesday + 3 = Friday. 12/12 is Friday, so 12/26 is Friday Newton was born 12/25, so that was a Thursday b) My grandfather's date of birth: - 20 January 1898 - 1800's anchor is Friday. Year 98 = 8*12 + 2, (2/4) = 0. So 8 + 2 + 0 = 10 gives an offset of 3. - 1898 wasn't a leap year, so 10 January was Monday - That means 17 January was a Monday, too. - So 20 January 1898 was a Thursday. c) A wedding anniversary that I like to remember: 15 May 2000 - 2000 has anchor day on Tuesday, and no offset. - Rule: "I work 9 to 5 at 7-11", so 9 May (16 May) are on Tuesday. - 15 May 2000 was a Monday. True. 'Twas the day after Mother's Day. d) My parent's wedding day: 19 May 1957 - 1900 has anchor day Wednesday. 57 = 4*12 + 9 and (9/4) = 2. - So 4 + 9 + 2 = 15 or an offset of 1. - 9 May is Thursday, as is 16 May. The 19th is 3 days later. - So 19 May 1957 was a Sunday. Plan: I'm going to reveal the magic behind this, and introduce some mental shortcuts to help you learn to do this in your head. If you can master the 12's row in your times tables up to 8 times 12, and the 4's row up the 20s or 30s, and you can tell time on a 12-hour clock, you should be able to do this. We're not in school, so paper and pencil to track the numbers, and finger-counting offsets to days of the week are all allowed. Explanation: 1. Certain memorable dates fall on the same day of the week as "Doomsday" = last day of February, whatever that is. 2. Dates recycle every 400 years, and Doomsday Anchor dates by Century are 1600: Tuesday, 1700: Sunday, 1800: Friday, 1900: Wednesday. 3. That's enough, but to simplify mental math notice 12-year cycles. - Every completed 12 years pushes the days of the week ahead by +1 - Each year within the current incomplete cycle adds +1 - Each leap year in current cycle adds +1 (including current year) 4. Doomsday dates are: a. January 10 and Doomsday (last day of February) b. Odd months: Add +4 through July, then subtract 4. 7 March, 9 May, 11 July 5 September, 7 November c. Even months are reflexive: 4/4, 6/6, 8/8, 10/10, 12/12 See the attached spreadsheets for examples and annotated calculations. - LibreOffice Calc: 229-Charles-in-NJ-Doomsday-Rule-v1.ods - Excel 5/95 'xls' for LibreOffice or Gnumeric: 229-Charles-in-NJ-Doomsday-Rule.xls - Gnumeric: 229-Charles-in-NJ-Doomsday-Rule-v1.gnumeric Bonus Content: - Excel VBA module: 229-Charles-in-NJ-Doomsday-Rule.vbaxl.bas * Import the .bas module * Input is an Excel "Date" object * Very proprietary formats and code, but some people use it. - Python: doomsday.py * Contains two functions: Each returns a string value for the day of the week, e.g., "Sunday" dayOfWeek(year, month, day): Doomsday is last day of February, and the (month, day) are converted to relative ordinal dates. For leap years, we have to push both Doomsday and any target date after 28 February up by one for the leap day. dayOfWeek2(year, month, day): Doomsday date anchors are computed for each month, so leap years require adjustments to the anchors for January and February to account for the shift in the February ending date. Later months are fine. - Script for GNU 'bc': doomsday.bc is a bc 'port' of the Python code * Differences: Return value is a number from 0-6 that represents the day of the week by its relative position. 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday * In a shell, run 'bc' with the filename as an argument: catintp@Derringer:~$ bc doomsday.bc - This loads the two functions in the file. You can invoke them within 'bc' like any other function: dayofweek(1981, 5, 15) dayofweek2(1642, 12, 25) dayofweek(2013, 11, 22) dayofweek2(2059, 5, 19) - Alternate Script for GNU 'bc': doomsday2.bc * Return value is still a number from 0-6 that represents the day of the week by its relative position. * Uses a side effect to print a human-friendly answer. * English only, but localisation should be easy.
Edited version - re sent
The Sonar Project has $9,838 raised with 256 people contributing. A big thanks to all the !HPR Listeners who helped out.
It's not too late to contribute to the ACF. See http://accessiblecomputingfoundation.org/ for more information.
Tomorrow The Eleventh Annual Southern California Linux Expo starts. Running from February 22 to the 24, 2013 in the Hilton Los Angeles International Airport. Speakers include Kyle Rankin, Joe Brockmeier and Matthew Garrett.
See http://www.socallinuxexpo.org/scale11x for more information
The N Days of Christmas? Intro to Recreational Math Part One: Counting Partridges and Gold Rings
The complete shownotes can be found here:
Background on Pascal's Triangle and the Binomial Theorem, see the excellent videos by Sal Khan at http://KhanAcademy.org
Contact: Charles in NJ Email: email@example.com
Charlie + Alpha + Tango + India + November + Tango + Papa.
Hacker Public Radio: 206 203 5729 The N Days of Christmas? Intro to Recreational Math Part Zero: Calendar Counting First episode of HPR that contains a direct discussion of a math topic. - Episode 479 Ohio Linux Fest, Klaatu interviews DWick about math software for Linux - Episode 523 Using Petunia software to teach math Inspired by a traditional song that is proof that some songs do not need to be recorded by William Shatner to be annoying. - Repetitive and formulaic - Involves a lot of counting, and that's our focus here. What is the 12 Days of Christmas? - Starts on Christmas Day, runs through the day before the next Season - Hint: That's 'Epiphany', which starts January 6. - Counting calendar days comes hard, so we tend to use our fingers - Turns out that using our fingers is quite mathematical. Here's why. Finger Counting: How do I count Twelve Days? - Let's start easy, with the fingers on one hand. My hands have five. - To name the Five Days of New Years is easy: January 1-5