The Farey sequence of order , written , consists of all reduced fractions between and whose denominators do not exceed , arranged in increasing order. The simple example begins , , , and ends with . Neighboring terms always satisfy . This elegant property ensures fractions are as close as possible without sharing denominators.
Farey sequences relate intimately to mediants and Diophantine approximation. In each step between and , one inserts mediant fractions whenever the new denominator does not exceed . This iterative construction reveals how rational approximations to real numbers become finer as the order increases.
John Farey, an English geologist, observed a pattern in the arrangement of fractions in 1816, though the concept had been studied earlier by mathematicians such as Cauchy. Farey sequences later gained prominence in geometry and dynamical systems. For instance, they describe the winding numbers of closed geodesics on a torus, encode rotations in continued fraction expansions, and even appear in the study of the Riemann hypothesis via Ford circles.
Provide an integer greater than zero. The algorithm constructs the sequence starting from and . It iteratively generates next terms by computing mediants and updating a pair of neighboring fractions. Because each mediant has denominator , the sequence respects the order restriction. The resulting list shows how rationals fill the interval ever more densely as grows.
Farey sequences provide insight into fractions that closely approximate irrational numbers. For example, fractions neighboring , where is the golden ratio, follow a pattern related to Fibonacci numbers. By generating sequences for large orders, you can discover how simple fractions approximate famous irrational constants with surprising accuracy.
Compute the characteristic polynomial of a 2x2 or 3x3 matrix and learn how it relates to eigenvalues.
Compute a truncated Fourier series for a function on [-π, π] to study periodic behavior.
Approximate a root of a continuous function on a given interval using the bisection method.