Stern-Brocot Tree Explorer

Every fraction appears exactly once

CalculatorsFreeNo Signup
4.9(490 reviews)
All Tools

Loading tool...

About Stern-Brocot Tree Explorer

A Stern-Brocot tree explorer navigating the infinite binary tree of all positive rationals. Each node is the mediant of its ancestors. Find any fraction's path (L/R sequence), convert paths to fractions, and explore tree levels. Client-side.

Stern-Brocot Tree Explorer Features

  • Tree navigation
  • Path finder
  • Mediant
  • Fraction locator
  • Level explorer
Stern-Brocot tree: start with 0/1 and 1/0 as boundaries. Root = mediant 1/1. Left child: mediant with left ancestor. Right: with right ancestor. Every positive rational appears exactly once! Path encodes the continued fraction. First levels: 1/1, 1/2, 2/1, 1/3, 2/3, 3/2, 3/1...

How to Use

Enter fraction or path:

  • Path: L/R sequence to fraction
  • Locate: Find fraction's path
  • Levels: Browse tree layers

The Mediant

Mediant of a/b and c/d = (a+c)/(b+d). Not the average! The mediant always lies between the two fractions. This property ensures the tree is in order (in-order traversal gives all rationals sorted).

Continued Fractions

The path to a/b in the Stern-Brocot tree encodes its continued fraction! L=go left (subtract 1), R=go right (take reciprocal minus 1). The number of consecutive L's and R's gives the CF coefficients.

Step-by-Step Instructions

  1. 1Enter fraction.
  2. 2Find path.
  3. 3Navigate tree.
  4. 4Explore levels.
  5. 5Convert to CF.

Stern-Brocot Tree Explorer — Frequently Asked Questions

Why does every rational appear exactly once?+

The tree is constructed so that each node's value is unique (mediants of distinct parent pairs are distinct). The tree is also complete: for any rational p/q, the path L^a₁R^a₂L^a₃... reaches it, where [a₁,a₂,a₃,...] is its continued fraction.

How is this related to continued fractions?+

The path to p/q in the Stern-Brocot tree is L^(a₀)R^(a₁)L^(a₂)... where p/q = [a₀;a₁,a₂,...]. This gives a beautiful bijection between paths and continued fractions, and hence all positive rationals.

Who invented it?+

Independently by Moritz Stern (1858) and Achille Brocot (1861). Stern was a mathematician studying number theory; Brocot was a French clockmaker using it to find gear ratios. Same tree, different motivations!

Share this tool: