A continued fraction (Kettenbrüche in German) is a finite or infinite expression of the form
with convergence under appropriate conditions. The most commonly used form is where for all ; such is called a regular continued fraction.
Every real number may be (more or less1) uniquely expressed as a finite or infinite regular continued fraction for which all the are integers and for . The expression is an infinite continued fraction if and only if the real number is irrational, so that there is a bijection
This is in fact a homeomorphism if we endow the left side with the product topology and the right side with the subspace topology, regarding the set of irrationals as a subset of the real line (with its standard topology). (The space of irrationals becomes in this way a kind of prototypical chaotic dynamical system, where the dynamics on the product space is given by a shift map.)
We can describe the basic theory of continued fractions for real numbers in terms of dynamics of fractional linear transformations on the real projective line , with the point at infinity playing a special role. From an nPOV, it is useful to cast this in coalgebraic terms.
Let us denote by the interval (considered as a subset of the projective line ); if , we let be the floor of (the greatest integer such that ). We denote by the set of positive integers (so, excluding ). Put , and define a map
where if , and . This defines a coalgebra of the functor defined by the formula
Let us define to be rational if it is a quotient of two integers (including , so is here considered “rational”). Define by if , and .
An element is rational if and only if there exists such that .
Only if: this is clear for . Otherwise, write in lowest terms, so that and . We argue by strong induction on , where we have for which and by the Euclidean algorithm. If , then and we are done; otherwise where and , whence for some by inductive hypothesis, and then .
If: argue by induction on the least such that . If , then is rational. Otherwise, we have
and since , we have that is rational by inductive hypothesis, and therefore is also rational.
If is any sequence of positive integers, then there is a unique such that for all . (This must be irrational by Lemma .)
In a nutshell, is given by the continued fraction
and so it is really only a matter of proving that this continued fraction converges, i.e., that its truncations , namely the rational numbers with and for , form a Cauchy sequence.
For , let denote the fractional linear transformation . We have
and since is monotone decreasing, we have that is monotone increasing. Thus some easy inductions establish
so that , and all that remains is to show .
In fact we have
The second equation is proved by induction on the length of continued fraction representations . Put and , with all fractions in reduced form, and suppose as induction hypothesis that . The fractional linear transformation , being represented by the integral matrix
with determinant , takes -determinant matrices to -determinant matrices. In particular it takes the determinant of absolute value on the left to one on the right,
and this completes the induction.
Here and . Similarly, if
then and . Thus we have
so that by induction, , completing the proof that the infinite continued fraction converges.
It may be tempting to believe that this -coalgebra structure makes the terminal coalgebra. That is unfortunately not correct because the coalgebra structure is not an isomorphism (it fails to be surjective because no element maps to under ; this is the fact that the standard continued fraction for is just and not ). However, below we will exhibit a different kind of coalgebra making half-open intervals a terminal coalgebra.
Let be the set of irrational elements . The results above imply that equipped with the map
is a terminal coalgebra for the functor , isomorphic to under the coalgebra structure
Endow with the subspace topology coming from (as one-point compactification of ), and with the topology of the product of countably many discrete spaces .
The coalgebra isomorphism is a continuous map.
It suffices to check that each composite
is continuous. Following the notation above, this composite map is , so it suffices to check that is continuous, or in other words that
is open for every . This set is clearly open, being the intersection (noting that of course !).
The coalgebra isomorphism is continuous.
This merely says that for each sequence of positive integers and for a given , that there exists such that provided for . But this just follows the proof of convergence of continued fractions given in the proof of Lemma .
The coalgebra isomorphism is a homeomorphism.
This makes the space of irrationals the terminal coalgebra for the endofunctor .
A continued fraction is periodic, i.e., satisfies for some fixed and all , only if it is the root of a quadratic equation (where the operator on the left can be written as a fractional linear transformation). Every quadratic irrational is eventually periodic (i.e., for some and we have for all ): the proof is part of the theory of Pell's equation?.
This example shows that periodic points are dense in the discrete dynamical system , since quadratic surds are dense among all irrationals.
Part of the story of Pell’s equation is that an integer solution to , with is a square-free integer, is a pair where is a reduced form fraction (a rational approximant) represented by a finite truncation of the continued fraction of .
The quadratic irrational represented by is the golden ratio . Many properties of this constant (as manifested both mathematically and physically) are due to this fact and the fact that of all infinite continued fractions, the convergence rate of its rational approximants is slowest for this number.
Were the Pythagoreans the first to do coalgebra? John Baez remarks in Week 265 that the Pythagoreans were fascinated by pentagrams, and drops hints that they may have been aware of the continued fraction for the golden ratio and also the fact that is irrational. The Pythagorean pentagram on display in Baez’s page clearly indicates an infinite stream of pentagons which can be viewed as a coalgebraic behavior stream. And indeed if were a rational number with as small as possible, then we would also have , with numerator and denominator even smaller, contradiction. This is analogous to one of the famous proofs of irrationality of : if , then also , which generates an infinite descending stream of positive numerators and denominators, contradiction.
The regular continued fraction for Ludolph's number displays no regularity, but other types of continued fractions do. See Wikipedia.
The popularity of certain rational approximations to pi such as or can be explained by the fact that these are rational approximants obtained by truncating the regular continued fraction for , coupled with the following result.
The truncation is a “best” rational approximant to the irrational number , in the sense that it minimizes the distance to among all rational numbers whose denominators are less than or equal to .
The space of irrationals may be identified with the space of irrationals in the interval (by taking their reciprocals). Here the action is generated by the shift map .
The map is topologically mixing. Moreover, if is equipped with the probability measure
then is an ergodic transformation? with respect to , making an ergodic system.
A proof may be found here.
Returning to the theme of coalgebras, an alternative form of continued fractions may be used to exhibit a half-open real interval as a terminal coalgebra. The alternative continued fractions are of the form
where the are suitable integers; for now we will call them antiregular continued fractions (not knowing what others call them), or acf’s for short. These acf’s correspond to fractional linear transformations belonging to , generated by the transformations , .
Consider the linear order (this time excluding ); let be the smallest integer strictly greater than .
Consider the endofunctor on the category of linearly ordered sets where is the set equipped with the ordinal product or lexicographic order. (Actually we replace with the set of integers greater than or equal to .) Define a map
where .
(Pavlovic-Pratt) The map defines a -coalgebra structure , making the terminal -coalgebra.
Now let , the set of rational elements of . On the category of linear orders, let be the endofunctor , the ordinal sum where was defined above.
The initial -algebra is the free monoid , lexicographically ordered according to the convention given in this remark (where initial segments of words are greater than ).
On the other hand, we have an -algebra structure on , a function
where for , , otherwise . Observe that this is indeed a monotone map between the linear orders .
is the initial -algebra.
The inverse map is in essence another form of the acf (see above): if denotes the least integer greater than or equal to , then , and otherwise
The -algebra isomorphism takes a finite word to the rational number to which the acf
evaluates.
Among the many uses of continued fractions, we mention a quite remarkable one due to John H. Conway.
A rational tangle is a subspace of the 3-disk obtained by embedding two arcs
with endpoints on the boundary , such that the pair of spaces is homeomorphic to the pair , with distinct points. Two rational tangles are isotopic if there exists an orientation-preserving homeomorphism that is the identity on .
Conventionally, rational tangles (or more general 2-tangles) are exhibited by tangle diagrams placed within a disk (with appropriate over- and under-crossings), say a unit disk in the complex plane, with endpoints situated at primitive roots of unity ; these endpoints are indicated by their directions NE, NW, SW, SE. There is a trivial 2-tangle with a chord from NE to NW and another from SE to SW; this is denoted . Two operations that can be used to generate further 2-tangles are
“Turn” (rotate the disk through 90 degrees counterclockwise),
“Twist” (insert a “horizontal” twist that interchanges NE and SE, which can be a positive twist or a negative twist depending on convention).
(Conway) The set of isotopy classes of rational tangles is in bijection with the set of rational elements , in such a way that if is the isotopy class corresponding to , then is the class corresponding to a turn of , and is the class corresponding to a positive twist of .
In particular, every rational tangle can be brought back to the trivial tangle by a series of (positive) twists and turns, and every rational tangle is isotopic to the tangle obtained by applying a 180 degree counterclockwise turn to it. A very readable account of this result may be found in an article by Kauffman and Lambropoulou, here.
It should be remarked that the twist and turn operations correspond to group elements in (cf. the article Moebius transformation, in particular the remarks on the surjective homomorphism where is the braid group on strands):
John Baez asks a question about this in TWF228, and reports on an answer in TWF229. He returns to this topic in an illuminating comment here.
David Corfield speculates at the Café that the infinite tangles mentioned by Kauffman and Lambropoulou, as limits of rational tangles, might be viewed as belonging to a coalgebraic completion of the collection of rational tangles (along the lines of seeing the terminal coalgebra as a coalgebraic completion of the initial algebra , as in Theorem ).
The Calkin-Wilf tree is an infinite complete binary tree whose vertices are in 1-to-1 correspondence with the positive rational numbers. The tree may be defined inductively by the following very simple recipe (Calkin & Wilf, 2000):
For example, the first four levels of the Calkin-Wilf tree are:
Remarkably, every positive rational number appears exactly once in the tree, and so performing a breadth-first traversal () gives an enumeration of the positive rationals with no double-counting. In fact, Calkin and Wilf proved that the th number in this sequence is equal to
where is the number of ways of writing the integer as a sum of powers of 2, each power being used at most twice.
By locating a positive rational in the Calkin-Wilf tree and describing the path to from the root as a sequence of binary choices, one generates a string of bits which may be interpreted as an “uncompressed” representation of the continued fraction of . In turn, compressing this path by counting the number of repeated bits (i.e., by performing a “run-length encoding”) is a way of reconstructing the continued fraction. This is perhaps easier to see if we first express the two operations returning the left and right children of a vertex equivalently as
from which it follows that
Now, suppose a positive rational has continued fraction , assuming without loss of generality that is odd (we allow for ). Then the path from 1 to in the Calkin-Wilf tree begins by taking steps to the left, followed by steps to the right, steps to the left, and so on, ending with steps to the right. In other words,
For example:
Finally, the Calkin-Wilf tree gives a simple algebraic characterization of the positive rationals, namely as an initial object in the category of pointed modules for the free monoid on two elements . Given any such module and point , there is a unique module homomorphism sending to , defined as follows: given a positive rational , locate on the Calkin-Wilf tree, and then retrace the path from to in , beginning at and applying the actions and as appropriate.
The Calkin-Wilf tree was first described in a 2000 paper by Neil Calkin and Herbert Wilf, “Recounting the rationals”, but is closely related to the much older Stern-Brocot tree, another arrangement of the positive rationals with the special property that the values are ordered from left to right. Here are the first four levels of the Stern-Brocot tree:
In fact, each tree may be obtained from the other by reversing the paths from the root (e.g., is reached from the root of the Stern-Brocot tree by going down left twice and then right once).
The construction of a continued fraction from an arbitrary real number relies on the limited principle of omniscience to define the floor; it is not acceptable in constructive mathematics. Nevertheless, using the usual constructive meaning of rational number and irrational number (as well as convergence in the real numbers), we have that a continued fraction (involving natural numbers) represents a rational number iff it is finite and an irrational number iff it is infinite; and every rational or irrational number (if positive) is so representable. Constructively, we simply cannot say that every real number is either rational or irrational.
Now, just because a real number has an expansion as a continued fraction, that doesn't mean that it must be rational or irrational. In general, a continued fraction expansion (according to the coalgebraic formulation) is given by a stream of natural numbers, and a stream is not necessarily finite (so a list) or infinite (so a sequence). However, a stream that is not finite must be infinite; accordingly, a real number that is not rational must be irrational if it has a continued fraction; even this is not constructively valid without the continued fraction.
Wikipedia, Continued fraction
Claude Brezinski, Continued fractions and Padé approximants, North-Holland 1991. (vendor)
A. Ya. Khinchin, Continued fractions, U. Chicago Press 1964.
Ilan Vardi, Continued fractions from Euclid to the present day, unpublished manuscript (web)
Louis Kauffman and Sofia Lambropoulou, On the classification of rational tangles, arXiv (web).
Dan Piponi wrote a series of posts on his blog “A Neighborhood of Infinity”, using the programming language Haskell to illustrate some of the connections between continued fractions, rational tangles and linear operators:
The material on half-open intervals as terminal coalgebras was first given by Pavlović and Pratt,
A type-theoretic formalization of the rationals in Coq based on the Stern-Brocot/Calkin-Wilf representation is described in:
Their library includes two implementations of the field operations: 1. a “strict” implementation (in the programming languages sense) in which the operations are performed by first converting continued fractions to ordinary fractions, applying the usual algorithms for arithmetic, and then converting back, and 2. a “lazy” implementation operating directly on continued fractions, in which the operations only need to inspect a portion of the input stream in order to determine a portion of the output stream. This latter approach is based on ideas originally due to Gosper:
For rational numbers, there are two continued fraction representations, agreeing up to say , but ending with in one case and in the other (since after all ). This can be an annoyance, but there are various workarounds. ↩
Last revised on January 22, 2017 at 03:31:21. See the history of this page for a list of all contributions to it.