Continued Fractions
Continued Fractions are a way of representing real numbers as a sequence of positive integers. Let's say we have a real number
. We can form a sequence of positive integers from
in this way:
For example, let's say
. We can say that
The trick here is that if
, we can continue this exact process with
and keep the continued fraction going.
Let's take another example, that of
:
The list of continued fractions is represented as a list of the coefficients
, in this case
The
th convergent of a continued fraction is the approximation of the fraction we gain by truncating the continued fraction and using only the first
terms of the sequence, for example the 2nd convergence of
is
while the 3rd would be
.
One of the obvious applications of these convergents is as rational approximations to irrational numbers.
- As a sequence, they have a limit
- This limit is, the real number you are attempting to approximate
- They are alternately greater than and less than
In Sage, we can define a continue fraction very easily:
f = continued_fraction(17/11)
We can then print off the list of coefficients:
print(f)
>>> [1; 1, 1, 5]
And the convergents are even calculated for us:
print(f.convergents())
>>> [1, 2, 3/2, 17/11]
Last modified 1yr ago