My goal in this post is to describe a surprising and beautiful method (the Stern-Brocot tree) for generating all positive reduced fractions. I’ll then discuss how properties of the tree yield a simple, direct proof of a famous result in Diophantine approximation due to Hurwitz. Finally, I’ll discuss how improvements to Hurwitz’s theorem led Markoff to define another tree with some mysterious (and partly conjectural) similarities to the Stern-Brocot tree.
The Stern-Brocot tree
We first describe what I’ll christen the “extended Stern-Brocot tree” . It’s an ordered binary tree whose root note is labeled by the triple
. Each node in the tree is labeled with an ordered triple of rational numbers (plus
), written in lowest terms, and each node has two children. If a node is labeled by the triple
, then its left child is labeled
and its right child is labeled
, where
denotes the mediant of
and
. For example, the two children of the root
are
and
. And the two children of
are
and
. Here is a depiction of all descendents of
in the extended Stern-Brocot tree:
To get the Stern-Brocot tree , we keep just the mediants (the middle entry) and throw away the first and last entry in each triple:

The Stern-Brocot tree T (from [2]). The branch consisting of 1/2 and its descendants corresponds to the previous picture.
The Stern-Brocot tree has a number of remarkable properties, the most notable of which is that every positive reduced fraction appears exactly once in the tree. Let’s see why this is the case…
Properties of the Stern-Brocot tree
We record the following properties of the Stern-Brocot and extended Stern-Brocot trees:
(a) Every triple occurring in
has
.
Proof: A simple calculation shows that the mediant of two distinct fractions and
is always strictly between
and
.
(b) For every triple occurring in
, we have
, where
.
Proof: This holds for the root node, and a simple calculation shows that if it holds for a given node then it also holds for both children; the result follows by induction.
(c) Every fraction appearing in is reduced.
Proof: If are reduced and
, then
and thus the GCD of
and
is 1. The result now follows from (b) by induction.
(d) Given , let
be the least common ancestor of
and
. Then
iff
is a descendent of (or equal to) the left child of
and
is a descendent of (or equal to) the right child of
.
Proof: Again, this is a straightforward induction.
(e) No fraction appears more than once in .
Proof: This follows immediately from (d).
(f) For every triple occurring in
,
has a smaller denominator than any other fraction between
and
.
Proof: Let be any fraction between
and
. Then
It follows that , and the right-hand side is the denominator of
. If equality holds, then
, which implies that
and
.
(g) Every reduced positive fraction appears in
.
Proof: (Sketch) Assume for simplicity that (the general case is similar). We claim that
appears at the latest in row
of
. Indeed, if
has not already appeared by row
, then there is a triple
in row
of
with
. By induction and the uniqueness part of (f), it follows that
.
Combining (c), (e), and (g), we find:
Theorem: Every reduced fraction appears exactly once in
Stern-Brocot expansions of real numbers
Every positive real number has a “Stern-Brocot expansion” consisting of a (possibly empty, possibly infinite) string of L’s and R’s determined by starting at the root and moving downwards through
. At each stage, we move to the node labeled by unique triple
with
, stopping if
, and we record whether we went left or right in order to reach
.
For example, the Stern-Brocot expansions of and
are
and
, respectively. In this way, every positive rational number corresponds to a unique finite string (with 1 corresponding to the empty string), and every positive irrational number corresponds to a unique infinite string. The inverse-golden ratio
corresponds to the infinite string
and a result of Euler implies that the irrational number
corresponds to the infinite string
(If you’re familiar with continued fractions, there is a simple dictionary between Stern-Brocot and continued fraction expansions: a finite Stern-Brocot expansion of the form or
with all
corresponds to the finite continued fraction
, and an infinite Stern-Brocot expansion of the form
corresponds to the infinite continued fraction
)
Diophantine approximation
Given a real number , the Stern-Brocot triples corresponding to
are the triples
appearing as vertices in the rooted path in
which we just described. The mediants of these triples are called the semiconvergents of
. For example, when
the corresponding Stern-Brocot triples are
, and
, and the semiconvergents are
.
For the inverse-golden ratio the semiconvergents are
(ratios of consecutive Fibonacci numbers). The last semiconvergent of a rational number
is equal to
, and if
is irrational then the semiconvergents converge to
.
(The name semiconvergent comes from the fact that every convergent of the corresponding continued fraction is a semiconvergent, but not necessarily vice-versa.)
The most important fact about semiconvergents is that they give the closest approximations to with a given denominator, i.e., a reduced fraction
is a semiconvergent of
iff
is closer to
than any other fraction of the form
with
.
This leads us into the theory of Diophantine approximation, which is precisely concerned with such approximations by rational numbers. The cornerstone of this theory is Dirichlet’s Approximation Theorem, which is the following assertion:
Theorem (Dirichlet): If
is a positive irrational number, there are infinitely many reduced fractions
with
Remarks:
- The “trivial” bound in Dirichlet’s theorem would be
, since for every positive integer
there is a rational number
with
(and this holds whether or not
is irrational).
- The converse of Dirichlet’s theorem is true as well: if
is rational then there are only finitely many reduced fractions
with
So Dirichlet’s theorem allows us to distinguish rational numbers from irrational ones in a rather interesting and non-trivial way.
- The exponent of 2 in Dirichlet’s theorem cannot be improved, since by a famous theorem of Klaus Roth (for which he won the Fields Medal), if
is an algebraic number then for each
and every constant
, there are only finitely many reduced fractions
with
- The constant term in Dirichlet’s theorem can, however, be improved. This is the subject of Hurwitz’s theorem, to which we turn in the next section.
- Dirichlet’s Approximation Theorem has a number of applications, e.g. it can be used to prove that Pell’s equation
has infinitely many integer solutions for every non-square positive integer
. And the Stern-Brocot tree (or, equivalently, the theory of continued fractions) can be used to explicitly find all solutions.
Hurwitz’s theorem
As a motivation for Hurwitz’s theorem, we note that if is the inverse-golden ratio, a simple calculation shows that for any
there are only finitely many reduced fractions
with
Indeed, let denote the other root of the quadratic polynomial
satisfied by
. Then since
has no rational roots, for any rational number
we have
. Writing
, we see that if
then
After a bit of algebra, we see that this implies
, which (since
) cannot hold when
is large.
Adolf Hurwitz proved that , and the corresponding constant of
, is the “worst-case scenario” in Dirichlet’s theorem:
Theorem (Hurwitz): If is a positive irrational number, there are infinitely many reduced fractions
with
Proof of Hurwitz’s theorem
As a warm-up, we use the Stern-Brocot tree to give a quick proof of Dirichlet’s theorem. Indeed, we claim that in any Stern-Brocot triple corresponding to
, either
or
must satisfy the conclusion of Dirichlet’s Approximation Theorem. The proof of property (g) above shows that each rational number can appear in only finitely many Stern-Brocot triples, so we’re done once we establish the claim. And the claim is easy to prove: if
and
, then
since
and the denominator of
is at least as large as the denominator of
. Similarly, if
then
satisfies the conclusion of Dirichlet’s theorem.
To prove Hurwitz’s theorem, we refine the above observation by proving that in any Stern-Brocot triple corresponding to
, either
,
, or
must satisfy the conclusion of Hurwitz’s Theorem. It suffices to prove this in the case
, since if
we may replace
by
,
by
, and
by
.
Assuming, therefore, that , if the conclusion of Hurwitz’s theorem fails for each of
then (setting
):
(1)
(2)
(3)
Adding (1) and (3) and simplifying using property (b) gives Similarly, adding (2) and (3) gives
Adding these two inequalities gives Using the fact that
and simplifying, this is equivalent to
where
is the golden mean. But then
, which is impossible since the
is irrational.
Beyond Hurwitz
Hurwitz in fact proved more than just the above. He also showed that one could improve on the above theorem for irrational numbers which are not -equivalent to
(e.g.
). More precisely, if
are real numbers, we write
if there exist integers
with
such that
If we replace
with any real number
, it is still true that for any
there are only finitely many reduced fractions
with
However, Hurwitz showed that if
, then one can do better, with an optimal constant of
instead of
. This prompts the following definition:
If
is a positive irrational number, its Lagrange number
is the supremum of all
such that there are infinitely many reduced fractions
with
It’s not difficult to show that -equivalent irrationals have the same Lagrange number.
The Lagrange spectrum is the set of all numbers of the form for
a positive irrational number. By what we’ve already said, we know that
and
belong to the Lagrange spectrum.
Markoff and his equation
Andrei Markoff (also spelled Markov – he’s the same mathematician for whom Markov chains are named) discovered a remarkable connection between the Lagrange spectrum and integer solutions to the Diophantine equation
now known as the Markoff equation.
In order to state Markoff’s result, we define a Markoff number to be a positive integer such that
for some integers
, i.e., such that
is a solution to the Markoff equation. The sequence of Markoff numbers begins
Theorem (Markoff):
1. The Lagrange spectrum is discrete in the interval
. On the other hand, 3 is a limit point of the Lagrange spectrum.
2. More precisely, the Lagrange spectrum below 3 is precisely the set of real numbers
where
is a Markoff number.
As one of the steps toward proving this theorem, Markoff established the remarkable fact that all integer solutions to his equation can be described by an algorithmic procedure similar to the one which we used to define the (extended) Stern-Brocot tree!
The extended Markoff tree
The observation which gets everything going is that if is a solution to the Markoff equation with
, then
and
are also solutions (in the same numerical order). We’ll call
and
the degenerate Markoff triples, and all other solutions
with
non-degenerate Markoff triples. The smallest non-degenerate Markoff triple is
.
The extended Markoff tree is a rooted tree in which each node is labeled with a Markoff triple, with the root node labeled
. The unique child of
is
, and the unique child of
is
. The subtree consisting of the node labeled with the non-degenerate Markoff triple
and all its descendants is an ordered binary tree: if a node is labeled by the non-degenerate Markoff triple
, its left child is labeled
and its right child is labeled
:
Theorem (Markoff): Every integer solution
to the Markoff equation with
appears precisely once in the extended Markoff tree.
The Markoff tree and the uniqueness conjecture
We obtain the Markoff tree M from the extended Markoff tree in the same way that we obtained the Stern-Brocot tree from its extended version: by forgetting
and
and just keeping the middle element
of each Markoff triple. The Markoff numbers are (by the symmetry of the Markoff equation) precisely those numbers which appear somewhere in the Markoff tree.
The major unsolved problem in the subject is:
Conjecture (Markoff’s Uniqueness Conjecture, Version 1): Every Markoff number appears exactly once in the Markoff tree.
The interest in this conjecture stems partly from its apparent degree of difficulty and partly from its interesting implications. For example, the uniqueness conjecture is equivalent to the following statement which does not mention Markoff’s equation at all but relates directly to the Lagrange spectrum:
Conjecture (Markoff’s Uniqueness Conjecture, Version 2): If
are irrational numbers with
, then
.
For an extensive history and mathematical discussion of the Markoff uniqueness conjecture (in these and other forms), see the lovely book [2].
Concluding remarks:
- The basic properties of the Stern-Brocot tree yield a constructive proof (which does not make explicit use of the extended Euclidean algorithm) that if
are relatively prime positive integers then there are positive integers
such that
. (Take
to be the triple corresponding to the rational number
and let
.)
- Achille Brocot was a French clockmaker who used the Stern–Brocot tree to design systems of gears with a gear ratio close to a particular desired value.
- Another characterization of equivalence is that
are
-equivalent if and only if their continued fraction expansions coincide from some point onward (i.e., they have the same “tail”); see [2] for additional information.
- There is a real number
, called Freiman’s constant, such that every real number greater than
belongs to the Lagrange spectrum but for every
there is a real number in
which does not belong to the Lagrange spectrum. Explicitly (as you would no doubt guess),
In the interval
the Lagrange spectrum is complicated (a fractal-like blend of discrete and continuous parts).
- The Stern-Brocot tree is closely related to Farey sequences, which are in turn closely related to Ford circles. Ford circles allow for an appealing geometric visualization of the Stern-Brocot tree:

Ford circles (https://pqrtheory.wordpress.com/2010/07/)
References:
[1] M. Aigner, Markov’s Theorem and 100 Years of the Uniqueness Conjecture, Springer-Verlag, 2013.
[2] R. Graham, D.E. Knuth, and O. Patashnik, Concrete Mathematics (2nd edition), Addison-Wesley, 1994.
[3] J.D. Sally and P.J. Sally, Jr., Roots to Research, American Mathematical Society, 2007.