Continued Fractions
This is lab was written by Elad Zelingher, all rights reserved to Elad Zelingher.
Continued fractions are a way of representing real numbers. Given a real number , recall that we define and . If (that is, if is not an integer), then we have that and thus , where . We continue the process. Suppose that and are defined so that for every . We define . If (that is, if is an integer), then we have that
Otherwise, we have that where and
The process ends if and only if the number is rational. Otherwise, the sequences and are infinite. If the process ends at step , we write
Otherwise, we write
Problem 1
Compute the continued fractions of , and of .
Problem 2
The program ContinuedFraction allows you to compute the continued fraction of a number of the form where is a non-square integer (or zero) and are rational numbers. Use this program to verify the computations from the previous problem.
Problem 3
For a rational number with and coprime compare the continued fraction of produced by ContinuedFraction and the Euclidean algorithm steps for and produced by EuAlgDem. How are these related?
Problem 4
A continued fraction is called essentially periodic if the sequence is periodic from some place. Suppose that is periodic from place and that its period is of length . We write
Use ContinuedFraction with different inputs to test whether the continued fraction of is always periodic for .
Problem 5
A continued fraction is called purely periodic if it is periodic from the first term. Given a purely periodic continued fraction, we can find the number it represents by writing down a recursive expression. For example, if
Then we have and hence . This equation has two solutions
However it is clear that is positive so we must have .
Using this we can evaluate essentially periodic continued fractions: we first compute the periodic part and then substitute the expression we have for it in the continued fraction. Use this method to compute and check your result using ContinuedFraction.
Problem 6
The program PCFEvaluator allows you to evaluate an essentially periodic continued fraction. Use this program to find numbers whose continued fraction expression is purely periodic. Can you classify these numbers?
Problem 7
Consider numbers of the form where is a square free integer. From which element of the sequence does the sequence become periodic? Use ContinuedFraction.
Problem 8
The convergents of for a positive square-free integer are closely related to the Pell equation
Choose and try computing for the convergents of using ContinuedFraction. Keep a list of which pairs satisfy that this difference is . Now do the same for .
Problem 9
The equation
Can be rewritten in the form
Thus Pell's equation secretly seeks for the elements in with norm .
Choose the first pair from each of the lists you made in the previous problem and compute the powers of using QuadraticPowerTab. What are the first few powers? How are they related to rest of the pairs you have on that list?
Problem 10
Use ContinuedFraction for different to try to find a pattern for the first convergent that satisfies the Pell equation