Function Repository Resource:

FareyRange

Source Notebook

Generate a list of fractions with a bounded denominator

Contributed by: Jan Mangaldan

ResourceFunction["FareyRange"][xmin,xmax,n]

generates the sorted list of rational numbers with denominators not exceeding n within the interval xmin to xmax.

Details

All fractions returned by ResourceFunction["FareyRange"] are completely reduced.

Examples

Basic Examples (1) 

All fractions in the interval 0 to 2 with denominators not exceeding 5:

In[1]:=
ResourceFunction["FareyRange"][0, 2, 5]
Out[1]=

Scope (2) 

The bounds can be inexact numbers:

In[2]:=
ResourceFunction["FareyRange"][0.33, 1.41, 7]
Out[2]=

FareyRange can be used to find low-denominator approximations to a pair of close values:

In[3]:=
ResourceFunction["FareyRange"][1.4444, 1.4445, 2000]
Out[3]=

Properties and Relations (1) 

FareyRange[0,1,n] is equivalent to FareySequence[n]:

In[4]:=
ResourceFunction["FareyRange"][0, 1, 9] === FareySequence[9]
Out[4]=

Version History

  • 1.0.0 – 07 July 2021

Related Resources

License Information