Data Science with Andreas Lauschke (#10)
Author
Andreas Lauschke
Title
Data Science with Andreas Lauschke (#10)
Description
Gregorian Calendar with Continued Fractions
Category
Educational Materials
Keywords
URL
http://www.notebookarchive.org/2020-09-4lmqno7/
DOI
https://notebookarchive.org/2020-09-4lmqno7
Date Added
2020-09-10
Date Last Modified
2020-09-10
File Size
82.13 kilobytes
Supplements
Rights
Redistribution rights reserved



Understanding the Gregorian Calendar with Continued Fractions
Understanding the Gregorian Calendar with Continued Fractions
Andreas Lauschke, Nov 21 2019
Andreas Lauschke, Nov 21 2019
today’s session: Gregorian Calendar with continued fractions
summary: pope Gregory XIII, 1502 - 1585, set up a commission to improve the Julian calendar. The Gregorian calendar was introduced in Oct 1582 (but not adopted by all countries immediately). The leap year rule is:
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the year 2000 is.
accuracy: improves approximation of the Julian calendar by skipping three Julian leap days in every 400 years, giving an average of 365.2425 mean solar days. The error is about one day per 3,030 years. However, due to non-constant precession of the equinoxes and the movement of the perihelion (point when earth is closest to sun), the error itself is variable, which means the Gregorian calendar implies an error closer to one day every 7,700 years. This is *substantially* more accurate than the error of one day in 128 years of the Julian calendar.
sidenote: for more on the introduction of the Julian calendar, and Caesar’s decision to add 90 days to 46 BC, making it the longest year of all times, with 445 days, or 25% longer than usual, see
In[]:=
CurrentValue[EvaluationCell,CellOpen]=False;Hyperlink["https://www.youtube.com/watch?v=fD-R35DSSZY"]
nested sidenote: given that the Julian calendar has an error of 1 day in 128 years, and he added 90 days, it means he solved 90 * 128 == 11,520 years of “offness” with one decree. Efficient, I’d say.
please read the wikipedia article for more details and a historical account of Pope Gregory XIII and the Gregorian calendar. It’s more exciting than your usual bedtime thriller.
In[]:=
CurrentValue[EvaluationCell,CellOpen]=False;Hyperlink["https://en.wikipedia.org/wiki/Gregorian_calendar"]
various theorems establish that the cfs are the best-approximations to any number with rational expressions (think: fractions). You’ll remember long division and the Euclidean algorithm from 4th grade. You are already *using* cfs without having known about them!
In[]:=
584/169//N[#,500]&
a period of 78 digits!
In[]:=
3+455621301775147928994082840236686390532544378698224852071005917159763313609467/999999999999999999999999999999999999999999999999999999999999999999999999999999
Cfs find their greatest usefulness in approximation theory / calculus, which is normally not the most important domain of the data scientist -- so I won't do any cf theory here. But it is an *exciting* area of calculus that is *entirely* underrated.
for now, just trust me that the representation of the year’s length with cfs will be illuminating.
with the kernel we have several cf functions directly at our fingertips:
In[]:=
??*ContinuedF*
and I also add Convergents and Rationalize to that.
In[]:=
Convergents[584/169]
let’s do math: 1 year is 365 days, 5 hours, 48 minutes, 46 seconds (keep in mind, this itself is an empirical number, and empirical numbers are based on observations which have errors). It is an *adopted* value which we have to treat as exact.
dropping the integral component for the day, we have:
In[]:=
r=(53600+4860+46)/86400N@%
let’s look at cf convergents of this.
In[]:=
Convergents[r]
each of those is a solution to the calendar problem, with increasing accuracy. The denominator gives the length of the cycle, and the numerator gives the number of leap years per cycle.
we could have:
365 days + 0
365 days + 1/4 days
365 days + 7/29 days
...
365 days + 10463/43200 days
Clearly, 365 days + 7/29 days would be more accurate than 365 + 1/4, but also more complicated. Looking at all, we really have only four realistic options:
In[]:=
CurrentValue[EvaluationCell,CellOpen]=False;Style[Grid[{Style[#,Bold]&/@{"Option","Num of LYs","Period","Error"},{"1","1","4","-11m 14s"},{"2","7","29","1m 11s"},{"3",8,"33","-19s"},{"4","31","128","1s"}},Dividers{All,{True,True,False}},AlignmentRight,FrameTrue],20]
◼
the first option is the Julian calendar: one leap year every four years. Error: about 1 day in 128 years (86400/(11 60+14)//N).
◼
the second option is extremely unwieldy. Just WHO likes odd primes like 7 and 29?
◼
the third option, 8 leap years every 33 years, has been proposed by the Persian and Tajik scholar and poet Omar Khayyam in 1079. It seems it didn't make it either. 8 and 33 are not convenient numbers.
◼
the fourth option is exceptionally accurate. An error of 1s is of no practical significance. It has been proposed, for example, by the Russian astronomer Medler in 1864 from the beginning of the 20th century. It called for only *one* correction to the Gregorian calendar: jump one leap year every 128 years (reminder: the Julian calendar has 32 leap years every 128 years!). But it has never been enacted anywhere -- no pleasant "round-off". The accuracy is striking: the error in the Julian calendar is 1 day in 128 years, it uses 32 leap years in 128 years, and the best convergent (above) would be 31 leap years in 128 years. If 31 and 128 weren't such unwieldy numbers, the best solution would actually be a "modified Julian calendar" -- something Caesar never could have noticed (“just make an exception to your calendar every 128 years, and the error is 1s every 128 years”).
the Gregorian calendar is not found among these four choices, and cfs were not known in the 16th century. Yet, the Gregorian calendar is *extremely* precise. How did they do it?
Today we would proceed with cfs and lean towards the ratio of the last row, 31:128, but we would want to replace the numbers with something more convenient, a “round number”, we’d try 400 years among other choices. If 128 years contain 31 leap years (option 4), how many are contained in 400 years?
Today we would proceed with cfs and lean towards the ratio of the last row, 31:128, but we would want to replace the numbers with something more convenient, a “round number”, we’d try 400 years among other choices. If 128 years contain 31 leap years (option 4), how many are contained in 400 years?
In[]:=
31/128x/400//HoldForm//TraditionalForm
In[]:=
Solve[31/128x/400,x]N@%
round it, and we get 97 leap years for every 400-year cycle. This is the Gregorian calendar (reminder: no leap year if divisible by 100, except if divisible by 400, and this rule gives us exactly 97 leap years per 400-year cycle). But the above would use knowledge of 31/128 and today’s known year length.
so that would have been impossible for the papal commission, because back in the 16th century people didn’t have the high accuracy of a year’s length, and no cfs (so no knowledge of 31/128). The commission used the astronomical tables compiled by the Academy of Toledo on the order of King Alphonse X (“the Wise”) of Castille (1221-1284). The length of the year in those tables was: 365 days 5 hours 49 minutes 16 seconds. Converted to cfs gives:
In[]:=
Convergents[(53600+4960+16)/86400]
thus, the pope’s commission could not have been aware of the ratio 31/128 by any method whatsoever.
however, the commission could have been satisfied with its work, it is *very* precise, because if now we choose an “option 4” from the list, this time using the Academy of Toledo tables (again, remember they didn’t have cfs back then, we’re analysing their precision retro-actively!), we still get 122/503 in the fourth convergent, not too shabby (I mean, it’s clear that all these convergents go towards a number a little less than 1/4, hence we get something around 97 for the number of leap years in every 400-year cycle):
In[]:=
Solvex400,xN@%
122
503
aka, 97 in 400. We’ve seen that ratio before with more exact (today’s) data. In fact, all of the convergents tend towards something around 97:
using year length of the Academy of Toledo table:
In[]:=
Solve[#x/400,x]&/@Convergents[(53600+4960+16)/86400]//N[#,100]&//TableForm
using today’s year length:
In[]:=
Solve[#x/400,x]&/@Convergents[(53600+4860+46)/86400]//N[#,100]&//TableForm
sidenote for nerds: this is an example of alternating convergence, note that every number is alternating between “above” and “below” both a) the previous number and b) the final number of 97+1/54 and 97-13/108 respectively. This is one of the characteristics of cfs approximations using standard convergents.
so with a “planning horizon” of 400 years, skipping 3 leap years every 400 years, is the first order of business! I’d argue the last rows, the solutions derived from the best convergents, are darn close to 97. Percentage-wise, the papal commission “missed their mark” by only
In[]:=
97/(97+1/54)//N1-%//PercentForm
or less than 2% of a percent.
I emphasize that cfs were unknown in the 16th century, the result was found by trial-and-error by the papal commission. Here is my personal opinion on how this could have been accomplished by them: According to the Academy tables, the Julian year was longer than the true year by 10 m 44s. How many years would it take to accumulate that error until one full day is reached?
In[]:=
86400/(1060+44)Quantity[N@%,"Years"]
thus one would have to “skip” one leap year every 134 years. But that would be complicated, 134 is an unpleasant number, however, notice that 134 is about 400/3. So we come to the same conclusion: skip three leap years every 400 years. This is the Gregorian calendar, without the use of cfs. The beauty of all of it is that a rule like “every 4 years, except when 100, except when 400”, is incredibly easy even for the common folk to understand. Everyone understands 4, 100, and 400. The *simplicity of the rule*, with a small denominator early on, was *important*.
it means Pope Gregory effectively assumed that the year was 4 seconds shorter than what *he* thought it actually was (using the Academy of Toledo tables). Let’s do a comparison:
(*AcademyofToledo,assumedtobecorrectbypapalcommission*)Convergents[(53600+4960+16)/86400](*averageGregorian*)Convergents[(53600+4960+12)/86400](*true,using45seconds*)Convergents[(53600+4860+45)/86400](*true,using46seconds*)Convergents[(53600+4860+46)/86400]
the second list of convergents ends with 97/400, which means exactly: 3 leap years in 400 years, without error.
for a modern version, now that we have cfs, the problem is that the length of the year itself is not clearly defined, and the earth’s rotation speed is slowing down. A very precise formula / method would only make sense for the long run (meaning: we seek precision for the sake of correctness in the *very* distant future, and that means: thousands of years), which then would necessarily have to take into account the consequences of the slow-down of the earth’s rotation. And in thousands of years, who would want to give credit to *us*? Earth will have passed through another ice age. So we’re better off just adding a second to a year occasionally:
what is done in real life? For reasons of convenience, the length of the year is explicitly changed from time to time. Usually 1s is added. At the year change from 2016 to 2017 the last minute of the year got one extra second. What? WAIT a second! Exactly. We had to wait one extra second before 2017 could start. The last second of 2016 wasn’t 23:59:59, but 23:59:60. And it wasn’t the first time. We’ve been adjusting the clocks since 1972. In 34 years we’ve added 26 leap seconds to the year. The one before the last time was in June 2015. As the earth’s rotation slows down over time, we’ll see this second-adding business more frequently in the future. On the other hand, it also means that the Gregorian calendar becomes progressively more correct (at ridiculously slow speed), because the Academy of Toledo had the year’s length some 27 seconds too long.
wiki page:
In[]:=
CurrentValue[EvaluationCell,CellOpen]=False;Hyperlink["https://en.wikipedia.org/wiki/Leap_second"]


Cite this as: Andreas Lauschke, "Data Science with Andreas Lauschke (#10)" from the Notebook Archive (2020), https://notebookarchive.org/2020-09-4lmqno7

Download

