0.0
The project is in a healthy, maintained state
A collection of Stern-Brocot based models and methods
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

Runtime

 Project Readme

FractionTree

Gem Version

A collection of Stern-Brocot based models and methods.

The Stern-Brocot algorithm describes a way of constructing sets of non-negative fractions arranged in a binary tree.

Construction of a SB tree starts by using the fractions 0/1 and 1/0, where 1/0 denotes infinity. Subsequent fractions are derived by the algorithm, (m + m′)/(n + n′), where m/n is the left adjacent fraction and m′/n′ is the right adjacent fraction, and m/n < m′/n′. This sum is called the mediant.

Given m/n = 0/1 and m′/n′ = 1/0, the first mediant sum, is:

0/1 + 1/0 => (0 + 1)/(1 + 0) = 1/1

Fractions constructed in this way, have the following properties:

  1. m/n < (m + m′)/(n + n′) < m′/n′
  2. m'n - mn' = 1

Installing

gem install fraction-tree

Authors

Jose Hales-Garcia

License

This project is licensed under the [MIT] License.

Acknowledgments