tag:blogger.com,1999:blog-91279819495374129652018-03-06T06:15:03.491-08:00Accelerated DoomsdayC. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-9127981949537412965.post-113505160329914432012-07-31T10:24:00.005-07:002012-11-14T12:14:00.647-08:00Wall Street Crash of 1929The Great Crash (aka the Wall Street Crash of 1929) occurred in October 29, 1929<br /><br />Multiple Choice question:<br />This day in history is also known as<br />a) Black Monday<br />b) Black Tuesday<br />c) Black Wednesday<br />d) Black Thursday<br />e) Black Friday<br /><br /><br />Saturday and Sunday are excluded because the stock market is closed on those days.<br /><br />C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-68621834170780706482011-12-02T13:16:00.000-08:002011-12-02T13:20:45.268-08:00Unix cal program for September 1752//calendar for September 1752<br /><pre>% cal 9 1752<br /><br />September 1752<br />Su Mo Tu We Th Fr Sa<br /> 1 2 14 15 16<br />17 18 19 20 21 22 23<br />24 25 26 27 28 29 30<br /></pre>C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-40485396118709085332011-10-24T21:02:00.000-07:002012-09-04T18:59:16.277-07:00Prepare to Meet Thy DoomsdayI wrote an article for Scientific American regarding the Doomsday algorithm.<br /><br />"<a href="http://www.scientificamerican.com/article.cfm?id=calendar-algorithm">What Day is Doomsday</a>? How to Mentally Calculate the Day of the Week for Any Date"<br /><br />special thanks to John Matson for the editorial work.<br /><br />Chinese translation: <a href="http://www.ccglim.com/11434.html">http://www.ccglim.com/11434.html</a>C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-39279974161040397802011-08-07T20:19:00.000-07:002013-07-30T00:32:26.183-07:00Sakamoto's AlgorithmTomohiko Sakamoto came up with a terse program for calculating the day of the week in 1993. His code was written in the C language. The non-portable code goes like this:<br /><br />int dayofweek(unsigned int y, unsigned int m, unsigned int d) <br />{ <br />y -= m < 3; <br />return (y + y/4 - y/100 + y/400 + "-bed=pen+mad."[m] + d) % 7; <br />} <br /><br /><br />Here is the portable version:<br /><br />int dayofweek(int y, int m, int d) <br />{ <br />static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; <br /><br />y -= m < 3; <br />return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; <br />}C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-10110805461320468422011-05-30T00:42:00.000-07:002011-05-30T00:45:50.369-07:00Negative Space Font<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-3smK35ROYuo/TeNKulk0wsI/AAAAAAAAAEQ/6HGxjDRAVm0/s1600/doomsday.jpg"><img style="cursor:pointer; cursor:hand;width: 320px; height: 258px;" src="http://4.bp.blogspot.com/-3smK35ROYuo/TeNKulk0wsI/AAAAAAAAAEQ/6HGxjDRAVm0/s320/doomsday.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5612411724854772418" /></a><br /><br />"Doomsday Algorithm" in negative space fontC. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-83916250773725386962011-01-22T15:39:00.000-08:002011-08-12T12:19:49.058-07:00Doomsday Timelineby the doomsayers
<br />
<br />The Doomsday Algorithm was first introduced in 1973. Over the years, it has undergone many refinements and improvements. The ultimate goal is to make the algorithm easy to calculate mentally in addition to being easy to remember. Here is a timeline of important modifications to the Doomsday algorithm. Please email spectralfft at yahoo.com for corrections/suggestions to this timeline
<br />
<br />1882: Christian Zeller devised the Zeller's congruence algorithm for determining the day of the week for any calendar date. This algorithm is not suitable for mental calculation but works well in computer software.
<br />
<br />1887: Lewis Carroll published a perpetual calendar algorithm in the journal Nature with the title "To Find the Day of the Week for Any Given Date". Carroll's algorithm can be performed mentally. Lewis Carroll, himself, can calculate the day of the week in about 20 seconds.
<br />
<br />1967: Martin Gardner published "Tricks of Lightning Calculators" in the May issue of Scientific American magazine. He gives a full description of Carroll's calendar algorithm.
<br />
<br />when?: Martin Gardner told John Horton Conway about Lewis Carroll's perpetual calendar algorithm and challenged him to come up with a better algorithm.
<br />
<br />1973: John Horton Conway published the original Doomsday algorithm in the journal Eureka. The title of his paper is "Tomorrow is the Day After Doomsday". Conway reuses Lewis Carroll's formula for calculating doomsyear.
<br />
<br />when?: John Horton Conway came up with an improved mnemonic "working 9 to 5 at the 7-Eleven"
<br />
<br />when?: John Horton Conway came up with a table-lookup acceleration to calculating the doomsyear term. This method is very fast but it requires the memorization of 18 numbers.
<br />
<br />1993: Tomohiko Sakamoto posted a terse C program containing his calendar algorithm in the Usenet newsgroup comp.lang.c . His algorithm and program listing is remarkably simple, but not suitable for mental calculation. Moreover, unlike Zeller's congruence, the Sakamoto algorithm uses table-lookup for each of the 12 months.
<br />
<br />1994: Rudy Limeback created a website on the Doomsday algorithm
<br />
<br />1995: Sidney Graham created a website on the Doomsday algorithm
<br />
<br />2001: Bob Goddard came up with an improved mnemonic -- January 3/4 instead of the original January 31/32
<br />
<br />2004: Sohael Babwani published a new algorithm for calculating the day of the week for any calendar date. Like Zeller's congruence, his algorithm is not suitable for mental calculation.
<br />
<br />2008: Mike Walters came up with an algorithm to simplify doomsyear term calculation. Bob Goddard later helped him refine this method.
<br />
<br />2009: Bob Goddard published the "First Sunday Doomsday Algorithm" which introduced several innovations, including the use of 7's complement in lieu of subtraction/negation
<br />
<br />2010: Chamberlain Fong devised the Decade method for calculating doomsyear
<br />
<br />2010: Chamberlain Fong and Mike Walters devised the Odd+11 method for calculating doomsyear
<br />
<br />2010: Yingking Yu came up with new mnemonics: January 11 and February 22 for leap years. Yingking Yu also made several suggestions to calculating doomsyear.C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0tag:blogger.com,1999:blog-9127981949537412965.post-36688588265604637812010-06-20T00:10:00.001-07:002015-10-30T00:12:34.351-07:00Methods for Accelerating Conway's Doomsday Algorithmupdated arXiv version of this document: <br /><a href="http://arxiv.org/abs/1006.3913">http://arxiv.org/abs/1006.3913</a><br />and part 2 <br /><a href="http://arxiv.org/abs/1006.3913">http://arxiv.org/abs/1010.0765</a><br /><br /><strong>Abstract </strong><br /><br />We propose a simplification of a key component in the Doomsday Algorithm for calculating the day-of-the-week of any given date. In particular, we propose to replace the calculation of the required term: <br /><br />floor(x/12) + x mod 12 + floor((x mod 12)/4) <br /><br />with <br /><br />2 y + 3(y mod 2) + z + leap <br /><br />where <br />x is an input two-digit year; <br />y is the tens digit of x; <br />z is the ones digit of x; <br />leap is the number of leap years in the y decade less than or equal to x excluding the start of the decade; <br /><br /><br />We argue that this simplification makes the algorithm simpler and easier to calculate mentally. <br /><br /><strong>Introduction </strong><br />The Doomsday rule is an algorithm for calculating the day of the week for any given calendar date. It was invented by John Horton Conway in 1982. It was designed to be simple enough that, with practice, one can do the calculation in his head without paper or pencil and come up with an answer in just a few seconds. Conway himself was able to do the algorithm calculations in his head in about 2 seconds [1]. <br /><br />For brevity, we won't discuss the full algorithm here. Instead we refer the readers to excellent writeups [2][3] that describe the algorithm in full detail. We will, however, summarize key components of the algorithm to point out some important definitions and nomenclature. <br /><br />The Doomsday algorithm's input is a calendar date of the form MM/DD/YYYY where MM is the month, DD is the day, and YYYY is the year. YYYY can further be broken down to its constituent century CC and year within the century YY. The output of the algorithm is a number between 0 to 6 that corresponds to each of the 7 days fo the week. <br /><br />The key equation of the Doomsday rule can be described a sum (modulo 7) of three terms: <br /><br />day_of_the_week = [doomscentury + doomsyear + doomsmonth ] mod 7 <br /><br />where: <br /><br />doomscentury(CC) is a function of the input date's century <br />doomsyear(YY) is a function of the input date's 2-digit year within a century <br />doomsmonth(MM,DD) is a function of the input date's calendar month and day. <br /><br />In this paper, we only really care about the doomsyear term. We will only gloss over the doomsmonth and doomscentury terms. The doomsmonth term is what takes advantage of the fact that April 4, June 6, August 8, October 10, and December 12 all fall on the same day of the week for any calendar year. The doomscentury term accounts for the quirk in the Gregorian calendar system where years that are divisible by 100 are not leap years except when they are divisible by 400. We will not attempt to simplify or discuss further the doomscentury and doomsmonth terms for the rest of this paper. <br /><br />The doomsyear term is given by Conway [4] as: <br /><br />floor(x/12) + x mod 12 + floor((x mod 12)/4) <br /><div align="justify"><br />where x is the input date's 2-digit year within a century. <br />The addition is always modulo 7, so the resulting doomsyear term is a number between 0 and 6, inclusive. <br /><br /><strong>Related Work</strong><br />In practice, calculating the doomsyear term is a bottleneck of the Doomsday algorithm. Aside from having to do divisions by 12 and 4, one has to keep in memory 3 numbers to add. The term given by Conway is actually already an acceleration method for the term <br /><br />x + floor(x/4) <br /><br />which, in practice, is difficult to calculate for two-digit input numbers mentally [2] especially if followed by a required modulo 7 operator. Several people have suggested acceleration methods for the doomsyear term. Conway himself offered a lookup table acceleration for it [3][5]. His acceleration method is arguably the fastest but it requires the memorization of 18 numbers and extra rules for handling leap years. In 2008, Mike Walters [6] came up with a simpliflication of the doomsyear term that involves addition of multiples of 11, a division by 2, and a negation modulo 7 operator. Bob Goddard [7] made improvements to this method in 2009. Our proposed acceleration method is just as simple as Mike Walters' and Bob Goddard's method. In addition, our proposed acceleration method is amenable to a table-lookup memorization similar to Conway’s lookup table acceleration. <br /><br /><strong>Simplified Formula</strong><br /><br />Let us break down the two-digit year x into its constituent digits y and z, where y is the tens digit, and z is ones digit. That is, </div><br /><div align="justify">y = floor(x/10) <br />z = x mod 10 <br /><br />For example, if x = 74, then y= 7 and z = 4. If x = 88, then y= 8 and z= 8. <br />Having defined y and z in terms of x, we propose the replacement doomsyear function as <br /><br />doomsyear(y,z) = 2 y + 3 (y mod 2) + z + leap <br /><br /><br />We define an extra variable called leap as the number of leap years between the start of the y decade and the z year. If the start of a decade is a leap year, we don't count it. But if the year z is a leap year, we do include it. For example, if x = 88, the decade starts at 80 and we have leap = 2 because 84 and 88 are leap years. If x=74, the decade starts at 70 and we have leap = 1 because 72 is a leap year. In general, the variable leap can only have three values: 0 , or 1, or 2. There can't be more than 2 leap years after the start of a decade. Remember, we never include the start of the decade in our leap count. </div><div align="justify">In summary, our proposed method for calculating doomsyear breaks the 2-digit input year into its constituent digits; and does simple arithmetic on these digits. Afterwards, there is the addition of a leap year correction term. Our method essentially requires only 3 additions and a multiplication by 2. Moreover, since the input is broken down to single digit numbers, the calculations done only involve small numbers and are easy to do mentally. In fact, our doomsyear arithmetic only involves positive integers in between 0 to 31. This range of numbers happens to be the “calendar range” which probably cannot be avoided in the calculations of any calendar algorithm. </div><div align="justify">There are no explicit divisions or subtractions in our doomsyear formula. However, there are implicit divisions and subtractions needed when one is figuring out the leap year correction term and when one is doing a modulo 7 operation afterwards. Nevertheless, all doomsyear acceleration methods require these implicit divisions and subtractions! <br /><br /><br /><strong>Examples</strong><br /><br />Let's calculate the doomsyear term for these years: <br /><br />1) 1974: y = 7, z = 4 <br />leap = 1 because 1972 is a leap year <br />doomsyear = 2*7 + 3*1 + 4 + leap = 14 + 3 + 4 + 1 = 22 = 1 (mod 7) <br /><br />2) 2040: y = 4, z= 0 <br />leap = 0 <br />doomsyear = 2*4 + 3*0 + 0 + leap = 8 + 0 + 0 + 0 = 1 (mod 7) <br /><br />3) 2010: y = 1, z = 0 <br />leap = 0 <br />doomsyear = 2*1 + 3*1 + 0 + leap = 2 + 3 + 0 + 0 = 5 (mod 7) <br /><br />4) 1988: y = 8, z= 8 <br />leap = 2 because 1984 and 1988 are leap years <br />doomsyear = 2*8 + 3*0 + 8 + leap = 16 + 0 + 8 + 2 = 26 = 5 (mod 7) <br /><br />5) 2007: y = 0, z= 7 <br />leap = 1 because 2004 is a leap year <br />doomsyear = 2*0 + 3*0 + 7 + leap = 0 + 0 + 7 + 1 = 8 = 1 (mod 7) <br /><br />6) 1998: y = 9, z=8 <br />leap = 2 because 1992 and 1996 are leap years <br />doomsyear = 2*9 + 3*1 + 8 + leap = 18 + 3 + 8 + 2 = 31 = 3 (mod 7) <br /><br /><br /><strong>Tips and Tricks</strong><br /><br />Memorization and Lookup Tables <br /><br />Let’s define the decade anchor to be the “(2y + 3 (y mod 2))” subexpression of the doomsyear term. This subexpression only depends on the y decade of the input year. <br /><br />decade_anchor(y) = ( 2 y + 3 (y mod 2) ) mod 7 <br /><br />By virtue of memorizing the decade anchor for each decade, one can significantly speed-up the calculation of the doomsyear term. This memorization is, of course, optional. Here is the table to memorize: <br /><br /><a href="http://3.bp.blogspot.com/_9kqI2niiMJ8/TB8LFqUT-3I/AAAAAAAAAAM/UPyzIEyNXVI/s1600/decade_anchor.gif"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5485115063047289714" src="http://3.bp.blogspot.com/_9kqI2niiMJ8/TB8LFqUT-3I/AAAAAAAAAAM/UPyzIEyNXVI/s320/decade_anchor.gif" style="cursor: hand; float: left; height: 202px; margin: 0px 10px 10px 0px; width: 320px;" /></a><br /><div align="justify"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />If one memorizes this simple table of 10 numbers, one can avoid calculating the decade anchor “2y + 3 (y mod 2)” component of the doomsyear formula. The doomsyear formula is thus: <br /><br />doomsyear(y,z) = decade_anchor(y) + z + leap <br /><br />An important mnemonic that can aid in memorizing this table involves the observation of its clamping effect. That is, for the starting and ending decades of the 00’s and the 90’s, the decade anchor is 0. Thus, one only really needs to memorize 8 numbers when using this decade anchor lookup table acceleration trick. <br /><br />Look Before You Leap <br /><br />There are several tricks to make the calculation of the leap term easier. Let’s look at a table of possible values for the leap term depending on the digit year z: <br /><br /><a href="http://1.bp.blogspot.com/_9kqI2niiMJ8/TB8L3EOrPDI/AAAAAAAAAAU/wsI9lXRbgpg/s1600/leaper.gif"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5485115911816559666" src="http://1.bp.blogspot.com/_9kqI2niiMJ8/TB8L3EOrPDI/AAAAAAAAAAU/wsI9lXRbgpg/s320/leaper.gif" style="cursor: hand; float: left; height: 188px; margin: 0px 10px 10px 0px; width: 320px;" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />One can easily see that for digit years 0 and 1, the leap value is always 0. Likewise, for the digit years 8 and 9, the leap value is always 2; and for the digit years 4 and 5, the leap value is always 1. So, we only really need to do leap year calculations when the digit year is 2, 3, 6, or 7. Furthermore, if one checks whether the decade is odd or even, leap year determination can be totally avoided at the expense of more memorization. <br /><br /><br />Lucky Number 7 <br /><br />Another tip for the calculation of the doomsyear term involves the observation that 7 = 0 in modulo 7 arithmetic. So the z term in the doomsyear formula can be dropped altogether for the years 07, 17, 27, 37, 47 etc. <br /><br /><br /><br /><br /><strong>Conclusion </strong>We presented an acceleration method for calculating the doomsyear term of the Doomsday rule. Our method is simple because it only involves additions and a multiplication by 2. Furthermore, we provided further tips and tricks that can give additional speed to our method. In the appendix section of this paper, we show that our acceleration method method is similar in form to Conway’s lookup table acceleration method, but requires less memorization. <br /><br /><a href="http://1.bp.blogspot.com/_9kqI2niiMJ8/TB8NGyZQ14I/AAAAAAAAAAc/v56_WNHMh-U/s1600/table.gif"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5485117281418663810" src="http://1.bp.blogspot.com/_9kqI2niiMJ8/TB8NGyZQ14I/AAAAAAAAAAc/v56_WNHMh-U/s320/table.gif" style="cursor: hand; float: left; height: 320px; margin: 0px 10px 10px 0px; width: 235px;" /></a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />References: <br /><br />[1] Mark Alpert, ”Not Just Fun and Games”, Scientific American, April 1999. <br /><br />[2] Wikipedia contributors, ”Doomsday Rule”, Wikipedia, The Free Encyclopedia. <br /><br />[3] Rudy Limeback, “Doomsday Algorithm”, <br />http://rudy.ca/doomsday.html <br /><br />[4] Richard Guy, John Horton Conway, Elwyn Berlekamp : "Winning Ways: For Your Mathematical Plays, Volume. 2: Games in Particular", Academic Press, London, 1982 <br /><br />[5] Sidney Graham, “Doomsday Rule”, <br />http://www.cst.cmich.edu/users/graha1sw/Pub/Doomsday/DoomsdayIntro.html <br /><br />[6] Mike Walters, “An Easier Doomsday Algorithm”, Blogspot blog <br />http://easydoomsday.blogspot.com/ <br /><br />[7] Bob Goddard, “First Sunday Doomsday Algorithm”, Blogspot blog <br />http://firstsundaydoomsday.blogspot.com/ <br /><br /><br /><br /><br /><br /><strong>Appendix 1: Some Doomsyear Properties</strong><br /><br />Let us look at table 3 once again and observe some properties of the doomsyear term. <br /><br />Property#1 Non-Leap-Year Increment <br /><br />We can see from table 3 that the doomsyear increases by 1 for every non-leap year. This follows from the fact that 365 = 1 (mod 7); and the day of the week increases by one after each non-leap year. <br /><br />Property#2 Leap-Year Increment <br /><br />We can also see from table 3 that the doomsyear increases by 2 for every leap year. This follows from the fact that 366 = 2 (mod 7); and the day of the week increases by two after each leap year. <br /><br />Property#3 Periodicity <br /><br />The days of the week repeat with a period of 7. The leap years within a century repeat with a period of 4. It is no surprise that doomsyear values repeat every 28 years. 28 is, of course, the least common multiple of 7 and 4. <br /><br />Property#4 Quasi-periodicity <br /><br />We can observe from table 3 that the doomsyear value almost repeats a count of 0 to 6 every 5 or 6 years except for regular jumps occuring every leap year.We can call this property as quasi-periodicity. <br /><br /><br /><br /><br /><br /><br /><strong>Appendix 2: Conway’s Look-up Table Acceleration Method</strong><br /><br />John Horton Conway devised an acceleration method to avoid explicit calculation of the doomsyear term. In practice, Conway’s method is probably the fastest acceleration method for such, but it involves memorizing 18 numbers and some non-intuitive rules. In this section, we will describe Conway’s look-up table method. In the next section, we will compare and contrast our method with Conway’s acceleration method. <br /><br />Conway’s lookup table method requires memorizing the years of the century where the doomsyear value is zero. Let us call these numbers as zero-anchor years. These are: <br /><br />0, 6, 11.5, 17, 23, 28, 34, 39.5, 45 <br />51, 56, 62, 67.5, 73, 79, 84, 90, 95.5 <br /><br /><br />There’s actually the added complication of the half-numbers: 11.5, 39.5, 67.5 and 95.5. These half-numbers mean that the preceding year has doomsyear value 6 and the succeeding year has doomsyear value 1. For example, doomsyear(11) = 6, and doomsyear(12) = 1; doomsyear(67) = 6, and doomsyear(68) = 1. These half-numbers occur because of the increment-by-2 property of doomsyear values during leap years. In effect, a doomsyear of value 0 got skipped in the half-number locations. <br /><br />The gist of Conway’s acceleration method is to find the nearest zero-anchor year to your input year. Afterwards, subtract the zero-anchor year from your input year and add a leap year correction to get the doomsyear value For this section, we will restrict the zero-anchor to be the less than your input year. It is actually possible to select a zero-anchor greater than your input year, but it requires remembering some additional rules when dealing with leap years and half-numbers. This is tricky and error-prone, so we will not cover it. <br /><br />Here are the steps of Conway’s acceleration method: </div><div align="justify">1) Select the nearest zero-anchor year less than your input year. <br />2) Let z0 be the difference between your input year and the selected zero-anchor. Ignore fractional values of half-numbers in zero-anchor years. That is, treat 11.5, 39.5, 67.5, and 95.5 as 11, 39, 67, and 95 respectively in calculating the difference <br />3) Count the number of leap years between the zero-anchor and your input year. If the zero-anchor year is a leap year, do not include it. On the other hand, if your input year is a leap year, include it in the leap count. Let us denote this count of leap years as leap0 <br />4) Add z0 and leap0 to get the doomsyear value. If the selected zero-anchor is a half-number, subtract 1 from the sum. We denote this as the anchor adjustment term needed for half-number zero-anchors. <br /><br />To sum it all up, Conway’s acceleration method can be described by the equation: <br /><br />doomsyear = anchor_adjustment + z0 + leap0 <br /><br />Note that the anchor_anjustment term is almost always zero except for half-number years where it has a value of –1. <br /><br /><br />Examples: <br /><br />1) 1974: <br />zero-anchor is 1973 <br />z0 = 1974 – 1973 = 1 <br />leap0 = 0 <br />doomsyear = 1 + 0 = 1 <br /><br />2) 2040: <br />zero-anchor is 2039.5 <br />z0 = 2040 – 2039 = 1 <br />leap0 =1 because 2040 is a leap year <br />doomsyear = -1 + 1 + 1 = 1 <br /><br />3) 2010: <br />zero-anchor is 2006 <br />z0 = 2010 – 2006 = 4 <br />leap0 = 1 because 2008 is a leap year <br />doomsyear = 4 + 1 = 5 <br /><br />4) 1988: <br />zero-anchor is 1984 <br />z0 = 1988 – 1984 = 4 <br />leap0 = 1 because 1988 is a leap year. Remember, we don’t count the zero-anchor <br />doomsyear = 4 + 1 = 5 <br /><br />5) 2007: <br />zero-anchor is 2006 <br />z0 = 2007 – 2006 = 1 <br />leap0 = 0 <br />doomsyear = 1 + 0 = 1 <br /><br />6) 1998: <br />zero-anchor is 1995.5 <br />z0 = 1998 – 1995 = 3 <br />leap0 = 1 because 1996 is a leap year <br />doomsyear = -1 + 3 + 1 = 3 <br /><br />7) 1914: <br />zero-anchor is 1911.5 <br />z0 = 1914– 1911 = 3 <br />leap0 = 1 because 1912is a leap year <br />doomsyear = -1 + 3 + 1 = 3 <br /><br />8) 1972: <br />zero-anchor is 1967.5 <br />z0 = 1972 – 1967 = 5 <br />leap0 = 2 because 1968 and 1972 are leap years <br />doomsyear = -1 + 5 + 2 = 6 <br /><br /><br /><br /><strong>Appendix 3: A Comparison of Our Acceleration Method with Conway’s</strong><br /><br />As we mentioned in the tips and tricks section, our method is amenable to lookup table acceleration. In fact, we claim that after this lookup table acceleration, our method is very similar to Conway’s acceleration method. Let us compare and contrast the doomsyear equation for our method and Conway’s method. These are: <br /><br />doomsyear(y,z) = decade_anchor(y) + z + leap <br /><br />and <br /><br />doomsyear(x) = anchor_adjustment(x) + z0 + leap0 <br /><br />respectively. We have carefully named different terms of the equations to highlight the similarities between both equations. Let us list down these similarities. <br /><br />1) Both equations are the sum of 3 terms. Each of these terms correspond with a counterpart in the other method. <br />2) Both equations use memorization of an anchor year for the speedup. In our method, the starting year of the decade serves as the anchor. In Conway’s method, years with doomsyear value of zero are used as the anchor. <br />3) Both equations use z as the number of years between the input year and the anchor year. <br />4) Both equations contain a leap count correction term that counts the number of leap years between the anchor year and the input year. <br /><br />We now list down differences between the 2 equations and mention some advantages of our method over Conway’s method. <br /><br />1) In our method, z is not computed. It is part of the input. In Conway’s method, z0 has to be calculated by subtracting the zero-anchor year from the input year. <br />2) In our method, one has to memorize 10 digits for the anchoring. In Conway’s method, one has to memorize 18 numbers for the anchoring. <br />3) In our method, the leap count correction term follows a regular pattern for a given decade and is amenable to another speedup via memorization. <br />4) In our method, one can always fall back to using the “2y + 3 (y mod 2)” calculation if entries in the lookup table are forgotten. </div></div>C. Fonghttp://www.blogger.com/profile/16514653288703177586noreply@blogger.com0