Calkin–Wilf tree
   HOME

TheInfoList



OR:

In
number theory Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and integer-valued functions. German mathematician Carl Friedrich Gauss (1777–1855) said, "Mat ...
, the Calkin–Wilf tree is a
tree In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are ...
in which the vertices correspond one-to-one to the
positive Positive is a property of positivity and may refer to: Mathematics and science * Positive formula, a logical formula not containing negation * Positive number, a number that is greater than 0 * Plus sign, the sign "+" used to indicate a posi ...
rational number In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all rat ...
s. The tree is rooted at the number 1, and any rational number expressed in simplest terms as the fraction has as its two children the numbers and . Every positive rational number appears exactly once in the tree. It is named after Neil Calkin and
Herbert Wilf Herbert Saul Wilf (June 13, 1931 – January 7, 2012) was a mathematician, specializing in combinatorics and graph theory. He was the Thomas A. Scott Professor of Mathematics in Combinatorial Analysis and Computing at the University of Pennsylv ...
, but appears in other works including Kepler's ''
Harmonices Mundi ''Harmonice Mundi (Harmonices mundi libri V)''The full title is ''Ioannis Keppleri Harmonices mundi libri V'' (''The Five Books of Johannes Kepler's The Harmony of the World''). (Latin: ''The Harmony of the World'', 1619) is a book by Johannes ...
''. The sequence of rational numbers in a breadth-first traversal of the Calkin–Wilf tree is known as the Calkin–Wilf sequence. Its sequence of numerators (or, offset by one, denominators) is Stern's diatomic series, and can be computed by the fusc function.


History

The Calkin–Wilf tree is named after Neil Calkin and
Herbert Wilf Herbert Saul Wilf (June 13, 1931 – January 7, 2012) was a mathematician, specializing in combinatorics and graph theory. He was the Thomas A. Scott Professor of Mathematics in Combinatorial Analysis and Computing at the University of Pennsylv ...
, who considered it in a 2000 paper. In a 1997 paper, Jean Berstel and Aldo de Luca called the same tree the ''Raney tree'', since they drew some ideas from a 1973 paper by George N. Raney. Stern's diatomic series was formulated much earlier by Moritz Abraham Stern, a 19th-century German mathematician who also invented the closely related Stern–Brocot tree. Even earlier, a similar tree (including only the fractions between 0 and 1) appears in Kepler's ''
Harmonices Mundi ''Harmonice Mundi (Harmonices mundi libri V)''The full title is ''Ioannis Keppleri Harmonices mundi libri V'' (''The Five Books of Johannes Kepler's The Harmony of the World''). (Latin: ''The Harmony of the World'', 1619) is a book by Johannes ...
'' (1619).


Definition and structure

The Calkin–Wilf tree may be defined as a
directed graph In mathematics, and more specifically in graph theory, a directed graph (or digraph) is a graph that is made up of a set of vertices connected by directed edges, often called arcs. Definition In formal terms, a directed graph is an ordered pa ...
in which each positive rational number occurs as a vertex and has one outgoing edge to another vertex, its parent, except for the root of the tree, the number 1, which has no parent. The parent of any rational number can be determined after placing the number into simplest terms, as a fraction for which
greatest common divisor In mathematics, the greatest common divisor (GCD) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. For two integers ''x'', ''y'', the greatest common divisor of ''x'' and ''y'' is ...
of and is 1. If , the parent of is ; if , the parent of is . Thus, in either case, the parent is a fraction with a smaller sum of numerator and denominator, so repeated reduction of this type must eventually reach the number 1. As a graph with one outgoing edge per vertex and one root reachable by all other vertices, the Calkin–Wilf tree must indeed be a tree. The children of any vertex in the Calkin–Wilf tree may be computed by inverting the formula for the parents of a vertex. Each vertex has one child whose value is less than 1, , because of course . Similarly, each vertex has one child whose value is greater than 1, . As each vertex has two children, the Calkin–Wilf tree is a binary tree. However, it is not a
binary search tree In computer science, a binary search tree (BST), also called an ordered or sorted binary tree, is a rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left subtree and ...
: its inorder does not coincide with the sorted order of its vertices. However, it is closely related to a different binary search tree on the same set of vertices, the Stern–Brocot tree: the vertices at each level of the two trees coincide, and are related to each other by a bit-reversal permutation.


Breadth first traversal

The Calkin–Wilf sequence is the sequence of rational numbers generated by a breadth-first traversal of the Calkin–Wilf tree, :, , , , , , , , , , , , , , …. Because the Calkin–Wilf tree contains every positive rational number exactly once, so does this sequence. The denominator of each fraction equals the numerator of the next fraction in the sequence. The Calkin–Wilf sequence can also be generated directly by the formula :q_ = \frac where denotes the th number in the sequence, starting from , and represents the
integral part In mathematics and computer science, the floor function is the function that takes as input a real number , and gives as output the greatest integer less than or equal to , denoted or . Similarly, the ceiling function maps to the least int ...
. It's also possible to calculate directly from the run-length encoding of the
binary representation A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically "0" (zero) and "1" (one). The base-2 numeral system is a positional notation ...
of : the number of consecutive 1s starting from the least significant bit, then the number of consecutive 0s starting from the first block of 1s, and so on. The sequence of numbers generated in this way gives the
continued fraction In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer ...
representation of .Example: :i = 1081 = 100001110012: The continued fraction is ;2,3,4,1hence . :i = 1990 = 111110001102: The continued fraction is ;1,2,3,5hence . In the other direction, using the continued fraction of any as the run-length encoding of a binary number gives back itself. Example: :: The
continued fraction In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer ...
is ;1,3hence = 11102 = 14. :: The
continued fraction In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer ...
is ;3 But to use this method, the length of the continued fraction must be an odd number. So ;3should be replaced by the equivalent continued fraction ;2,1 Hence = 10012 = 9. A similar conversion between run-length-encoded binary numbers and continued fractions can also be used to evaluate
Minkowski's question mark function In mathematics, the Minkowski question-mark function, denoted , is a function with unusual fractal properties, defined by Hermann Minkowski in 1904. It maps quadratic irrational numbers to rational numbers on the unit interval, via an expressio ...
; however, in the Calkin–Wilf tree the binary numbers are integers (positions in the breadth-first traversal) while in the question mark function they are real numbers between 0 and 1.


Stern's diatomic sequence

Stern's diatomic sequence is the
integer sequence In mathematics, an integer sequence is a sequence (i.e., an ordered list) of integers. An integer sequence may be specified ''explicitly'' by giving a formula for its ''n''th term, or ''implicitly'' by giving a relationship between its terms. For ...
:0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, … . Using
zero-based numbering Zero-based numbering is a way of numbering in which the initial element of a sequence is assigned the index 0, rather than the index 1 as is typical in everyday ''non-mathematical'' or ''non-programming'' circumstances. Under zero-base ...
, the th value in the sequence is the value of the fusc function, named according to the obfuscating appearance of the sequence of values and defined by the
recurrence relation In mathematics, a recurrence relation is an equation according to which the nth term of a sequence of numbers is equal to some combination of the previous terms. Often, only k previous terms of the sequence appear in the equation, for a parameter ...
s :\begin \operatorname(2n) &= \operatorname(n) \\ \operatorname(2n+1) &= \operatorname(n) + \operatorname(n+1), \end with the base cases and . The th rational number in a breadth-first traversal of the Calkin–Wilf tree is the number . Thus, the diatomic sequence forms both the sequence of numerators and the sequence of denominators of the numbers in the Calkin–Wilf sequence. The function is the number of odd binomial coefficients of the form , , and also counts the number of ways of writing as a sum of
powers of two A power of two is a number of the form where is an integer, that is, the result of exponentiation with number two as the base and integer  as the exponent. In a context where only integers are considered, is restricted to non-negative ...
in which each power occurs at most twice. This can be seen from the recurrence defining fusc: the expressions as a sum of powers of two for an even number either have no 1s in them (in which case they are formed by doubling each term in an expression for ) or two 1s (in which case the rest of the expression is formed by doubling each term in an expression for ), so the number of representations is the sum of the number of representations for and for , matching the recurrence. Similarly, each representation for an odd number is formed by doubling a representation for and adding 1, again matching the recurrence.The OEIS entry credits this fact to and to uncited work of Lind. However, Carlitz's paper describes a more restricted class of sums of powers of two, counted by instead of by . For instance, :6 = 4 + 2 = 4 + 1 + 1 = 2 + 2 + 1 + 1 has three representations as a sum of powers of two with at most two copies of each power, so .


Relation to Stern–Brocot tree

The Calkin–Wilf tree resembles the Stern–Brocot tree in that both are binary trees with each positive rational number appearing exactly once. Additionally, the top levels of the two trees appear very similar, and in both trees, the same numbers appear at the same levels. One tree can be obtained from the other by performing a bit-reversal permutation on the numbers at each level of the trees. Alternatively, the number at a given node of the Calkin–Wilf tree can be converted into the number at the same position in the Stern–Brocot tree, and vice versa, by a process involving the reversal of the
continued fraction In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer ...
representations of these numbers. However, in other ways, they have different properties: for instance, the Stern–Brocot tree is a
binary search tree In computer science, a binary search tree (BST), also called an ordered or sorted binary tree, is a rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left subtree and ...
: the left-to-right traversal order of the tree is the same as the numerical order of the numbers in it. This property is not true of the Calkin–Wilf tree.


Notes


References

* * * *. *. *
EWD 570: An exercise for Dr.R.M.Burstall
pp. 215–216, an
EWD 578: More about the function "fusc" (A sequel to EWD570)
pp. 230–232, reprints of notes originally written in 1976. * *. * *.


External links

* * * {{DEFAULTSORT:Calkin-Wilf tree Integer sequences Trees (data structures)