Bill Wood’s post on continued fractions gave an introduction into many of the interesting ways that we can represent rational and irrational numbers. Andy Novocin’s post was a follow-up to Bill’s post. Andy discussed some open questions about transcendental numbers and gave a glimpse about how a mathematician thinks about problems.
This post is a “how-to” piece. I’ll explore in step-by-step detail how we can construct continued fractions in some special cases. For the math teacher who wants to give some enrichment exercises, this may be perfect.
Messing Around
First, let’s just build up a little bit of a comfort level with working with fractions. If you’re already comfortable with fractions, skip this section.
With continued fractions, we are going to want to write things like $$\frac{1}{1 + \frac{1}{1 + 1}}$$
Resolving this looks like this
$$\begin{eqnarray*}
\frac{1}{1 + \frac{1}{1 + 1}} & = & \frac{1}{1 + \frac{1}{2}}\\
& = & \frac{1}{\frac{3}{2}}\\
& = & \frac{2}{3}
\end{eqnarray*}
$$
Continuing …
So, now let’s see what happens when we try to do something like this
$$\frac{1}{2 + \frac{1}{2 + \frac{1}{2 + \cdots}}}$$
Notice the \(\cdots\)? That means that the pattern continues on forever. This is an example of a continued fraction.
So how do we actually compute anything with fractions that go on forever? Here’s one way. Let’s start with \(\frac{1}{2}\) and “add” to it \(\frac{1}{2}\) like so
$$\frac{1}{2 + \frac{1}{2}}$$
This gives us \(\frac{2}{5}\). And if we want to get the next “layer”, we simply do
$$\frac{1}{2 + \frac{2}{5}}$$ since
$$\begin{eqnarray*}
\frac{1}{2 + \frac{1}{2 + \frac{1}{2}}} & = & \frac{1}{2 + \frac{2}{5}}
\end{eqnarray*}
$$
and this gives \(\frac{5}{12}\) and the next layer is just
$$\begin{eqnarray*}
\frac{1}{2 + \frac{1}{2 + \frac{1}{2 + \frac{1}{2}}}} & = & \frac{1}{2 + \frac{5}{12}}\\
& = & \frac{12}{29}
\end{eqnarray*}
$$
Try this yourself!
Making a Continued Fraction
Here we’ll need to get some algebra going. What is the positive \(x\) that solves \(x^{2} = 2\)? The answer is, \(x = \sqrt{2}\). But what is \(\sqrt{2}\)? We know it’s an irrational number and thus cannot be represented as a fully-reduced ratio of two integers. There are many methods that exist to extract a numerical value for \(\sqrt{2}\), but we’re interested in setting up a continued fraction for this.
So let’s try the following mumbo-jumbo:
$$\begin{eqnarray*}
x^{2} & = & 2\\
x^{2} – 1 & = & 1 \mbox{ (subtract 1 from both sides)}\\
(x-1)(x+1) & = & 1 \mbox{ (factor the left-hand side for mysterious reasons)}\\
(x-1) & = & \frac{1}{x + 1}\\
(x-1) & = & \frac{1}{x – 1 + 1 + 1} \mbox{ (allowed to add and subtract one!)}\\
(x-1) & = & \frac{1}{(x-1) + 2} \mbox{ (group to have \(x-1\) on both sides)}\\
y & = & \frac{1}{2 + y} \mbox{ (let \(y = x-1\))}
\end{eqnarray*}
$$
Now, the real mumbo-jumbo begins. Notice that \(y = \frac{1}{2 + y}\) has \(y\) on both sides. So, if we “substitute” the right-hand side for \(y\) on the right-hand side we obtain
$$y = \frac{1}{2 + \frac{1}{2 + y}}$$
Continuing in this manner we end up with
$$y = \frac{1}{2 + \frac{1}{2 + \frac{1}{2 + \cdots}}}$$
And we have a continued fraction! But what is this continued fraction for? Well, \(y = x – 1\) and \(x\) we know was supposed to be \(\sqrt{2}\) because we set up the problem that way (\(x^{2} = 2\)). So, this is the continued fraction for \(\sqrt{2} – 1\).
The first few fractions are \(\frac{1}{2}, \frac{2}{5}, \frac{5}{12}, \frac{12}{29}, \frac{29}{70}\). (Can you see the pattern in how the fractions are constructed? Can you deduce that the next fraction would be \(\frac{70}{70\cdot 2 + 29} = \frac{70}{169}\)?)
Looking at the decimal representation we have
$$\begin{eqnarray*}
\frac{1}{2}& = & 0.5\\
&&\\
\frac{ 2 }{ 5 }&=& 0.4 \\
&&\\
\frac{ 5 }{ 12 }&=& 0.416666666667 \\
&&\\
\frac{ 12 }{ 29 }&=& 0.413793103448 \\
&&\\
\frac{ 29 }{ 70 }&=& 0.414285714286 \\
&&\\
\frac{ 70 }{ 169 }&=& 0.414201183432 \\
&&\\
\frac{ 169 }{ 408 }&=& 0.414215686275 \\
&&\\
\frac{ 408 }{ 985 }&=& 0.41421319797 \\
&&\\
\frac{ 985 }{ 2378 }&=& 0.414213624895 \\
&&\\
\frac{ 2378 }{ 5741 }&=& 0.414213551646 \\
&&\\
\frac{ 5741 }{ 13860 }&=& 0.414213564214
&&\\
\sqrt{2}-1 & \approx & 0.414213562373
&&\\
\sqrt{2} & \approx & 1.414213562373\end{eqnarray*}
$$
Not a bad rational approximation for an irrational!
Can you do something similar to find \(\sqrt{3}\)?