Calendars are Cool Part 2: Be Rational

Rational numbers are your friend when making a calendar. If you recall the year and month lengths presented in Part 1, they're not at all what most people would consider "nice numbers". Truth is, you never get nice numbers when working with anything astronomical. Calendars "nice-ify" the numbers they're working with by using rational approximations of the real value instead.

To talk in real-world terms, one year on Earth is about 365.2422 days. That means a calendar with 365 days in it (like the Gregorian Calendar) would be 1 day off after 4 years. You'll see how I made that calculation in a bit. But that's why we have leap days! Every four years, when we would be 1 day off, we add an extra day to "correct" the calendar and bring it back in line with the solar year. (In truth, the Gregorian Calendar leap year system is more complicated than this. But the Julian Calendar does use this system.)

So how do you know how often to add a day? Well, that's where rational approximation comes in handy. We're going to learn about continued fractions and how they are your best friend when it comes to approximations.
A general continued fraction. Yikes.

Let's turn our solar year length into a continued fraction. Continued fractions look a bit scary, but  they're actually quite simple to create, and helpful with approximating. There are two steps:

  1. Take the number on the left of the decimal point. This is your next "a" value.
  2. Find 1 divided by the decimal part of your number (the part to the right of the decimal point). Loop back to step 1.
You can do these steps until you're happy with the number of values you have, or you run out of precision and you end with 0. Let's do an example with our set-up's solar year length: 379.11236843710856 days. We have plenty of precision to go around, so I'm going to stop after we get five values.

Our first number is 379.
1/0.11236843710856 = 8.899296152298465.
Our second number is 8.
1/0.899296152298465 = 1.1119807389858738.
Our third number is 1.
1/0.1119807389858738 = 8.930107168931512.
Our fourth number is 8.
1/0.930107168931512 = 1.0751449224381093.
Our fifth number is 1.

Great, now we have five numbers, but what do they mean? Well, let's go back to that image. We just found a₀, a₁, a₂, a₃, and a₄ in our continued fraction representation . So what do those mean? What does a continued fraction let us do?

Continued fractions are helpful not because they go on forever, but because "chopping" them off gives you the closest approximations to your original number. When you chop off a continued fraction, you include all values up to a point, and set the rest of the expansion to 0.

If you chop off at a₀, it means that 379 is the best whole-number approximation.
If you chop off at a₁, it means 379 + 1/8 is also good.
If you chop off at a₂, it means (after simplifying) 379 + 1/9 is a better approximation.

The a₂ approximation.

The a₃ approximation.


Basically, the later you chop off the continued fraction, the better and better the approximations get. Let's look at the next few approximations:

a₃: 379 + 9/80
a₄: 379 + 10/89

Notice that the denominator gets more complicated, but the accuracy also improves. Below is a comparison of each approximation. You can see how the number of correct digits increases the farther you go.

Original: 379.11236843710856
a₀: 379.
a₁: 379.125
a₂: 379.111111...
a₃: 379.1125
a₄: 379.112359...

I stopped at the fifth value (a₄) because something interesting happens to the next one: we get 13, the biggest value we've seen in the fraction part of the continued fraction. This is important because big numbers in the continued fraction indicate that the next best approximation gets a big denominator, which is bad. Let's take a look at the a₅ approximation:

379 + 139/1237 = 379.11236863...

Sure, it gave us two extra decimal places, but at what cost? Look at that denominator! 1237 is huge and complicated, and it makes things very difficult if you try to use it in a calendar. Unfortunately, our approximation adventure stops here with the solar year.

Continued fractions are like a number's "signature", telling you important information about how well you can approximate that number with fractions. When making calendars, there's a trade-off between accuracy and complexity. Accuracy ensures that your calendar is representing its goal well, but you also want it to be simple enough to be usable.

Next time, we'll look at the set-up and look at the continued fractions of each term.

Comments

Popular Posts