Farey sequence explained

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]

Examples

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 =

Farey sunburst

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 .

History

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.

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 .

\varphi(n)

:

|Fn|=|Fn-1|+\varphi(n).

Using the fact that |F1| = 2, we can derive an expression for the length of Fn:

|Fn|=1+

n
\sum
m=1

\varphi(m)=1+\Phi(n),

where

\Phi(n)

is the summatory totient.

We also have :

|Fn|=

1
2
n\mu(d)\left\lfloor\tfrac{n}{d}\right\rfloor
\left(3+\sum
d=1

2\right),

and by a Möbius inversion formula :

|Fn|=

1
2
n|F
(n+3)n-\sum
\lfloorn/d\rfloor

|,

where is the number-theoretic Möbius function, and

\lfloor\tfrac{n}{d}\rfloor

is the floor function.

The asymptotic behaviour of |Fn| is :

|Fn|\sim

3n2
\pi2

.

The number of Farey fractions with denominators equal to

k

in Fn is given by

\varphi(k)

when

k\leqn

and zero otherwise. Concerning the numerators one can define the function

l{N}n(h)

that returns the number of Farey fractions with numerators equal to

h

in Fn. This function has some interesting properties as[4]

l{N}n(1)=n

,
m)=\left\lceil(n-p
l{N}
n(p

m)\left(1-1/p\right)\right\rceil

for any prime number

p

,

l{N}n+mh(h)=l{N}n(h)+m\varphi(h)

for any integer

m\geq0

,

l{N}n(4h)=l{N}n(2h)-\varphi(2h)

.In particular, the property in the third line above implies

l{N}mh(h)=(m-1)\varphi(h)

and, further,

l{N}2h(h)=\varphi(h)

. The latter means that, for Farey sequences of even order n, the number of fractions with numerators equal to n/2 is the same as the number of fractions with denominators equal to n/2, that is

l{N}n(n/2)=\varphi(n/2)

.

The index

In(ak,n)=k

of a fraction

ak,n

in the Farey sequence

Fn=\{ak,n:k=0,1,\ldots,mn\}

is simply the position that

ak,n

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:

In(0/1)=0,

In(1/n)=1,

In(1/2)=(|Fn|-1)/2,

In(1/1)=|Fn|-1,

In(h/k)=|Fn|-1-In((k-h)/k).

The index of

1/k

where

n/(i+1)<k\leqn/i

and

n

is the least common multiple of the first

i

numbers,

n={\rmlcm}([2,i])

, is given by:[5]

In(1/k)=1+n

i
\sum
j=1
\varphi(j)
j

-k\Phi(i).

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 . Since

c
d

-

a
b

=

bc-ad
bd

,

this is equivalent to saying that

bc-ad=1

.

Thus and are neighbours in F5, and their difference is .

The converse is also true. If

bc-ad=1

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(b,d).

If has neighbours and in some Farey sequence, with

a
b

<

p
q

<

c
d

then is the mediant of and  - in other words,

p
q

=

a+c
b+d

.

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

a+c
b+d

,

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.

Equivalent-area interpretation

Every consecutive pair of Farey rationals have an equivalent area of 1.[6] See this by interpreting consecutive rationals r1 = p/q and r2 = p′/q′ as vectors (p, q) in the x–y plane. The area of A(p/q, p′/q′) is given by qp′ − qp. As any added fraction in between two previous consecutive Farey sequence fractions is calculated as the mediant (⊕), then A(r1, r1r2) = A(r1, r1) + A(r1, r2) = A(r1, r2) = 1 (since r1 = 1/0 and r2 = 0/1, its area must be 1).

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 by 1. If, which first appears in Farey sequence Fq, has continued fraction expansions

[0; ''a''<sub>1</sub>, ''a''<sub>2</sub>, ..., ''a''<sub>''n'' &minus; 1</sub>, ''a''<sub>''n''</sub>, 1]

[0; ''a''<sub>1</sub>, ''a''<sub>2</sub>, ..., ''a''<sub>''n'' &minus; 1</sub>, ''a''<sub>''n''</sub> + 1]

then the nearest neighbour of in Fq (which will be its neighbour with the larger denominator) has a continued fraction expansion

[0; ''a''<sub>1</sub>, ''a''<sub>2</sub>, ..., ''a''<sub>''n''</sub>]

and its other neighbour has a continued fraction expansion

[0; ''a''<sub>1</sub>, ''a''<sub>2</sub>, ..., ''a''<sub>''n'' &minus; 1</sub>]

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

The lcm can be expressed as the products of Farey fractions as

lcm[1,2,...,N]=e\psi(N)=

1
2

\left(

\prod
r\inFN,0<r\le1/2

2\sin(\pir)\right)2

where

\psi(N)

is the second Chebyshev function.[7] [8]

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,

|Fn|=1+

n
\sum
m=1

\varphi(m)=1+

n
\sum\limits
m=1
m
\sum\limits
k=1

\gcd(k,m)\cos{2\pi

k
m
} .

For any 3 Farey fractions, and the following identity between the gcd's of the 2x2 matrix determinants in absolute value holds:[9]

\gcd\left(\begin{Vmatrix}a&c\\b&d\end{Vmatrix},\begin{Vmatrix}a&e\\b&f\end{Vmatrix}\right) =\gcd\left(\begin{Vmatrix}a&c\\b&d\end{Vmatrix},\begin{Vmatrix}c&e\\d&f\end{Vmatrix}\right) =\gcd\left(\begin{Vmatrix}a&e\\b&f\end{Vmatrix},\begin{Vmatrix}c&e\\d&f\end{Vmatrix}\right)

[10]

Applications

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 log2(3).

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 r-constrained paths, namely paths made up of line segments that each traverse at most

r

rows and at most

r

columns of cells. Let

Q

be the set of vectors

(q,p)

such that

1\leqq\leqr

,

0\leqp\leqq

, and

p

,

q

are coprime. Let

Q*

be the result of reflecting

Q

in the line

y=x

. Let

S=\{(\pmx,\pmy):(x,y)\inQ\cupQ*\}

. Then any r-constrained path can be described as a sequence of vectors from

S

. There is a bijection between

Q

and the Farey sequence of order

r

given by

(q,p)

mapping to

\tfrac{p}{q}

.

Ford circles

There is a connection between Farey sequence and Ford circles.

For every fraction (in its lowest terms) there is a Ford circle C[{{sfrac|''p''|''q''}}], which is the circle with radius 1/(2q2) 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[{{sfrac|''p''|''q''}}] are precisely the Ford circles for fractions that are neighbours of in some Farey sequence.

Thus C[{{sfrac|2|5}}] is tangent to C[{{sfrac|1|2}}], C[{{sfrac|1|3}}], C[{{sfrac|3|7}}], C[{{sfrac|3|8}}], etc.

Ford circles appear also in the Apollonian gasket (0,0,1,1). The picture below illustrates this together with Farey resonance lines.[17]

Riemann hypothesis

Farey sequences are used in two equivalent formulations of the Riemann hypothesis. Suppose the terms of

Fn

are

\{ak,n:k=0,1,\ldots,mn\}

. Define

dk,n=ak,n-k/mn

, in other words

dk,n

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[18] proved that the statement
mn
\sum
k=1
2
d
k,n

=O(nr)\forallr>-1

is equivalent to the Riemann hypothesis, and then Edmund Landau[19] remarked (just after Franel's paper) that the statement

mn
\sum
k=1

|dk,n|=O(nr)\forallr>1/2

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:

\sum
r\inFn

r=

1
2

|Fn|.

The sum of the denominators in the Farey sequence is twice the sum of the numerators and relates to Euler's totient function:

\sum
a/b\inFn

b=2

\sum
a/b\inFn

a=1+

n
\sum
i=1

i\varphi(i),

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

{\displaystyle1+\sum\sum(a,b)=1a=1+\sumb

\varphi(b)
2
}. The sum of denominators is

{\displaystyle2+\sum\sum(a,b)=1b=2+\sumb\varphi(b)}

. The quotient of the first sum by the second sum is
1
2
.

Let bj be the ordered denominators of Fn, then:[21]

|Fn|-1
\sum
j=0
bj
bj+1

=

3|Fn|-4
2

and

|Fn|-1
\sum
j=0
1
bj+1bj

=1.

Let aj/bj the jth Farey fraction in Fn, then

|Fn|-1
\sum
j=1

(aj-1bj+1-aj+1bj-1)=

|Fn|-1
\sum
j=1

\begin{Vmatrix}aj-1&aj+1\\bj-1&bj+1\end{Vmatrix}=3(|Fn|-1)-2n-1,

which is demonstrated in.[22] Also according to this reference the term inside the sum can be expressed in many different ways:

aj-1bj+1-aj+1bj-1=

bj-1+bj+1
bj

=

aj-1+aj+1
aj

=\left\lfloor

n+bj-1
bj

\right\rfloor,

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

\lfloor|Fn|/2\rfloor
\sum
j=1

(aj-1bj+1-aj+1bj-1)=3(|Fn|-1)/2-n-\lceiln/2\rceil,

The Mertens function can be expressed as a sum over Farey fractions as

M(n)=-1+\suma\inn}e2\pi

  where  

l{F}n

  is the Farey sequence of order n.

This formula is used in the proof of the Franel–Landau theorem.[23]

Next term

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)
so 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 (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:from fractions import Fractionfrom collections.abc import Generator

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__

"__main__": import doctest

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]

See also

Further reading

External links

Notes and References

  1. Book: Guthery . Scott B. . 2011 . A Motif of Mathematics: History and Application of the Mediant and the Farey Sequence . 1. The Mediant . 7 . Docent Press . Boston . en . 978-1-4538-1057-6 . 1031694495 . https://books.google.com/books?id=swb2c9enRJcC&pg=PA7 . 28 September 2020.
  2. Book: G. H. Hardy . Hardy, G.H. . E. M. Wright . Wright, E.M. . 1979 . An Introduction to the Theory of Numbers . Fifth . Oxford University Press . 0-19-853171-0 . Chapter III .
  3. Book: Beiler, Albert H. . 1964 . Recreations in the Theory of Numbers . Second . Dover . 0-486-21096-0 . Chapter XVI. Cited in Web site: Farey Series, A Story . Cut-the-Knot.
  4. Tomas Garcia . Rogelio . Farey Fractions with Equal Numerators and the Rank of Unit Fractions . Integers . July 2024 . 24 . 13 July 2024 --> .
  5. Tomas . Rogelio . Partial Franel sums . Journal of Integer Sequences . January 2022 . 25 . 1 . 16 January 2022 --> .
  6. Web site: Austin . David . December 2008 . Trees, Teeth, and Time: The mathematics of clock making . . Rhode Island . en . 28 September 2020 . live . https://web.archive.org/web/20200204014725/http://www.ams.org/publicoutreach/feature-column/fcarc-stern-brocot . 4 February 2020.
  7. 0907.4384. Martin. Greg. A product of Gamma function values at fractions with the same denominator. math.CA. 2009.
  8. 0909.1838 . Wehmeier . Stefan . The LCM(1,2,...,n) as a product of sine values sampled over the points in Farey sequences . math.CA . 2009.
  9. Tomas Garcia . Rogelio . Equalities between greatest common divisors involving three coprime pairs. Notes on Number Theory and Discrete Mathematics . August 2020 . 26 . 3. 5–7 . 10.7546/nntdm.2020.26.3.5-7 . 225280271 . free . 20 January 2022 --> .
  10. Tomas . Rogelio . Partial Franel sums . Journal of Integer Sequences . January 2022 . 25 . 1 . 16 January 2022 --> .
  11. Web site: Farey Approximation . NRICH.maths.org . 18 November 2018 . https://web.archive.org/web/20181119092100/https://nrich.maths.org/6596 . 19 November 2018 . dead.
  12. Eliahou . Shalom . The 3x+1 problem: new lower bounds on nontrivial cycle lengths . Discrete Mathematics . August 1993 . 118 . 1–3 . 45–56 . 10.1016/0012-365X(93)90052-U. free .
  13. Zhenhua Li . A. . Harter . W.G. . 1308.4470 . Quantum Revivals of Morse Oscillators and Farey–Ford Geometry . Chem. Phys. Lett. . 2015 . 633 . 208–213 . 10.1016/j.cplett.2015.05.035. 2015CPL...633..208L . 66213897 .
  14. Tomas . R. . 2014 . 10.1103/PhysRevSTAB.17.014001. From Farey sequences to resonance diagrams . Physical Review Special Topics - Accelerators and Beams . 17 . 1 . 014001. 2014PhRvS..17a4001T . free .
  15. Harabor . Daniel Damir . Grastien . Alban . Öz . Dindar . Aksakalli . Vural . Optimal Any-Angle Pathfinding In Practice . Journal of Artificial Intelligence Research . 26 May 2016 . 56 . 89–118 . 10.1613/jair.5007. free .
  16. Hew . Patrick Chisan . The Length of Shortest Vertex Paths in Binary Occupancy Grids Compared to Shortest r-Constrained Ones . Journal of Artificial Intelligence Research . 19 August 2017 . 59 . 543–563 . 10.1613/jair.5442. free .
  17. Tomas . Rogelio . 2006.10661. Imperfections and corrections . physics.acc-ph. 2020 . 4 July 2020 --> .
  18. Jérôme Franel . Jérôme . Franel . Les suites de Farey et le problème des nombres premiers . Nachrichten von der Gesellschaft der Wissenschaften zu Göttingen . Mathematisch-Physikalische Klasse . 1924 . 198–201 . fr.
  19. Edmund Landau . Edmund . Landau . Bemerkungen zu der vorstehenden Abhandlung von Herrn Franel . Nachrichten von der Gesellschaft der Wissenschaften zu Göttingen . Mathematisch-Physikalische Klasse . 1924 . 202–206 . de.
  20. Jean A.. Blake. 10.2307/2313922 . Some Characteristic Properties of the Farey Series. The American Mathematical Monthly. 73. 1. 1966. 50–52 . 2313922 .
  21. 10.4169/000298910X475005 . 10.4169/000298910X475005 . Farey Sums and Dedekind Sums . The American Mathematical Monthly . 117 . 1 . 72–78 . 2010 . Kurt Girstmair . Girstmair . Kurt. 31933470 .
  22. R. R. . Hall . P. . Shiu . The Index of a Farey Sequence. Michigan Math. J. . 51 . 2003. 10.1307/mmj/1049832901. 1 . 209–223. free .
  23. Book: Edwards . Harold M. . Harold Edwards (mathematician) . Smith. Paul A.. Paul Althaus Smith. Ellenberg. Samuel. Samuel Eilenberg. 1974 . Riemann's Zeta Function . 12.2 Miscellany. The Riemann Hypothesis and Farey Series . . Pure and Applied Mathematics. 263267 . New York . en . 978-0-08-087373-2 . 316553016 . https://archive.org/details/riemannszetafunc00edwa_0/page/262 . registration . 30 September 2020.
  24. Norman . Routledge . Computing Farey series . . 92 . 523 . 55–62 . March 2008.