Fraction Tree and Continued Fractions

This Demonstration is a game for exploring connections between the Stern–Brocot tree and continued fractions.
The primary challenge is to reach a destination fraction in the tree using the arrow buttons. You can follow your progress with the "fraction tree" tab.
Once you have figured out how the fraction tree works, try to solve problems using the other tabs. Use the arrow buttons to change your position in the Stern–Brocot tree. Your position in the tree will change even while using other tabs.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Snapshot 1: The fraction has been reached in the Stern–Brocot tree. It is possible to display up to 20 levels on the screen. Beyond five levels it is easier to keep track of the order of fractions using the "ordering" tab.
Snapshot 2: The same solution is shown in the order of the fractions visited. The ordering corresponds to collapsing the Stern–Brocot path onto a single dimension. The solution was reached by turning left, right, left, right.
Snapshot 3: The fraction is shown as the mediant of and ; it was produced by summing the parents' numerators to produce the numerator of the mediant and summing the parents' denominators to produce the denominator of the mediant. This method, although incorrect as a way to add fractions, is the very way to produce a mediant. The mediant always lies between the parent fractions.
Snapshot 4: Click the "continued fraction" tab to keep track of turns in the tree and to show how the continued fraction is built up from partial quotients.
Snapshot 5: Click the "plotted fractions" tab to show how the fractions converge (or not) on the goal fraction. In the snapshot, the current slope is ; the desired slope is . All visited fractions, not only the convergents, are displayed in the plot.
This Demonstration was developed under the auspices of the Poincaré Institute for Mathematics Education at Tufts University and TERC, an NSF-funded Math and Science Partnership project (NSF MSP DUE-0962863).
[1] R. L. Graham, D. E. Knuth, and O. Patashnik, Concrete Mathematics: A Foundation for Computer Science, Reading, MA: Addison–Wesley, 1994.
[2] H. M. Stark. "Number Theory from a Continued Fractions Viewpoint," An Introduction to Number Theory, Cambridge, MA: MIT Press, 1970 pp. 181–256.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+