OFFSET
1,1
COMMENTS
For each prime p, if p is congruent to 1 mod 4, compute (1+sqrt(p))/2, otherwise compute sqrt(p). Express it as a periodic continued fraction. Sort them by the largest term in the periodic part; within those that have the same largest term, sort them by the geometric mean of terms.
These quadratic irrationals are used in a Richtmyer low-discrepancy sequence generator. Sorting them this way puts the golden ratio first in the list of quadratic irrationals, because (frac(n*phi)) has the lowest discrepancy among sequences of the form (frac(n*a)).
LINKS
Pierre Abbat, Table of n, a(n) for n = 1..4228
Pierre Abbat, Quadlods
EXAMPLE
17 == 1 (mod 4), so compute (sqrt(17)+1)/2 = 2.561552812808830.... Its continued fraction expansion is [2;(1,1,3)]. The largest term is 3.
13 == 1 (mod 4), so compute (sqrt(13)+1)/2 = 2.30277563773199.... Its continued fraction expansion is [2;(3)]. The largest term is again 3, but the average term is larger than the average term in (sqrt(17)+1)/2, so 13 goes after 17.
7 == 3 (mod 4), so compute sqrt(7) = 2.645751311064590.... Its continued fraction expansion is [2;(1,1,1,4)]. The largest term is 4, so 7 goes after 13.
PROG
(C++) See Quadlods link. The program generates 6542 terms of the sequence, but after the 4228th term, there are terms larger than 65536, which it does not generate, interspersed.
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre Abbat, Sep 09 2019
STATUS
approved