The Stern–Brocot tree is the binary tree of every positive rational in lowest terms, each appearing exactly once. Start with the boundary 0⁄1 and 1⁄0. At each step the tree inserts the mediant a + c⁄b + d between the two current neighbours — and a mediant is automatically the fraction with the smallest denominator that lies strictly between them. Type any positive real and this tool walks the tree, giving you the L/R path, every convergent, and the sharpest rational approximation for a chosen denominator ceiling.
| k | ak | pk/qk | value | error | |x − p/q|·q² |
|---|
A fraction p⁄q is a best rational approximation of the second kind to x if no other p′⁄q′ with q′ ≤ q satisfies |q′x − p′| < |qx − p|. Every best approximation of the second kind (with a mild exception at the head) is a convergent of x’s continued-fraction expansion — and every convergent is a node of the Stern–Brocot tree encountered along the descent toward x. That’s why the R/L path you see below is really the continued fraction in disguise: each run of L’s (or R’s) of length ak corresponds to the partial quotient ak.