Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a list of fractions with a bounded denominator
| ResourceFunction["FareyRange"][xmin,xmax,n] generates the sorted list of rational numbers with denominators not exceeding n within the interval xmin to xmax. | 
All fractions in the interval 0 to 2 with denominators not exceeding 5:
| In[1]:= | ![ResourceFunction["FareyRange"][0, 2, 5]](https://www.wolframcloud.com/obj/resourcesystem/images/79b/79baa846-44db-4f40-bf44-3b9189923c86/7e15acb7ea4b6a12.png) | 
| Out[1]= |  | 
The bounds can be inexact numbers:
| In[2]:= | ![ResourceFunction["FareyRange"][0.33, 1.41, 7]](https://www.wolframcloud.com/obj/resourcesystem/images/79b/79baa846-44db-4f40-bf44-3b9189923c86/2b0b8c12978e0441.png) | 
| 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]](https://www.wolframcloud.com/obj/resourcesystem/images/79b/79baa846-44db-4f40-bf44-3b9189923c86/7800c9e5b039f9da.png) | 
| Out[3]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License