Continued Fractions
Definition: Continued Fraction
A continued fraction is has this shape:
The series
These are useful for approximating irrational numbers by a rational one. One can just cut off the continued fraction at any point and simplify the fraction.
Expansion algorithm
The algorithm to expand a number works like the following. We will take
We now know that
The
We take
This expression evaluates to 0.366, so let us write it again as a double inverse.
We simplify the innermost fraction again:
Such that we have
Then we can resolve one level of fractions again:
We can then split off a 2 because the following sub-expression evaluates to 2.732:
We then need to simplify the latter part:
Let us collect the terms that we have so far:
We're only interested in the coefficients. There is a non-periodic part of
Convergents
The continued fractions are infinitely deep and hence equal the irrational number. When we cut off the expansion at some point, we can get a rational approximation. Let us again take
We need to simplify this fraction. We start on the inside and simplify:
Then we need to invert this and simplify with the next coefficient:
Invert again and simplify with the next coefficient:
And again:
That is a good approximation to
The algorithm here is just taking a list of coefficients and simplifying the fractions in reverse.