**— EARLY CALENDARS AND THE LEAP YEAR PROBLEM —**

Archaeological records suggest that calendar systems developed around the same time as writing in the ancient empires of Sumeria and Egypt, and from there spread rapidly through the Ancient Near East.

These early calendars came in many forms, and often reflect the culture or religion present in the empire that created or adapted them. Quite often they reflect long-term weather patterns, like the Egyptian calendar, which features three seasons (*flood*, *emergence*, and *low water*) of 120 days each, followed by 5 *intercalary* days of civil and religious significance.

Notably, the Egyptian calendar lacks any concept of a *leap year*, which led the date to slip away from the *tropical year*, the length of time it takes the Earth to revolve around the sun (if you believe that newfangled heliocentrism nonsense). For this reason the Romans would sometimes refer to the Egyptian calendar as the *annus vagus* (*wandering year*), in what I can only assume was the world’s oldest (re: only) calendrical diss.

The Sumerian/Babylonian calendar resembles the Egyptian calendar in many regards — it again features three seasons, broken into twelve lunar months with an intercalary period. Yet, unlike the Egyptian system, this calendar was a proper *lunisolar calendar*: it set months according to the lunar cycle and years according to the solar cycle.

Babylon’s emphasis on the lunar cycle led to an interesting resolution of the leap year problem: insert a thirteenth month **whenever you feel like it**. At first these insertions were the subject of royal decree, put forth on a case-by-case basis. Later, Babylonian astronomers made the observation that 19 tropical years equaled 235 lunar cycles (accurate to within two hours!) and codified this lunar-solar epicycle into their calendar.

The Babylonian system survives in spirit as precursor to the Hebrew religious calendar, while the Egyptian calendar was supplanted by the *Coptic,* or *Alexandrian calendar* to better sync with the newly-minted Julian calendar. Incremental refinements to the leap year system in the Julian calendar led to the introduction of the Gregorian calendar in 1582, which stands as the dominant calendar of the modern age.

In the Gregorian calendar, leap years are inserted into the calendar according to various divisibility rules. The following algorithm suggests the historical development of these rules:

- There are no leap years (the Egyptian calendar)
*unless*the year is divisible by 4 (the Julian calendar)*unless*the year is divisible by 100 (the Gregorian calendar)*unless*the year is divisible by 400 (the Gregorian calendar)

**— HOW LONG IS A DAY? —**

The Gregorian system includes 97 additional days every four centuries, and suggests that the length of the average tropical year is

So, how close does this come to the true year length?

Unfortunately, this is a question without an answer. While Kepler’s laws suggest absolute periodicity of orbits, the *nutation* of the Earth and the slight wobble of the Sun (due to gravitational influence of other planets) lead to a mean tropical year that changes (albeit slowly) over time.

To be strangely specific, Laskar’s planetary model (1986) suggests that for years near 2000 (give or take 10,000 years), the length of the mean tropical year has the following third-order Taylor approximation:

in which *Y* is number of (signed) Gregorian years from the year 2000. In particular, we compute that the length of the expected tropical year in 2017 is 365 days, 5 hours, 48 minutes, and 36.243 seconds. (This is a full 10 seconds shorter than the year 2000.)

**— LEAP YEARS AS CONVERGENTS —**

But let’s ignore the chaotic instability of the solar system for a moment and suppose that the Earth becomes locked into a perfect orbit with a tropical year of 365.242086145121 days. What becomes the optimal leap year system to reduce drift from the tropical year?

One solution is to simply intersperse 14614766 leap years into every block of 60370105 years, but this method is a little clunky and doesn’t suggest how to distribute these leaps to reduce local errors.

A second solution uses the theory of continued fractions and convergents. In continued fraction notation, we have

which we use to produce convergents *a/b* for the proportion of years that should leap. These convergents are

in which we recognize the Julian 1/4.

Here, we’ve defined convergents using continued fractions, but their fundamental property is made more clear by an independent definition: a reduced fraction *a/b* is a convergent to the number if

for all fractions *p/q* with denominator . In other words, *a/b* is the best approximation to with `small’ denominator.

It should be clear how to use the first convergent, 1/4, to distribute leap years. For the second, 7/29, we begin with a leap year every 4 years, then notice that we’ve been over-counting by 1/4-7/29 and correct by subtracting 1/116. This creates the following rule: `** include leap days in years divisible by 4, unless that year is divisible by 116′.** Note that even at this early stage we appear to differ from the Gregorian system.

Continuing in this way produces the alternating series of refinements

which not only suggests an incredibly convoluted scheme but also requires a huge number of epicycles to resolve itself!

Such is the issue with convergents — by looking only at improvements that can be implemented in the shortest periods possible, we end up with a greater number of terms in the long run. For example, had we jumped from 1/4 to 15/62 in a single refinement, we arrive at the leap year rule `** divisible by 4 unless divisible by 124′**, which drifts from the tropical year no faster than the system of corrections involving 4, 116, 957, and 2046 year cycles.

It’s safe to say that refinements via convergents are not the answer, but before we throw them under the bus I would like to remark on one of their nicer properties — the approximations they provide can always be written as a sequence of *unit fractions*, fractions with numerator one.

**— ALTERNATING EGYPTIAN FRACTIONS —**

It’s unclear where and when rational numbers originated. They were widely accepted at least in ancient Egypt, with the small caveat that these *Egyptian fractions* were always written as a sum of unit fractions, ie.

(with the sole exception of 2/3, which was for some reason allowed). Allowing for repetition, it becomes clear that every rational number can be written as an Egyptian fraction. This works even if we force the denominators in our fraction to be distinct, a fact better left to the exercises.

Following the example of Egyptian fractions, I define an *alternating Egyptian fraction* (AEF) as a rational number written as an alternating sum of unit fractions with strictly increasing denominators. (Following the remarks at the end of the last section, we see that every proper fraction can be written as an AEF via refinement of convergents.)

To fix notation, we write these as increasing sequences , and say that an AEF is an *approximation* to if

and so forth. Since each AEF can be used to create a leap year rule, we are led to consider the following questions:

- Given a -term AEF approximation to , which unit fraction should I add or subtract to minimize error in a -term AEF approximation to ? (The algorithm to produce approximations by iterating this approach would be considered a
*greedy algorithm*.) - In general, what is the optimal
*k*-term AEF approximation to ?

The first question is easy to answer, since at each step we’ve either over- or under-estimated (depending on whether our last term was positive or negative (resp.)), and the next unit fraction we include should be the smallest unit fraction (ie. with the largest denominator) that, when included, under- or over-counts in the opposite direction.

In our particular case we get the sequence of AEF *`convergents’*

This algorithm *converges quadratically* to our limiting value, in that the number of digits of accuracy roughly doubles at each iteration. In fact, the three-term approximation above lies *within a millisecond* of our stated `correct’ value. (It’s a bit of an understatement to say that this converges quadratically, since this algorithm actually terminates after 8 steps with an exact answer. For comparison, the continued fraction-based algorithm terminates after 14 iterations.)

Question (2) above is a lot harder to answer, and I know no way to solve it beyond brute-force searching through fractions of bounded denominator. (I’ll make these bounds clearer in a second.)

The best 1-term approximation is clearly still 1/4. For two-term approximations , we may assume that (else ). For each choice of we produce a bound on using the condition . Taking the worst of these bounds shows that in general, and searching this space reveals that

is the best 2-term AEF approximant to . To find optimal 3-term AEF approximant to , we bound in a similar fashion, and find (unsurprisingly?) that the familiar expression

is in fact optimal among 3-term AEF approximations to .

At this point it seems reasonable to conjecture that the greedy algorithm always finds the optimal *k*-term AEF approximation to . Yet after a bit of experimentation we conclude that this conjecture is **false** (at least for ); one simple counter-example can be seen by taking and . Here, the greedy algorithm gives the inexact approximation

while shows that an exact estimate is possible.

**— LACK YEARS —**

The approximations in the last section seem to suggest leap year rules beginning with the phrase ** `hold a leap year if the year is divisible by 4, unless the year is divisible by 126′**.

But here we’d be mistaken, as what our approximations really do is give algorithms for adjusting the number of days in a given year: add a day if the year is a multiple of 4, subtract a day if the year is a multiple of 126, etc. One quirk of this system is that the year 126 now has only 364 days — one might call it a *lack year*.

But lack years are silly, so we look to a solution already visible in the Gregorian calendar — choose an AEF approximation in which for all *k*. Under this additional restriction, we expect our AEF approximations to worsen, but how much? What are the new optimal AEF approximations to the mean tropical year?

Here, a modified greedy algorithm gives the sequence of approximations

which *converges linearly* (ie. the number of correct digits increases like a linear function in the number of terms).

Since the Gregorian calendar uses a 3-term approximation it’s reasonable to make a comparison between the accuracy of that system and the third approximation above. Here, we find that our new system is 276 times more accurate. (On the other hand, our `improvement’ is still almost 20,000 times less accurate than the system from the previous section.)

Ignoring our greedy algorithm and performing a brute force search gives the following sequence of optimal approximations:

,

which gives another counter-example to the *`greed is good’* mantra but doesn’t offer improvements at the 3-term correction scale.

**— CONCLUSIONS? —**

So, which of these systems would I recommend? Ultimately, I’d have to say **it doesn’t really matter**. Given the erratic nature of the Earth’s orbit, no system of this form will remain accurate for a timescale long enough to let these theoretical mean discrepancies compound in an meaningful way.

Thus, in the end, simplicity is key. The rule ** `leap year if divisible by 4 unless divisible by 124′** gives greater accuracy (for our current tropical year) while using one less clause than the Gregorian system.

Or, if you think that the nice use of centuries in the Gregorian system puts it over the top, consider the following `modified Gregorian’ rule: ** `leap year if divisible by 4 unless by 100 unless by 500′**, which captures the simplicity of the 1582 classic while measuring our current orbit with twice the accuracy.

**— EXERCISES —**

**Exercise 1: **According to the cubic fit of Laskar’s planetary model, the Gregorian calendar gives an accurate length for the mean tropical year three times near the year 2000. In which years did this occur?

**Exercise 2: **Prove that every rational number can be written as an Egyptian fraction with distinct denominators. (This problem has been described as *the first calculus.*)

**Exercise 3: **Prove that every infinite alternating Egyptian fraction converges to a real number in , and prove that every real number in may be written as a limit of alternating Egyptian fractions.

**Exercise 4: **Formalize the algorithm for constructing greedy AEFs and prove that the approximations constructed in this way converge quadratically.

**Exercise 5: **Find the best 4-term AEF approximation to the mean tropical year. Is it the approximation you get using the greedy algorithm? *Hint: Please don’t try to do this by hand.*

**Exercise 6: **Prove that there is an open set of for which the greedy algorithm fails to produce the optimal *k*-term AEF approximation for some *k*.