Continued Fractions

There are several different ways one can express a particular value. We can write the value using different bases, for example. If the value is rational, we could of course express it as a fraction. We can also express rational values as decimal values with digits that either terminate or repeat. The notion of continued fractions gives us yet another alternative to throw into the mix...

We say that a value $x$ has been expressed as a simple continued fraction when it is written in the following form:

$$x = a_0 + \frac{1}{\displaystyle{ a_1 + \displaystyle{\frac{1}{\displaystyle{a_2 + \displaystyle{\frac{1}{a_3 + \cdots}}}}}}}$$

where $a_0$ is an integer (possibly zero or negative), and $a_1, a_2, a_3, \ldots$ are positive integers.

As the above is somewhat cumbersome to write and/or type, we often abbreviate this with the following notation:

$$x = [a_0; a_1, a_2, a_3, \ldots]$$

Converting Rational Values to Continued Fractions

The process for converting an arbitrary rational value into its continued fraction form is straight-forward, and we describe it by example:

Suppose we wish to find the continued fraction form of

$$x=-\frac{95}{82}$$

Any fraction may be written as the sum of an integer and a positive fraction less than one in magnitude; finding the same here yields.

$$x = -2 + \frac{69}{82}$$

Now, let us modify the form (but not the value) of the fractional piece using reciprocation:

$$x = -2 + \frac{1}{\displaystyle{\quad \frac{82}{69} \quad}}$$

In doing so, we create an improper fraction in the denominator, which again can be resolved into the sum of an integer and a positive fraction less than one. Note also, that the integer part must be positive, since our improper fraction was positive.

$$x = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{13}{69}}}}$$

Play the same game again -- reciprocating our fraction less than one, we arrive at

$$x = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{1}{\displaystyle{\frac{69}{13}}}}}}$$

and writing the resulting improper fraction as a sum of an integer and a positive fraction less than one, we get

$$x = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{1}{\displaystyle{5 + \frac{4}{13}}}}}}$$

In this example, we can do this one more time before the process naturally terminates

$$x = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{1}{\displaystyle{5 + \displaystyle{\frac{1}{\displaystyle{3+\frac{1}{4}}}}}}}}}$$

The above work then tells us that $-95/82 = [-2;1,5,3,4]$.

Finite Simple Continued Fractions

In the case when the sequence of $a_n$ terms terminates (like the one just shown), we say that $x$ can be written as a finite simple continued fraction.

It should be clear that every finite simple continued fraction is rational, as its layers can be collapsed until all that is left is a single quotient of two integers.

For example, suppose we wished to collapse in this way the finite simple continued fraction $[3;2,5,4,2]$.

Starting with the bottom-most layer, we find common denominators to combine the integer and fraction located there, and then we reciprocate the result to eliminate that layer. Then, we do the same thing again, and again -- repeating this process until we have collapsed the entire fraction:

$$3 + \frac{1}{\displaystyle{ 2 + \displaystyle{\frac{1}{\displaystyle{5 + \displaystyle{\frac{1}{4 + \displaystyle{\frac{1}{2}}}}}}}}} = 3 + \frac{1}{\displaystyle{ 2 + \displaystyle{\frac{1}{\displaystyle{5 + \displaystyle{\frac{2}{9}}}}}}} = 3 + \frac{1}{\displaystyle{ 2 + \displaystyle{\frac{9}{47}}}} = 3 + \frac{47}{103} = \frac{356}{103}$$

So we know that every finite simple continued fraction is rational -- but is the reverse true? Does every rational value have a finite simple continued fraction form?

Think back to the process we used to turn an arbitrary fraction into a continued fraction. Does this process necessarily terminate in finitely many steps, regardless of our starting fraction?

Yes -- it must!

Arguing by example, consider again the steps seen in turning $-95/82$ into a continued fraction:

$$-\frac{95}{82} = -2 + \frac{69}{\fbox{82}} = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{13}{\fbox{69}}}}}= -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{1}{\displaystyle{5 + \frac{4}{\fbox{13}}}}}}} = -2 + \frac{1}{\displaystyle{ 1 + \displaystyle{\frac{1}{\displaystyle{5 + \displaystyle{\frac{1}{\displaystyle{3+\frac{1}{\fbox{4}}}}}}}}}} $$

Notice the bottom-most fraction at each stage. Each of these, by construction, must be proper fraction (i.e., less than one), so their denominators are always greater than their numerators. So we see that

$$82 \gt 69 \quad \quad \textrm{ and } \quad \quad 69 \gt 13 \quad \quad \textrm{ and } \quad \quad 13 \gt 4$$

Again, by construction, the numerator of the bottom-most fraction in any one stage is the denominator of the bottom-most fraction in the next stage, allowing us to create a string inequality

$$82 \gt 69 \gt 13 \gt 4$$

With the possible exception of the very first integer, the construction forces all of the other integers found (denominators included) to be positive. This, combined with the string inequality above, tells us that the sequence of bottom-most denominators must be a decreasing sequence of positive integers. Such a sequence must terminate -- as otherwise it will eventually pass zero and start to produce negative terms (a contradiction).

We have thus shown that not only is every finite simple continued fraction rational, but every rational value can be expressed as a finite simple continued fraction.

Infinite Continued Fractions

How might we construct a continued fraction for an irrational value? Note, we expect such a continued fraction will not have a finite form...

Suppose we wished to do this for $\sqrt{7}$. We can proceed in a very similar manner to what was described to convert a rational to continued fraction form:

Since $\sqrt{7} \doteq 2.645751311\ldots$, we first split it into an integer and a positive decimal value less than one.

$$\sqrt{7} = 2 + 0.645751311\ldots$$

Reciprocating the decimal piece, we have

$$\sqrt{7} = 2 + \frac{1}{1.54858377\ldots}$$

The reciprocation produces something bigger than one in the denominator, which we can again split into an in integer and a positive decimal value less than one.

$$\sqrt{7} = 2 + \frac{1}{1 + 0.54858377\ldots}$$

Again, we follow this with reciprocation...

$$\sqrt{7} = 2 + \frac{1}{1 + \displaystyle{\frac{1}{1.822875656\ldots}}}$$

and so on, producing

$$2 + \frac{1}{1 + \displaystyle{\frac{1}{1 + 0.822875656\ldots}}} = 2 + \frac{1}{1 + \displaystyle{\frac{1}{1 + \displaystyle{\frac{1}{1.215250437\ldots}}}}} = 2 + \frac{1}{1 + \displaystyle{\frac{1}{1 + \displaystyle{\frac{1}{1 + \displaystyle{\frac{1}{4 + 0.645751311\ldots}}}}}}}$$

At this point, something interesting happens. Notice that the decimal value seen in the last step agrees with the decimal value we saw in the first step. Not surprisingly, our calculations start to repeat themselves from this point forward.

This results in an infinite simple continued fraction representation for $\sqrt{7}$, given by

$$\sqrt{7} = [2;1,1,1,4,1,1,1,4,1,1,1,4,\ldots]$$

Borrowing the notation for specifying a repeating pattern in a decimal expansion by placing a bar over the part that repeats, we indicate the periodic nature of this infinite continued fraction by writing

$$\sqrt{7} = [2;\overline{1,1,1,4}]$$