Farey sequence
In mathematics, the Farey sequence of order n is the sequence of completely reduced fractions, either between 0 and 1, or without this restriction, which when in lowest terms have denominators less than or equal to n, arranged in order of increasing size.
With the restricted definition, each Farey sequence starts with the value 0, denoted by the fraction, and ends with the value 1, denoted by the fraction .
A Farey sequence is sometimes called a Farey series, which is not strictly correct, because the terms are not summed.
Examples
The Farey sequences of orders 1 to 8 are :Centered |
F1 = |
F2 = |
F3 = |
F4 = |
F5 = |
F6 = |
F7 = |
F8 = |
Plotting the numerators versus the denominators of a Farey sequence gives a shape like the one to the right, shown for 6.
Reflecting this shape around the diagonal and main axes generates the Farey sunburst, shown [|below]. The Farey sunburst of order connects the visible integer grid points from the origin in the square of side 2, centered at the origin. Using Pick's theorem the area of the sunburst is 4, where |n| is the number of fractions in n.
History
Farey sequences are named after the British geologist John Farey, Sr., whose letter about these sequences was published in the Philosophical Magazine in 1816. Farey conjectured, without offering proof, that each new term in a Farey sequence expansion is the mediant of its neighbours. Farey's letter was read by Cauchy, who provided a proof in his Exercices de mathématique, and attributed this result to Farey. In fact, another mathematician, Charles Haros, had published similar results in 1802 which were not known either to Farey or to Cauchy. Thus it was a historical accident that linked Farey's name with these sequences. This is an example of Stigler's law of eponymy.Properties
Sequence length and index of a fraction
The Farey sequence of order n contains all of the members of the Farey sequences of lower orders. In particular Fn contains all of the members of Fn−1 and also contains an additional fraction for each number that is less than n and coprime to n. Thus F6 consists of F5 together with the fractions and.The middle term of a Farey sequence Fn is always,
for n > 1. From this, we can relate the lengths of Fn and Fn−1 using Euler's totient function :
Using the fact that |F1| = 2, we can derive an expression for the length of Fn:
where is the summatory totient.
We also have :
and by a Möbius inversion formula :
where µ is the number-theoretic Möbius function, and is the floor function.
The asymptotic behaviour of |Fn| is :
The index of a fraction in the Farey sequence is simply the position that occupies in the sequence. This is of special relevance as it is used in an alternative formulation of the Riemann hypothesis, see below. Various useful properties follow:
The index of where and is the least common multiple of the first numbers,, is given by:
Farey neighbours
Fractions which are neighbouring terms in any Farey sequence are known as a Farey pair and have the following properties.If and are neighbours in a Farey sequence, with < , then their difference − is equal to. This is because every consecutive pair of Farey rationals have an equivalent area of 1.
If r1=p/q and r2=p'/q' are interpreted as vectors in the x,y plane, the area of A is given by qp' - q'p.
As any added fraction in between two previous consecutive Farey sequence fractions is calculated as the mediant
A = A + A = A = 1 .
Since:
this is equivalent to saying that
Thus and are neighbours in F5, and their difference is.
The converse is also true. If
for positive integers a,b,c and d with a < b and c < d then and will be neighbours in the Farey sequence of order max.
If has neighbours and in some Farey sequence, with
then is the mediant of and - in other words,
This follows easily from the previous property, since if, then,,.
It follows that if and are neighbours in a Farey sequence then the first term that appears between them as the order of the Farey sequence is incremented is
which first appears in the Farey sequence of order.
Thus the first term to appear between and is, which appears in F8.
The total number of Farey neighbour pairs in Fn is 2|Fn|-3.
The Stern–Brocot tree is a data structure showing how the sequence is built up from 0 and 1, by taking successive mediants.
Farey neighbours and continued fractions
Fractions that appear as neighbours in a Farey sequence have closely related continued fraction expansions. Every fraction has two continued fraction expansions — in one the final term is 1; in the other the final term is greater than 1. If, which first appears in Farey sequence Fq, has continued fraction expansionsthen the nearest neighbour of in Fq has a continued fraction expansion
and its other neighbour has a continued fraction expansion
For example, has the two continued fraction expansions and, and its neighbours in F8 are, which can be expanded as ; and, which can be expanded as.
Farey fractions and the least common multiple
In and it is shown that the lcm can be expressed as the products of Farey fractions aswhere is the second Chebyshev function.
Farey fractions and the greatest common divisor
Since the Euler's totient function is directly connected to the gcd so is the number of elements in Fn,For any 3 Farey fractions, and the following identity between the gcd's of the 2x2 matrix determinants in absolute value holds:
Applications
Farey sequences are very useful to find rational approximations of irrational numbers. For example, the construction by Eliahou of a lower bound on the length of non-trivial cycles in the 3x+1 process uses Farey sequences to calculate a continued fraction expansion of the number log2.In physics systems featuring resonance phenomena Farey sequences provide a very elegant and efficient method to compute resonance locations in 1D and 2D.
Farey sequences are prominent in studies of any-angle path planning on square-celled grids, for example in characterizing their computational complexity or optimality. The connection can be considered in terms of r-constrained paths, namely paths made up of line segments that each traverse at most rows and at most columns of cells. Let be the set of vectors such that,, and, are coprime. Let be the result of reflecting in the line. Let. Then any r-constrained path can be described as a sequence of vectors from. There is a bijection between and the Farey sequence of order given by mapping to.
Ford circles
There is a connection between Farey sequence and Ford circles.For every fraction there is a Ford circle C, which is the circle with radius 1/ and centre at. Two Ford circles for different fractions are either disjoint or they are tangent to one another—two Ford circles never intersect. If 0 < < 1 then the Ford circles that are tangent to C are precisely the Ford circles for fractions that are neighbours of in some Farey sequence.
Thus C is tangent to C, C, C, C etc.
Ford circles appear also in the Apollonian gasket. The picture below illustrates this together with Farey resonance lines.
and the Farey resonance diagram.
Riemann hypothesis
Farey sequences are used in two equivalent formulations of the Riemann hypothesis. Suppose the terms of are. Define, in other words is the difference between the kth term of the nth Farey sequence, and the kth member of a set of the same number of points, distributed evenly on the unit interval. In 1924 Jérôme Franel proved that the statementis equivalent to the Riemann hypothesis, and then Edmund Landau remarked that the statement
is also equivalent to the Riemann hypothesis.
Other sums involving Farey fractions
The sum of all Farey fractions of order n is half the number of elements:The sum of the denominators in the Farey sequence is twice the sum of the numerators and relates to Euler's totient function:
which was conjectured by Harold L. Aaron in 1962 and demonstrated by Jean A. Blake in 1966. A one line proof of the Harold L. Aaron conjecture is as follows.
The sum of the numerators is. The sum of denominators is
. The quotient of the first sum by the second sum is.
Let bj be the ordered denominators of Fn, then:
and
Let aj/bj the jth Farey fraction in Fn, then
which is demonstrated in. Also according to this reference the term inside the sum can be expressed in many different ways:
obtaining thus many different sums over the Farey elements with same result. Using the symmetry around 1/2 the former
sum can be limited to half of the sequence as
The Mertens function can be expressed as a sum over Farey fractions as
This formula is used in the proof of the Franel–Landau theorem.
Next term
A surprisingly simple algorithm exists to generate the terms of Fn in either traditional order or non-traditional order. The algorithm computes each successive entry in terms of the previous two entries using the mediant property given above. If and are the two given entries, and is the unknown next entry, then = . Since is in lowest terms, there must be an integer k such that kc = a + p and kd = b + q, giving p = kc − a and q = kd − b. If we consider p and q to be functions of k, thenso the larger k gets, the closer gets to.
To give the next term in the sequence k must be as large as possible, subject to kd − b ≤ n, so k is the greatest integer ≤ . Putting this value of k back into the equations for p and q gives
This is implemented in Python as follows:
def farey_sequence -> None:
"""Print the n'th Farey sequence. Allow for either ascending or descending."""
=
if descending:
=
while or :
k = // d
=
Brute-force searches for solutions to Diophantine equations in rationals can often take advantage of the Farey series. The lines marked can also be modified to include any two adjacent terms so as to generate terms only larger than a given term.