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 (although some authors omit these terms).
A Farey sequence is sometimes called a Farey series, which is not strictly correct, because the terms are not summed.[1]
The Farey sequences of orders 1 to 8 are :
F1 =
F2 =
F3 =
F4 =
F5 =
F6 =
F7 =
F8 =
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
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, centered at the origin. Using Pick's theorem, the area of the sunburst is, where is the number of fractions in .
The history of 'Farey series' is very curious — Hardy & Wright (1979)[2]
... once again the man whose name was given to a mathematical relation was not the original discoverer so far as the records go. — Beiler (1964)[3]
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.[3] Thus it was a historical accident that linked Farey's name with these sequences. This is an example of Stigler's law of eponymy.
The Farey sequence of order contains all of the members of the Farey sequences of lower orders. In particular contains all of the members of and also contains an additional fraction for each number that is less than and coprime to . Thus consists of together with the fractions and .
The middle term of a Farey sequence is always, for . From this, we can relate the lengths of and using Euler's totient function :
Using the fact that, we can derive an expression for the length of :
where is the summatory totient.
We also have :and by a Möbius inversion formula : where is the number-theoretic Möbius function, and
\lfloorn/d\rfloor
The asymptotic behaviour of is :
The number of Farey fractions with denominators equal to in is given by when and zero otherwise. Concerning the numerators one can define the function
l{N}n(h)
l{N}n(1)=n
m)=\left\lceil(n-p | |
l{N} | |
n(p |
m)\left(1-1/p\right)\right\rceil
p
l{N}n+mh(h)=l{N}n(h)+m\varphi(h)
l{N}n(4h)=l{N}n(2h)-\varphi(2h).
l{N}mh(h)=(m-1)\varphi(h)
l{N}2h(h)=\varphi(h).
l{N}n(n/2)=\varphi(n/2)
The index
In(ak,n)=k
ak,n
Fn=\{ak,n:k=0,1,\ldots,mn\}
ak,n
The index of where and is the least common multiple of the first numbers,, is given by:[5]
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 . Since
this is equivalent to saying that
Thus and are neighbours in, and their difference is .
The converse is also true. If
for positive integers with and, then and will be neighbours in the Farey sequence of order .
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
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 .
The total number of Farey neighbour pairs in is .
The Stern–Brocot tree is a data structure showing how the sequence is built up from 0 and 1, by taking successive mediants.
Every consecutive pair of Farey rationals have an equivalent area of 1.[6] See this by interpreting consecutive rationals as vectors in the xy-plane. The area is given byAs any added fraction in between two previous consecutive Farey sequence fractions is calculated as the mediant (⊕), then (since and, its area must be 1).
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 by 1. If, which first appears in Farey sequence, has the continued fraction expansions
then the nearest neighbour of in (which will be its neighbour with the larger denominator) 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 are, which can be expanded as ; and, which can be expanded as .
The lcm can be expressed as the products of Farey fractions as
where is the second Chebyshev function.[7] [8]
Since the Euler's totient function is directly connected to the gcd so is the number of elements in,
For any 3 Farey fractions the following identity between the gcd's of the 2x2 matrix determinants in absolute value holds:[9]
Farey sequences are very useful to find rational approximations of irrational numbers.[11] For example, the construction by Eliahou[12] 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 .
In physical systems with resonance phenomena, Farey sequences provide a very elegant and efficient method to compute resonance locations in 1D[13] and 2D.[14]
Farey sequences are prominent in studies of any-angle path planning on square-celled grids, for example in characterizing their computational complexity[15] or optimality.[16] The connection can be considered in terms of -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
1\leqq\leqr
0\leqp\leqq
S=\{(\pmx,\pmy):(x,y)\inQ\cupQ*\}
\tfrac{p}{q}
There is a connection between Farey sequence and Ford circles.
For every fraction (in its lowest terms) there is a Ford circle, which is the circle with radius
\tfrac{1}{2q2}
l(\tfrac{p}{q},\tfrac{1}{2q2}r).
Thus is tangent to,,,, etc.
Ford circles appear also in the Apollonian gasket . The picture below illustrates this together with Farey resonance lines.[17]
Farey sequences are used in two equivalent formulations of the Riemann hypothesis. Suppose the terms of are
\{ak,n:k=0,1,\ldots,mn\}.
dk,n=ak,n-\tfrac{k}{mn},
dk,n
is equivalent to the Riemann hypothesis, and then Edmund Landau[19] remarked (just after Franel's paper) that the statement
is also equivalent to the Riemann hypothesis.
The sum of all Farey fractions of order 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.[20] A one line proof of the Harold L. Aaron conjecture is as follows.The sum of the numerators is The sum of denominators isThe quotient of the first sum by the second sum is .
Let be the ordered denominators of, then:[21]
-1 |
Let
\tfrac{aj}{bj}
which is demonstrated in.[22] 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 aswhere
l{F}n
This formula is used in the proof of the Franel–Landau theorem.[23]
A surprisingly simple algorithm exists to generate the terms of Fn in either traditional order (ascending) or non-traditional order (descending). 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 and, giving and . If we consider p and q to be functions of k, then
p(k) | |
q(k) |
-
c | |
d |
=
cb-da | |
d(kd-b) |
To give the next term in the sequence k must be as large as possible, subject to (as we are only considering numbers with denominators not greater than n), so k is the greatest . Putting this value of k back into the equations for p and q gives
p=\left\lfloor
n+b | |
d |
\right\rfloorc-a
q=\left\lfloor
n+b | |
d |
\right\rfloord-b
This is implemented in Python as follows:
def farey_sequence(n: int, descending: bool = False) -> Generator[Fraction]: """ Print the n'th Farey sequence. Allow for either ascending or descending.
>>> print(*farey_sequence(5), sep=' ') 0 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1 """ a, b, c, d = 0, 1, 1, n if descending: a, c = 1, n - 1 yield Fraction(a, b) while 0 <= c <= n: k = (n + b) // d a, b, c, d = c, d, k * c - a, k * d - b yield Fraction(a, b)
if __name__
doctest.testmod
Brute-force searches for solutions to Diophantine equations in rationals can often take advantage of the Farey series (to search only reduced forms). While this code uses the first two terms of the sequence to initialize a, b, c, and d, one could substitute any pair of adjacent terms in order to exclude those less than (or greater than) a particular threshold.[24]