©2022 Compass Learning Technologies ← GXWeb Farey Numbers, Fraction Trees and Kissing Circles → Climbing Around Fraction Trees
Climbing Around Fraction Trees
and Unpacking the Stern-Brocot Continued Fraction
Saltire Software, home of Geometry Expressions and GXWeb
Symbolic computations on this page use Nerdamer Symbolic JavaScript to complement the in-built CAS of GXWeb
With thanks to the late Dr Keith Tognetti for pointing me in the direction of continued fractions many years ago and igniting in me a life-long passion, and to Dr Bruce Bates (both of the University of Wollongong) for revealing to us all the beautiful Stern-Brocot Continued Fraction. With colleague Dr Martin Bunder they have brought to light many wonderful and often surprising connections between binary trees and continued fractions.
Did You Know that Fractions Grow on Trees?
Or that (Fraction) Trees Can Grow from (Continued) Fractions?
![]()
Suppose you wanted to make a list of all the rationals... How might you start?
One approach might be to begin with the denominators of the fractions: first, list those with denominator 1 - zero and 1: \(\frac{0}{1}, \frac{1}{1} \).
Next, add those with denominator 2: \(\frac{0}{1}, \frac{1}{2}, \frac{1}{1} \).
Add those with denominator 3 ( \(\frac{0}{1}, \frac{1}{3}, \frac{1}{2}, \frac{2}{3}, \frac{1}{1} \)) and you are on your way to the Farey Sequence! This last would be referred to as the Farey Sequence of Order 3.
![]()
Ford Circles offer a beautiful way to help us to better visualise these special numbers. Imagine each term of a Farey Sequence is plotted on a number line. Then draw a circle on each point with a particular radius(!?) which allows it to just touch (to kiss!) any adjacent circle.
There are, of course, other ways to approach the problem of listing (enumerating) the rationals.
A second approach may be found in the form of Fraction Trees - Farey Trees, Stern-Brocot and Calkin-Wilf Trees offer amazing insights into the nature and structure of rational numbers, and their relationship with continued fractions. (Did you know that these fraction trees provide simple ways, not only to list all the rationals, but to express them in continued fraction form?)
In particular, we will discover a special continued fraction which generates all the rational numbers in the Farey Tree, and from these to the Stern-Brocot and Calkin-Wilf Trees!
Can you see how the fractions at each level are calculated from their parents?
How do the paths to each term lead to continued fractions?
How can you tell which level of the Stern-Brocot or Calkin-Wilf trees to look in to find a particular rational number?
Investigate the amazing Stern-Brocot continued fraction. Explore further using the buttons and sliders below - then try the quiz to predict the next level.
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
LEVEL 0 3 6 ROW 0 5 32 \[0+\cfrac{1}{3 - \cfrac{1}{1 - \cfrac{1}{3 - \cfrac{1}{1}}}}\] The Farey (Stern-Brocot Left Branch)
Continued Fraction of order 3: \[[0,3,1,3,1]_{sb}\]
App generated by GXWeb
The Stern-Brocot Continued Fraction form for
\[[0,3,1,3,1,5,1,3,1]_{sb}\]\[[0,3,-1,3,-1,5,-1,3,-1]\]=> \[0+\cfrac{1}{3-\cfrac{1}{1-\cfrac{1}{3-\cfrac{1}{1-\cfrac{1}{5-\cfrac{1}{1-\cfrac{1}{3-\cfrac{1}{1}}}}}}}}\]=> \[[\frac{0}{1},\frac{1}{3},\frac{1}{2},\frac{2}{3},\frac{1}{1},\frac{3}{2},\frac{2}{1},\frac{3}{1},\frac{1}{0}]\]Calkin-Wilf Equivalent
=>
\[[\frac{0}{1},\frac{1}{3},\frac{1}{2},\frac{3}{2},\frac{1}{1},\frac{2}{3},\frac{2}{1},\frac{3}{1},\frac{1}{0}]\]
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Mathematical ToolBox
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
About the MathBoxes...
Hint: When entering mathematical expressions in the math boxes below (f(x), g(x) and h(x)), use the space key to step out of fractions, powers, etc. On Android, begin entry by pressing Enter.
Type simple mathematical expressions and equations as you would normally enter these: for example, "x^2[space]-4x+3", and "2/3[space]". For more interesting elements, use Latex notation (prefix commands such as "sqrt" and "nthroot3" with a backslash ()): for example: "sqrt(2)[space][space]". Learn More?
Building the Fraction Trees
About the Stern-Brocot Continued Fraction
The Farey Tree (a subset of the Stern-Brocot Tree) begins with the endpoints of 0 and 1 and uses the mediant to find a fraction between each. As with the Farey sequence, this simply involves forming a fraction by adding the two numerators and the two denominators.
The Stern-Brocot Tree begins with the endpoints of 0 (\(\frac{0}{1}\)) and infinity (\(\infty = \frac{1}{0}\)) and uses the mediant to add to the Farey Tree and list all the rationals!
So \(\frac{0}{1}\) and \(\frac{1}{1}\) give \(\frac{0+1}{1+1} = \frac{1}{2}\)
Then \(\frac{0}{1}\) and \(\frac{1}{2}\) give \(\frac{0+1}{1+2} = \frac{1}{3}\) and \(\frac{1}{1}\) and \(\frac{1}{2}\) give \(\frac{1+1}{1+2} = \frac{2}{3}\)
Each subsequent row of fractions is built by continuing this process, stepping either to the left (L) or right (R), beginning from 1. Each \(n\)-th row begins with \(\frac{1}{n}\) and ends with \(\frac{n-1}{n}\).
\[\frac{0}{1}\] \[\frac{1}{0}\]
\[\frac{1}{1}\]\[\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\]
\[L\]\[\begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}\]\[\frac{1+0}{1+1}\]\[\frac{1}{2}\] \[R\]\[\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}\]\[\frac{1+1}{0+1}\]\[\frac{2}{1}\]
\[LL\]\[\begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}\]\[\begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}\]\[\frac{1+0}{2+1}\]\[\frac{1}{3}\] \[LR\]\[\begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}\]\[\begin{bmatrix} 1 & 1 \\ 1 & 2 \end{bmatrix}\]\[\frac{1+1}{1+2}\]\[\frac{2}{3}\] \[RL\]\[\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}\]\[\begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}\]\[\frac{2+1}{1+1}\]\[\frac{3}{2}\] \[RR\]\[\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}\]\[\begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}\]\[\frac{1+2}{0+1}\]\[\frac{3}{1}\] From \(\frac{1}{1}\), to get to \(\frac{1}{2}\), move down to the Left (L or 0). To form the continued fraction(s), simply add another 0 or 1 (it does not matter which because both deliver correct but slightly different results). So for \(\frac{1}{2}\), we could add 0 or 1. Begin your continued fraction with zero (or L since all our LEFT (Farey) fractions lie between 0 and 1) and then count each repeated element. Then adding 0 will give the continued fraction \([0, 2]=0+\cfrac{1}{2}\) and adding 1 gives \([0, 1, 1] = 0 + \cfrac{1}{1+\cfrac{1}{1}}\).
In the same way, to get to \(\frac{1}{3}\) from \(\frac{1}{1}\), step LL (or 00). Add another 0 to get (\([0,3]\)) or 1 for (\([0,2,1]\)). For \(\frac{2}{3}\) from \(\frac{1}{1}\), step LR (or 01). Add another 1 to get (\([0,1,1,1]\)) or 0 to get (\([0,1,2]\)).
As shown above, the Farey Tree makes up the left branch of the Stern-Brocot Tree. Each fraction beginning with a RIGHT step will be greater than 1, and complete this amazing tree.
For the right branch of the Stern-Brocot Tree (rationals greater than 1), to get to \(\frac{4}{1}\) from \(\frac{1}{1}\), step RR (or 11). Add another 1 to get (\([3]\)) or 0 for (\([2,1]\)). For \(\frac{8}{5}\) from \(\frac{1}{1}\), step RLRL (or 1010). Add another 1 to get (\([1,1,1,1,1]\)) or 0 to get (\([1,1,1,2]\)).
Observe that any continued fraction ending in 1 can be compacted by adding that trailing one to the previous term.
Try some of your own?
Step by step?
Explore the Calkin-Wilf Tree
The Calkin-Wilf tree (or Tree of All Fractions) is another binary tree which is obtained by starting with the fraction 0/1 and (this time!) adding \(\frac{a}{a+b}\) and \(\frac{a+b}{b}\) iteratively below each fraction \(\frac{a}{b}\).
![]()
The Calkin-Wilf Tree was only developed in the year 2000 by Neil Calkin and Herb Wilf (demonstrating that there is still much beautiful and useful mathematics to be discovered), and is also similar to the binary tree of Johannes Kepler (1619) (The image ⇒ shows the Calkin-Wilf rule on the left and Kepler's on the right).
This tree (like the Stern-Brocot tree) generates every rational number. Writing out the terms in a sequence gives
\(\frac{1}{1}, \frac{1}{2}, \frac{2}{1}, \frac{1}{3}, \frac{3}{2}, \frac{2}{3}, \frac{3}{1}, \frac{1}{4}, \frac{4}{3}, \frac{3}{5}, \frac{5}{2}, \frac{2}{5}, \frac{5}{3}, \frac{3}{4}, \frac{4}{1}\)...
The sequence has the property that each denominator is the next numerator. That means that the nth rational number in the list looks like \(\frac{b(n)}{b(n + 1)}\) (n = 0, 1, 2, . . .), where
{b(n)}n≥0 = {1,1,2,1,3,2,3,1,4,3,5,2,5,3,4,1,5,4,7,...}.
This is a bit remarkable - at very least, for its efficiency. This single list can be viewed in (at least) three ways:
As the list of numerators of the Calkin-Wilf Tree,
As the list of denominators of the Calkin-Wilf Tree (after removing the first term) OR
As the actual list of fractions of the Calkin-Wilf Tree by taking each term with its next term!
Differing from the Stern-Brocot tree above, the rationals between 0 and 1 are paired (interleaved) with their reciprocal complements.
Perhaps even simpler than Stern-Brocot, any term of the Calkin-Wilf tree can directly reveal its continued fraction through the binary form of the term number!
Consider the 19th term of the Calkin-Wilf tree: 19 = 10011 (binary) - RLLRR (counting from zero).
For Calkin-Wilf, count repeated terms FROM THE RIGHT to get the continued fraction.
If the binary ends in zero (i.e. if the term is even) then add a zero as the first term - even term values always lie between 0 and 1!
Calkin-Wilf: term 19
=> [2,2,1]
=> \(\frac{7}{3}\)
Explore the binary trees yourself!
Ferreira, J and Mendes, A (2016) A calculational approach to path-based properties of the Eisenstein-Stern and Stern-Brocot trees via matrix algebra
Ben Gobler: Listing the Rationals Using Continued Fractions (YouTube)
Gobler, Ben (2022) The Calkin-Wilf Tree: Extensions and Applications
Breaking Open the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
The Stern-Brocot Tree has its own continued fraction! (With thanks to Dr Bruce Bates from the University of Wollongong)
Note that this is not the usual simple continued fraction with all numerators equal to 1. This is a general continued fraction - all but the leading numerator equal -1. For convenience, we will use the continued fraction list form below \[[0,3,1,3,1]_{sb}\] but a stricter form might be [(0,1),(3,-1),(1,-1),(3,-1),(1,-1)].
Alternatively, it appears that the Stern-Brocot continued fraction CAN be expressed as a simple continued fraction by setting each 1 term to -1. Hence, the extended form for order 3 (including both left and right branches) could be expressed as \[[0,3,-1,3,-1,5,-1,3,-1]\]
\[0+\cfrac{1}{3+\cfrac{1}{-1+\cfrac{1}{3+\cfrac{1}{-1+\cfrac{1}{5+\cfrac{1}{-1+\cfrac{1}{3+\cfrac{1}{-1}}}}}}}}\]
\[[0,3,1,3,1]_{sb}\] The Stern-Brocot Continued Fraction of order 3 (Left Branch) is
(The Right Branch Stern-Brocot Continued Fraction of order 3 is \([3,1,3,1]_{sb}\))
\[0+\cfrac{1}{3-\cfrac{1}{1-\cfrac{1}{3-\cfrac{1}{1}}}}\] Each convergent of the Stern-Brocot continued fraction gives a term in the Farey Sequence of order 3:
\[\frac{0}{1}, \frac{1}{3}, \frac{1}{2}, \frac{2}{3}, \frac{1}{1}\]Adding the terms from the right-branch Stern-Brocot continued fraction (above) OR just some reciprocal mirroring of the terms, we then get the full Stern-Brocot sequence of order 3:
\[\frac{0}{1}, \frac{1}{3}, \frac{1}{2}, \frac{2}{3}, \frac{1}{1}, \frac{3}{2}, \frac{2}{1}, \frac{3}{1}\]Can you see how this may be expressed as a product of matrices?
\[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix}\] \[= \frac{1}{1}\]⇒ \[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 3 & -1 \\ \end{bmatrix} => \frac{0}{-1}, \frac{1}{3}\] \[\begin{bmatrix} 1 & 0 \\ 3 & -1 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & -1 \\ 2 & -3 \\ \end{bmatrix} => \frac{1}{2}\] \[\begin{bmatrix} 1 & -1 \\ 2 & -3 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 2 & -1 \\ 3 & -2 \\ \end{bmatrix} => \frac{2}{3}\] \[\begin{bmatrix} 2 & -1 \\ 3 & -2 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & -2 \\ 1 & -3 \\ \end{bmatrix} => \frac{1}{1}\]
Order (0) n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15... 2 (0) 2 1 3 (0) 3 1 3 1 4 (0) 4 1 3 1 5 1 3 1 5 (0) 5 1 3 1 5 1 3 1 7 1 3 1 5 1 3 1 Can you see a pattern?
Not an easy one at all...
Hint: The tree(s) we are building are binary. Each row increases by a multiple of two as each term on one row is the parent of two children.
Look again at our continued fraction arrays. The first two terms are easy: the leading zero of a continued fraction ensures that the value lies between 0 and 1. The second term is the order number.
Now study the remaining terms in the n-th sequence: all odd-numbered terms are given the value 1 (or -1 if using the simple continued fraction form!).
So what about the even numbers? 2 → 3 (\(2\cdot 1+1\))? 4 → 5 (\(2\cdot 2+1\))? But for 6, \(2\cdot 3+1\) does not equal 5, and for 8, \(2\cdot 4+1\) does not equal 7 as required.
The secret here lies in counting the number of 2s in the prime factorisation of each number!
Let b be the number of times 2 occurs as a factor of each number:
- \(2=2\cdot 1\) so b = 1 and \(2\cdot b + 1 = 3\).
- \(4=2\cdot 2\cdot 1\) so b = 2 and \(2\cdot b + 1 = 5\).
- \(6=2\cdot 3\) so b = 1 and \(2\cdot b +1 = 3\).
- \(8=2\cdot 2\cdot 2\cdot 1\) so b = 3 and \(2\cdot b +1 = 7\).
Order (0) n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15... n → b (0) n
↓
b20
↓
021
↓
120\(\cdot\)3
↓
022
↓
220\(\cdot\)5
↓
021\(\cdot\)3
↓
120\(\cdot\)7
↓
023
↓
320\(\cdot\)9
↓
021\(\cdot\)5
↓
120\(\cdot\)11
↓
022\(\cdot\)3
↓
120\(\cdot\)13
↓
021\(\cdot\)7
↓
120\(\cdot\)15
↓
0\(2\cdot b+1\) (0) n 1 3 1 5 1 3 1 7 1 3 1 5 1 3 1
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Navigating the Fraction Trees
About the Stern-Brocot Continued Fraction
References:
Bruce Bates (2014): The Stern-Brocot Continued Fraction
Bates, B., Bunder, M. and Tognetti, K. (2010): Locating Terms in the Stern-Brocot Tree
Bates, B., Bunder, M. and Tognetti, K. (2010): Linking the Calkin-Wilf and Stern-Brocot trees
Suppose I wish to know which fraction occurs in the 17th position of the Farey, Stern-Brocot or Calkin-Wilf trees.
Or I would like to know where exactly to find \(\frac{5}{8}\) in the Stern-Brocot or Calkin-Wilf trees.
If I know the j-th vertex in level k in the Stern-Brocot tree, how can I find the corresponding vertex in the Calkin-Wilf tree? And vice-versa?
Finally, could there be a Calkin-Wilf Continued Fraction?
About the Stern-Brocot Continued Fraction
Challenge 1
One approach to the first question involves expressing the path to each node in binary form, and converting this to a continued fraction. This has been dealt with in detail elsewhere: Follow a Binary Path to Continued Fractions.
A key focus of our current exploration is the Stern-Brocot Continued Fraction, which offers a lovely way to identify the position of any term: convert the fraction to continued fraction form and add the terms to find the Stern-Brocot or Calkin-Wilf order. Then use the convergent corresponding to your value to locate its position in the Stern-Brocot tree.
The Stern-Brocot Continued Fraction gives each of the terms of the Farey Tree, which serve as the left branch of the Stern-Brocot AND the even-numbered terms of Calkin-Wilf. While they can readily also give the Stern-Brocot right branch through reciprocal mirroring, filling in the remainder of the Calkin-Wilf Tree is a little more challenging!
Both these methods assume an ordering of the Farey and Stern-Brocot trees from right to left, counting from the top, as shown - AND an odd-numbered continued fraction!
Quite a different approach to navigating the trees comes with the use of normalised additive factorisation instead of the binary representation used above.
Any integer can be represented using an (odd-numbered) series of powers of 2, with alternating sums and differences. For example, the normalised additive factored form of 6 is [3,2,1] => 6 = \(2^3-2^2+2^1\) => (6 = 8-4+2)
Normalised additive factors can be used to find the value and position of any term in both Stern-Brocot and the Calkin-Wilf trees. These use a left-to-right ordering system for the vertices of the trees AND an odd-numbered continued fraction.
To build the continued fraction for term 3 (=> {2,1,0}) of level 3 of the Calkin-Wilf tree, for example, begin with the last term of the normalised additive factor list: [0].
From right to left, find the difference between each of the additive factors, and finally the difference between the level number (3) and the first term of the additive factors list (2) => 3 - 2 = 1
The continued fraction for term 3 of level 3 of the Calkin-Wilf tree is \([0,1,1,1] = \frac{2}{3}\). This is also term 6 of the full tree, since there are 3 terms preceding level 3.
About the Stern-Brocot Continued Fraction
Challenge 2
For Stern-Brocot, the process is similar but reversed (with an odd number of terms for Stern-Brocot and an even number of terms for Calkin-Wilf). First, though, we distinguish between fractions less than 1 as opposed to those greater than or equal to 1.
For Stern-Brocot:
Step 1. If the number is less than 1, discard the leading 0 and next term. (If greater than 1, just start with all the terms of the continued fraction.)
Step 2. Add remaining terms and subtract 1 for the first element of your NAF.
Step 3. Remove the current leading term and return to step 2.
Example 2.1: \(\frac{3}{5}\) => [0,1,1,1,1] lies in level 4 of the Stern-Brocot and Calkin-Wilf trees (since the sum of the terms add up to 4!)
This number is less than zero, so discard the first two terms, leaving just (1,1,1). Add these and subtract 1 to get 2, the first term of our normalised additive factor.
Discard the first term to get (1,1). Add and subtract 1 => 1. Our NAF is now {2,1}.
One more round to get 1-1 = 0, and our normalised additive factors for \(\frac{3}{5}\) => {2, 1, 0} = \(2^2 - 2^1 + 2^0 = 4 - 2 +1 = 3\).
Hence (rac{3}{5}) is term 3 of level 4 of the Stern-Brocot Tree.
Example 2.2: \(\frac{10}{7}\) => [1, 2, 3] lies in level 6 of the Stern-Brocot and Calkin-Wilf trees (since the sum of the terms add up to 6!)
This number is greater than zero, so add all terms (1 + 2 + 3). Add these and subtract 1 to get 5, the first term of our normalised additive factor.
Discard the first term to get (2 + 3). Add and subtract 1 => 4. Our NAF is now {5, 4}.
Once more to get 3 - 1 = 2, and our normalised additive factors for \(\frac{10}{7}\) => {5, 4, 2}.
The normalised additive factor form of \(\frac{10}{7}\) = [1,2,3] is {5,4,2} => \(2^5-2^4+2^2\)= 32 - 16 + 4.
\(\frac{10}{7}\) is term 20 of the complete Stern-Brocot Tree level 6
About the Stern-Brocot Continued Fraction
Challenge 3
Next, we deal with our third question: how do I map vertices between Stern-brocot and Calkin-Wilf trees? The answer is surprisingly simple!
To convert the jth entry in the kth level of the Stern-Brocot tree into the jth vertex in the kth level of the Calkin-Wilf tree (and back the other way!):
Take its reciprocal.
Express this reciprocal as a continued fraction possessing an even number of terms. (This will be either the long or short form), then
Rewrite this continued fraction backwards, then
Subtract 1 from the first term and add 1 to the last term.
And this method works in both directions!
Example 3.1: The 7th entry in the 4th level of the Stern-Brocot tree is \(\frac{5}{2} = [2,2]\). What is the 7th vertex in the 4th level of the Calkin-Wilf tree?
\(\frac{2}{5} = [0,2,2]\)
⇒ \( [0,2,1,1]\)
⇒ \( [1,2,1,0]\)
⇒ \( [0,1,2,1] = \frac{3}{4}\)
Example 3.2: The 7th entry in the 4th level of the Calkin-Wilf tree is \(\frac{3}{4} = [0,1,2,1]\). What is the 7th vertex in the 4th level of the Stern-Brocot tree?
\(\frac{4}{3} = [1,3]\)
⇒ \( [3,1]\)
⇒ \( [2,2] = \frac{5}{2}\)
About the Stern-Brocot Continued Fraction
Challenge 4
Thanks to the work of Dr Bruce Bates, the Stern-Brocot Continued Fraction is well defined, and offers an invaluable tool for generating the terms of Farey, Stern-Brocot and, with a little tweaking, Calkin-Wilf trees.
So it is intriguing to wonder if such a tool exists for the Calkin-Wilf Tree directly.
At this stage, all that can be offered is brute force computation - it remains to be established whether a generating function can be found for this problem.
About the Stern-Brocot Continued Fraction
Level 2 for both Stern-Brocot and Calkin-Wilf are identical, with convergents as shown:
Convergents:
\[[\frac{0}{1}, \frac{1}{2}, \frac{1}{1}, \frac{2}{1}]\]The continued fraction is given by
\[0 + \cfrac{1}{2 - \cfrac{1}{1 - \cfrac{1}{3}}}\]Denominator array: [0,2,1,3]
Numerator array: [1,-1,-1,1]
\[0 = \frac{0}{1}\] \[0 + \frac{1}{2} = \frac{1}{2}\] \[0 + \cfrac{1}{2 - \cfrac{1}{1 - \cfrac{1}{3}}} = \frac{2}{1}\] \[0 + \cfrac{1}{2 - \cfrac{1}{1 - \cfrac{1}{3}}} = \frac{2}{1}\] Can you see how this may be expressed as a product of matrices?
\[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 2 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & 1 \\ 1 & 0 \\ \end{bmatrix}\] \[= \frac{2}{1}\]⇒ \[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 2 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 2 & -1 \\ \end{bmatrix} => \frac{0}{-1}, \frac{1}{2}\] \[\begin{bmatrix} 1 & 0 \\ 2 & -1 \\ \end{bmatrix} \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & -1 \\ 1 & -2 \\ \end{bmatrix} => \frac{1}{1}\] \[\begin{bmatrix} 1 & -1 \\ 1 & -2 \\ \end{bmatrix} \begin{bmatrix} 3 & 1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 1 & 1 \\ \end{bmatrix} => \frac{2}{1}\]About the Stern-Brocot Continued Fraction
\[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 7 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 5 & -4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 7 & 1 \\ 1 & 0 \\ \end{bmatrix} \] \[= \frac{3}{1}\]
Level 3 for Stern-Brocot and Calkin-Wilf are similar, with Calkin-Wilf convergents displayed opposite:
Convergents:
\[[\frac{0}{1}, \frac{1}{3}, \frac{1}{2}, \frac{3}{2},\] \[\frac{1}{1}, \frac{2}{3}, \frac{2}{1}, \frac{3}{1}]\]The level 3 Calkin-Wilf continued fraction is given by
\[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{7 + \cfrac{1}{1 - \cfrac{4}{5 - \cfrac{4}{1 + \cfrac{1}{7}}}}}}}\]Denominator array: [0,3,1,7,1,5,1,7]
Numerator array: [1,-1,-4,1,-4,-4,1,1]
\[0 = \frac{0}{1}\] \[0 + \frac{1}{3} = \frac{1}{3}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1}} = \frac{1}{2}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{ 7}}} = \frac{3}{2}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{7+ \cfrac{1}{1}}}} = \frac{1}{1}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{7+ \cfrac{1}{1 - \cfrac{4}{5}}}}} = \frac{2}{3}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{7+ \cfrac{1}{1 - \cfrac{4}{5 - \cfrac{4}{1}}}}}} = \frac{2}{1}\] \[0 + \cfrac{1}{3 - \cfrac{1}{1 - \cfrac{4}{7+ \cfrac{1}{1 - \cfrac{4}{5 - \cfrac{4}{1 + \cfrac{1}{7}}}}}}} = \frac{3}{1}\]⇒ \[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 3 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 3 & -1 \\ \end{bmatrix} => \frac{0}{-1}, \frac{1}{3}\] \[\begin{bmatrix} 1 & 0 \\ 3 & -1 \\ \end{bmatrix} \begin{bmatrix} 1 & -4 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & -4 \\ 2 & -12 \\ \end{bmatrix} => \frac{1}{2}\] \[\begin{bmatrix} 1 & -4 \\ 2 & -12 \\ \end{bmatrix} \begin{bmatrix} 7 & 1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 3 & 1 \\ 2 & 2 \\ \end{bmatrix} => \frac{3}{2}\] \[\begin{bmatrix} 3 & 1 \\ 2 & 2 \\ \end{bmatrix} \begin{bmatrix} 1 & -4 \\ 1 & 0 \\ \end{bmatrix} = 4 \cdot \begin{bmatrix} 1 & -3 \\ 1 & -2 \\ \end{bmatrix} => \frac{1}{1}\] \[4 \cdot \begin{bmatrix} 1 & -3 \\ 1 & -2 \\ \end{bmatrix} \begin{bmatrix} 5 & -4 \\ 1 & 0 \\ \end{bmatrix} = 4 \cdot \begin{bmatrix} 2 & -4 \\ 3 & -4 \\ \end{bmatrix} => \frac{2}{3}\] \[4 \cdot \begin{bmatrix} 2 & -4 \\ 3 & -4 \\ \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix} = -4 \cdot \begin{bmatrix} 2 & -2 \\ 1 & -3 \\ \end{bmatrix} => \frac{2}{1}\] \[-4 \cdot \begin{bmatrix} 2 & -2 \\ 1 & -3 \\ \end{bmatrix} \begin{bmatrix} 7 & 1 \\ 1 & 0 \\ \end{bmatrix} = -4 \cdot \begin{bmatrix} 12 & 2 \\ 4 & 1 \\ \end{bmatrix} => \frac{3}{1}\]About the Stern-Brocot Continued Fraction
Level 4 Calkin-Wilf convergents:
\[0 = \frac{0}{1}\] \[0 + \frac{1}{4} = \frac{1}{4}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1}} = \frac{1}{3}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13}}} = \frac{4}{3}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1}}}} = \frac{1}{2}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11}}}}} = \frac{3}{5}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4}}}}}} = \frac{3}{2}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19}}}}}}} = \frac{5}{2}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1}}}}}}}} = \frac{1}{1}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7}}}}}}}}} = \frac{2}{5}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1}}}}}}}}}} = \frac{2}{3}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19}}}}}}}}}}} = \frac{5}{3}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19 - \cfrac{1}{1}}}}}}}}}}}} = \frac{2}{1}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19 - \cfrac{1}{1 - \cfrac{45}{44}}}}}}}}}}}}} = \frac{3}{4}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19 - \cfrac{1}{1 - \cfrac{45}{44 - \cfrac{36}{1}}}}}}}}}}}}}} = \frac{3}{1}\] \[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19 - \cfrac{1}{1 - \cfrac{45}{44 + \cfrac{36}{1 + \cfrac{5}{13}}}}}}}}}}}}}}} = \frac{4}{1}\]Convergents:
\[\frac{0}{1}, \frac{1}{4}, \frac{1}{3}, \frac{4}{3}, \frac{1}{2}, \frac{3}{5}, \frac{3}{2}, \frac{5}{2},\] \[\frac{1}{1}, \frac{2}{5}, \frac{2}{3}, \frac{5}{3}, \frac{2}{1}, \frac{3}{4}, \frac{3}{1}, \frac{4}{1},\]
The full continued fraction is given by
\[0 + \cfrac{1}{4 - \cfrac{1}{1 - \cfrac{9}{13 + \cfrac{5}{1 + \cfrac{9}{11 - \cfrac{45}{4 - \cfrac{4}{19 - \cfrac{27}{1 + \cfrac{4}{7 + \cfrac{4}{1 - \cfrac{27}{19 - \cfrac{1}{1 - \cfrac{45}{44 + \cfrac{36}{1 + \cfrac{5}{13}}}}}}}}}}}}}}}\]Denominator array: [0,4,1,13,1,11,4,19,1,7,1,19,1,44,1,13]
Numerator array: [1,-1,-9,5,9,-45,-4,-27,4,4,-27,-1,-45,36,5,1]
\[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 4 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -9 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 13 & 5 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & 9 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 11 & -45 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 4 & -4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 19 & -27 \\ 1 & 0 \\ \end{bmatrix} \] \[\begin{bmatrix} 1 & 4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 7 & 4 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -27 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 19 & -1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & -45 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 44 & 36 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 1 & 5 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 13 & 1 \\ 1 & 0 \\ \end{bmatrix} \] \[= \frac{4}{1}\]⇒ \[\begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix} \begin{bmatrix} 4 & -1 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 4 & -1 \\ \end{bmatrix} => \frac{0}{-1}, \frac{1}{4}\] \[\begin{bmatrix} 1 & 0 \\ 4 & -1 \\ \end{bmatrix} \begin{bmatrix} 1 & -9 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 1 & -9 \\ 3 & -36 \\ \end{bmatrix} => \frac{1}{3}\] \[\begin{bmatrix} 1 & -9 \\ 3 & -36 \\ \end{bmatrix} \begin{bmatrix} 13 & 5 \\ 1 & 0 \\ \end{bmatrix} = \begin{bmatrix} 4 & 5 \\ 3 & 15 \\ \end{bmatrix} => \frac{4}{3}\] \[\begin{bmatrix} 4 & 5 \\ 3 & 15 \\ \end{bmatrix} \begin{bmatrix} 1 & 9 \\ 1 & 0 \\ \end{bmatrix} = (3^2) \cdot \begin{bmatrix} 1 & 4 \\ 2 & 3 \\ \end{bmatrix} => \frac{1}{2}\] \[9 \cdot \begin{bmatrix} 1 & 4 \\ 2 & 3 \\ \end{bmatrix} \begin{bmatrix} 11 & -45 \\ 1 & 0 \\ \end{bmatrix} = (3^2 \cdot 5) \cdot \begin{bmatrix} 3 & -9 \\ 5 & -18 \\ \end{bmatrix} => \frac{3}{5}\] \[45 \cdot \begin{bmatrix} 3 & -9 \\ 5 & -18 \\ \end{bmatrix} \begin{bmatrix} 4 & -4 \\ 1 & 0 \\ \end{bmatrix} = (3^2 \cdot 5) \cdot \begin{bmatrix} 3 & -12 \\ 2 & -20 \\ \end{bmatrix} => \frac{3}{2}\] \[45\cdot \begin{bmatrix} 3 & -12 \\ 2 & -20 \\ \end{bmatrix} \begin{bmatrix} 19 & -27 \\ 1 & 0 \\ \end{bmatrix} = (3^4 \cdot 5) \cdot \begin{bmatrix} 5 & -9 \\ 2 & -6 \\ \end{bmatrix} => \frac{5}{2}\] \[405 \cdot \begin{bmatrix} 5 & -9 \\ 2 & -6 \\ \end{bmatrix} \begin{bmatrix} 1 & 4 \\ 1 & 0 \\ \end{bmatrix} = -(2^2 \cdot 3^4 \cdot 5) \cdot \begin{bmatrix} 1 & -5 \\ 1 & -2 \\ \end{bmatrix} => \frac{1}{1}\] \[-1620 \cdot \begin{bmatrix} 1 & -5 \\ 1 & -2 \\ \end{bmatrix} \begin{bmatrix} 7 & 4 \\ 1 & 0 \\ \end{bmatrix} = -(2^2 \cdot 3^4 \cdot 5) \cdot \begin{bmatrix} 2 & 4 \\ 5 & 4 \\ \end{bmatrix} => \frac{2}{5}\] \[-1620 \cdot \begin{bmatrix} 2 & 4 \\ 5 & 4 \\ \end{bmatrix} \begin{bmatrix} 1 & -27 \\ 1 & 0 \\ \end{bmatrix} = -(2^2 \cdot 3^5 \cdot 5) \cdot \begin{bmatrix} 2 & -18 \\ 3 & -45 \\ \end{bmatrix} => \frac{2}{3}\] \[-4860 \cdot \begin{bmatrix} 2 & -18 \\ 3 & -45 \\ \end{bmatrix} \begin{bmatrix} 19 & -1 \\ 1 & 0 \\ \end{bmatrix} = -(2^2 \cdot 3^5 \cdot 5) \cdot \begin{bmatrix} 20 & -2 \\ 12 & -3 \\ \end{bmatrix} => \frac{5}{3}\] \[-4860 \cdot \begin{bmatrix} 20 & -2 \\ 12 & -3 \\ \end{bmatrix} \begin{bmatrix} 1 & -45 \\ 1 & 0 \\ \end{bmatrix} = -(2^2 \cdot 3^7 \cdot 5) \cdot \begin{bmatrix} 2 & -100 \\ 1 & -60 \\ \end{bmatrix} => \frac{2}{1}\] \[-43740 \cdot \begin{bmatrix} 2 & -100 \\ 1 & -60 \\ \end{bmatrix} \begin{bmatrix} 44 & 36 \\ 1 & 0 \\ \end{bmatrix} = (2^4 \cdot 3^7 \cdot 5) \cdot \begin{bmatrix} 3 & -18 \\ 4 & -9 \\ \end{bmatrix} => \frac{3}{4}\] \[174960 \cdot \begin{bmatrix} 3 & -18 \\ 4 & -9 \\ \end{bmatrix} \begin{bmatrix} 1 & 5 \\ 1 & 0 \\ \end{bmatrix} = -(2^4 \cdot 3^7 \cdot 5^2) \cdot \begin{bmatrix} 3 & -3 \\ 1 & -4 \\ \end{bmatrix} => \frac{3}{1}\] \[-874800 \cdot \begin{bmatrix} 3 & -3 \\ 1 & -4 \\ \end{bmatrix} \begin{bmatrix} 13 & 1 \\ 1 & 0 \\ \end{bmatrix} = -(2^4 \cdot 3^7 \cdot 5^2) \cdot \begin{bmatrix} 36 & 3 \\ 9 & 1 \\ \end{bmatrix} => \frac{4}{1}\]
While level 3 does suggest some possible patterns, level 4 seems pretty far removed - but who is to say? The challenge has been issued!
Denominator Arrays
TYPE I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 0 2 1 3 3 0 3 1 7 1 5 1 7 4 0 4 1 13 1 11 4 19 1 7 1 19 1 44 1 13 5 0 5 1 21 1 19 9 37 5 47 1 49 1 279 4 39 TYPE II 0 1 1 1 1 1 3 3 1 25 7 7 5 5 1 49 Numerator Arrays
TYPE I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 1 -1 -1 1 3 1 -1 -4 1 -4 -4 1 1 4 1 -1 -9 5 9 -45 -4 -27 4 4 -27 -1 -45 36 5 1 5 1 -1 -16 11 80 -176 -45 -176 18 -99 50 1 -275 -225 44 1 TYPE II 1 1 -3 5 -21 25 -49 11 -91 605 -247 231 -361 33 -247 133
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Test Yourself
Share Your Results
Enter your name:
My class:
Email to:
Session report length: 0 characters.
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Share with QR Code
GXWeb Fractured Fractions Jigsaw
QR Codes are a great way to share data and information with others, even when no Internet connection is available. Most modern devices either come equipped with QR readers in-built, or freely available.
The default link here is the GXWeb Fractured Fractions Jigsaw, but you can use it as an alternative to sending your assessment data via email, web or share with others in your class. You can even use it to send your own messages!
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Explore Further
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Construct your own Model with GXWeb
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
References
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
Bates, B., Bunder, M. and Tognetti, K. (2010): Locating Terms in the Stern-Brocot Tree
Bates, B., Bunder, M. and Tognetti, K. (2010): Linking the Calkin-Wilf and Stern-Brocot trees
Bruce Bates (2014): The Stern-Brocot Continued Fraction
Calkin and Wilf (1999): Recounting the Rationals
Explore Bill Gosper (1972): Continued Fraction Arithmetic
Ferreira, J and Mendes, A (2016) A calculational approach to path-based properties of the Eisenstein-Stern and Stern-Brocot trees via matrix algebra
Gobler, Ben (2022) The Calkin-Wilf Tree: Extensions and Applications
Ben Gobler: Listing the Rationals Using Continued Fractions 1 (YouTube 15:09)
Ben Gobler: Listing the Rationals Using Continued Fractions 2 (YouTube 9:33)
Ben Gobler: Listing the Rationals Using Continued Fractions 3 (YouTube 13:42)
Behind the Scenes
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
About the Stern-Brocot Continued Fraction
Navigating the Fraction Trees
©2022 Compass Learning Technologies ← GXWeb Farey Numbers, Fraction Trees and Kissing Circles ← Climbing Around Fraction Trees