Constructing k-radius sequences

An n-ary k-radius sequence is a finite sequence of elements taken from an alphabet of size n such that any two distinct elements of the alphabet occur within distance k of each other somewhere in the sequence. These sequences were introduced by Jaromczyk and Lonc to model a caching strategy for computing certain functions on large data sets such as medical images. Let f_k(n) be the shortest length of any k-radius sequence. We improve on earlier estimates for f_k(n) by using tilings and logarithms. The main result is that f_k(n) ~ n^2/(2k) as n tends to infinity whenever a certain tiling of Z^r exists. In particular this result holds for infinitely many k, including all k<195 and all k such that k+1 or 2k+1 is prime. For certain k, in particular when 2k+1 is prime, we get a sharper error term using the theory of logarithms.


Introduction
Let k and n be positive integers. An n-ary k-radius sequence is a finite sequence a 0 , a 1 , . . . , a m−1 of elements taken from an alphabet F = {0, 1, . . . , n − 1} with the following property. For all distinct x, y ∈ F , there exist i, j ∈ {0, 1, . . . , m − 1} such that a i = x, a j = y and |i − j| ≤ k. In other words, any two distinct elements of F occur within a distance of k of each other somewhere in the sequence. We may think of a window of length k + 1 sliding along the sequence; the condition of being a k-radius sequence says that we will always be able to find a window containing both x and y, whatever our choice of x and y may be. For example, a 5-ary 2-radius sequence of length 7 is: 0, 1, 2, 3, 4, 0, 1 .
We write f k (n) for the shortest length m of an n-ary k-radius sequence. The example above shows that f 2 (5) ≤ 7 (and in fact f 2 (5) = 7). The notion of a k-radius sequence was introduced by Jaromczyk and Lonc [11]. Such sequences describe a First-In First-Out caching strategy for computing functions that require computations on all pairs taken from a set of n large objects (such as medical images), where at most k + 1 objects are cached at any one time. We believe that the problem of constructing short k-radius sequences is interesting as pure combinatorics; this paper establishes surprising (to us) connections to the theory of tilings and logarithms, and to properties of cyclotomic fields.
Let k be fixed. This paper is concerned with establishing the asymptotic growth of f k (n). It is obvious that f k (n) ≤ 2 n 2 , as the concatenation of all length 2 sequences x, y with 0 ≤ x < y < n is a k-radius sequence. Moreover (see Section 2) it is not difficult to show that 1 k n 2 ≤ f k (n). So f k (n) seems to grow like n 2 , and we would like to determine the limit lim n→∞ f k (n)/ n 2 (if it exists).
Ghosh [7] proved that when n is odd, n 2 + n/2 when n is even.
Chee, Ling, Tan and Zhang [2] observed that the explicit upper bound derived by Jaromczyk and Lonc is poor for small parameter sets, and provide good constructions of 2-radius sequences when n is small. We modify the argument of Lonc and Jaromczyk to improve the error term in their estimates (see Section 4), showing that (1.2) f 2 (n) = 1 2 n 2 + O(n 1.525 ).
Moreover, we show that there are infinitely many values of n such that f 2 (n) = Turning to the case when k > 2, Jaromczyk and Lonc [11] show that f k (n) ≤ 1 2 (k + 1)/3 We show that whenever there exists a Z-tiling of Z π(k) by copies of a certain fixed cluster of k hypercubes (Theorem 6.2). In particular, the result holds for all k ≤ 204 except possibly k = 195, and the result holds whenever at least one of k + 1 or 2k + 1 is prime. For many of these values of k (including all values of k with 2k + 1 prime, or with k + 1 prime and 8|k) we are able to improve the error term in (1.3); moreover for these values of k we show that there are infinitely many values n such that The structure of the remainder of the paper is as follows. In §2 we establish simple lower bounds for f k (n), and recall some of the number-theoretic tools that we shall need later. We then describe a construction method (generalising that of [11]) that for a prime number p produces p-ary k-radius sequences via coverings of Z * p by arithmetic progressions. We use this to produce a tight upper bound for f 2 (p) (Theorem 4.1), and deduce (1.2).
In §5 we recall and develop the theory of logarithms (bijections from {1, . . . , k} to Z k such that f (ab) = f (a) + f (b) whenever all three function values are defined). We introduce the notion of a special KM-logarithm which imposes precisely the right parity conditions that we need for a later construction of k-radius sequences. We explain the relationship between logarithms and certain tilings of Z r (Theorem 5.3). We prove our main result (Theorem 6.2) in §6, that the existence of a suitable tiling implies the estimate (1.3); in particular, the existence of a logarithm of length k is enough for this estimate to hold.
In §7 we define the notion of a k-radius prime, and show that if n is a k-radius prime then we get the estimate (1.4) for f k (n) with best-possible main term and a good error term (Proposition 7.1). We establish a link with logarithms by showing that k-radius primes exist precisely when there is a special KM-logarithm of length k (Theorem 7.2). In §8 we derive the density of k-radius primes for any fixed k, and use this result to improve the error term in our estimate (1.3) for those values of k where a special KM-logarithm of length k exists. In §9 we illustrate the applicability of our constructions by computing lists of all k up to 300 for which there exist logarithms or special KM-logarithms. Finally, in §10, we discuss some of the various open problems that remain.

Preliminaries
This section contains some elementary lemmas on k-radius sequences, and briefly describes some of the notation and results from number theory we will use.

2.1.
Elementary results on k-radius sequences. Lemma 2.1. Let k, n and x be positive integers. Then Indeed, the inequality (ii) may be improved to Proof. The first inequality of the lemma follows since every k-radius sequence is a (k + 1)-radius sequence.
To establish the final inequality of the lemma, note that we may construct an n-ary k-radius sequence by taking the shortest (n + x)-ary k-radius sequence and deleting every occurrence of the x most common of the n + x alphabet symbols. The x most common symbols together occur at least (x/(n + x))f k (n + x) times, and so the final statement of the lemma follows. Lemma 2.2 (Jaromczyk and Lonc, [11]). For any positive integers k and n, Proof. Let a 1 , a 2 , . . . , a m be a k-radius sequence. The k-radius condition implies that every unordered pair of distinct alphabet symbols must occur at positions i and j in the sequence, where 1 ≤ i < j ≤ m and |i − j| ≤ k. The number of positions i, j where 1 ≤ i < j ≤ m and |i − j| ≤ k is strictly less than km, since there are m − 1 choices for i and once i is fixed there at most k choices for j. Hence km > n 2 , as required.
We remark that Jaromzcyk and Lonc [11] show that the linear term of this bound can be improved, by considering the elements at the start and end of the sequence in more detail; they use this technique to give an explicit improved lower bound in the case when k = 2.
2.2. Some number theory. We use various pieces of standard terminology and notation from number theory. We use Z n to denote the ring of integers modulo n, represented by the elements 0, 1, . . . , n − 1. The multiplicative group of invertible elements we denote Z * n , its order being given by the Euler totient function ϕ(n). The letter p will always indicate a prime number. We use a p for the Legendre symbol. A natural number n is said to be y-smooth if each prime p dividing n satisfies p ≤ y. The function π(a) counts the number of primes in the interval [1, a], and ω(n) denotes the number of distinct prime factors of n.
The following theorem will be useful in moving from estimates valid for primes p to general estimates for natural numbers n. Theorem 2.3 (Harman, [9], Theorem 10.8). Let a and s be coprime positive integers. Then for all sufficiently large n, there exists a prime p such that p ≡ a mod s and n ≤ p ≤ n + n 0.525 .

A construction
In this section, we describe a construction method that we shall use to derive our asymptotic results. The method is a straightforward generalisation of a construction of Jaromczyk and Lonc [11].
Let p be a prime number. For an element d ∈ Z * p , we define the set For any d ∈ Z * p , let s d be the periodic sequence (0, d, 2d, . . . , (p − 1)d, 0, d, . . . ) of period p. Note that distinct elements x, y ∈ Z p appear at distance k or less somewhere within s d if and only if y − x ∈ B k,p (d).
Theorem 3.1. Let D ⊆ Z * p have the property that the sets B k,p (d) where d ∈ D cover Z * p . Then there exists a p-ary k-radius sequence of length |D|(p + k − 1) + 1. Proof. Let D = {d 1 , d 2 , . . . , d u }, where u = |D|. Let t i be a finite sequence of length p + k consisting of p + k consecutive terms of the periodic sequence s di . For i ≥ 2, we choose the first element of t i to be equal to the final element of t i−1 . Note that the sequence t i contains all pairs (x, y) with y − x ∈ B k,p (d i ). The sequence t 1 t 2 · · · t u of length u(p+k) produced by concatenating the sequences t i is therefore a k-radius sequence, by the 'covering' property of D. But the final element of each sequence t i is equal to the first element of the sequence t i+1 , by our choice of the shift of s di for i ≥ 2. We may always replace any repeats in a k-radius sequence by single occurrences, to produce a shorter k-radius sequence. There are u − 1 places where we may do this in our construction, so we have a k-radius sequence of length u(p + k − 1) + 1, as required.

2-radius sequences
In this section, we establish bounds on f 2 (n). Our methods are similar to those of Jaromczyk and Lonc [11], but our slightly different approach gives a better error term than theirs. This section is a good introduction to our more general methods in later sections of the paper.
Proof. Suppose that is odd. Then the theorem follows by Theorem 3.1, provided that we can find a set of (p − 1)(1 + 1/ )/4 sets B 2,p (d) that cover Z * p . Let 2 be the multiplicative group generated by 2 in Z * p . Now Z * p is the disjoint union of the cosets of 2 : . . , t}, we find that t = (p − 1)/ . For any i ∈ {1, 2, . . . , t}, we have that −C i = C j for some j ∈ {1, 2, . . . , t}. Since is odd, −1 ∈ 2 and so i = j. So, by relabelling if necessary, we may assume that C 2s+1 = −C 2s for all s ∈ {1, 2, . . . , t/2}. Define for all s ∈ {1, 2, . . . , t/2}. Since d, 2d ∈ B 2,p (d) for any d ∈ Z * p , we see that the blocks B 2,p (d) with d ∈ D s cover C 2s . Since −d, −2d ∈ B 2,p (d), we see that the sets B 2,p (d) with d ∈ D s cover −C 2s = C 2s+1 . Hence we have a cover of Z * p of size (t/2)( + 1)/2. Since t = (p − 1)/ , we have a cover with the properties we require and so the theorem follows in this case. Now suppose that is even. This implies that 2 /2 = −1 in Z * p . Writing Z * p as the union (4.1) of the cosets of 2 , we see that we see that C i is covered by the /4 sets B 2,p (d) with d ∈ D i . Defining we have constructed a covering of Z * p consisting of t /4 sets B 2,p (d). Since t = (p − 1)/ , the theorem now follows by Theorem 3.1.  Proof. If p ≡ 5 mod 8, then 2 is a quadratic non-residue modulo p. The quadratic residues are exactly those elements of Z * p whose orders divide (p − 1)/2, and hence 4 must divide the order of 2. The corollary then follows by the final case of Theorem 4.1. Proof. When n is sufficiently large, Theorem 2.3 implies that there is a prime p such that p ≡ 5 mod 8 and n ≤ p ≤ n + n 0.525 . Since f 2 (n) ≤ f 2 (p) by Lemma 2.1, the upper bound of the corollary follows by Corollary 4.2. The lower bound follows by Lemma 2.2.

Logarithmic functions, logarithms and tilings
The results from Sections 3 and 4 indicate that good coverings (even better, tilings) of Z * p by sets of the form B k,p (d) will give rise to short k-radius sequences. This section defines the notion of a logarithm of length k, and explains how to use these logarithms to construct certain high-dimensional tilings. In Section 6, we will use these tilings to construct good coverings of Z * p , which in turn will produce short k-radius sequences.

Logarithmic functions and logarithms. Given
Logarithms are used to construct lattice tilings of n-dimensional space by semi-crosses; see Stein and Szabó [15,Chapter 3]. They also arise in group theory, number theory and coding theory; see Galovich and Stein [6], Forcade and Pollington [5], and Gordon [8].
Galovich and Stein [6] note that a logarithm of length k exists whenever either k +1 is prime or 2k +1 is prime. To see this when k +1 is prime, let α be a primitive root modulo k+1. Then the 'discrete logarithm' map, taking a ∈ {1, 2, . . . , k} to the element x ∈ Z k such that a ≡ α x mod k + 1, is a logarithm of length k. When 2k+1 is prime, let α be a primitive root modulo 2k + 1. Let g : {1, 2, . . . , k} → Z 2k be the map taking a ∈ {1, 2, . . . , k} to the element x ∈ Z 2k such that a ≡ α x mod 2k + 1. The composition of g with the natural surjection from Z 2k to Z k (sending x mod 2k to x mod k) is a logarithm of length k. Computations by Galovich and Stein [6], and later by Forcade and Pollington [5], show that logarithms are common for small values of k. In particular, their computations show that logarithms exist for all k with k ≤ 204, except 195. We have verified and extended Forcade and Pollington's computations; we report our results in Section 9.
Let p be a prime such that p ≡ 1 mod k, and let ζ be a primitive kth root of unity in Z * p . Let f be the map f : {1, 2, . . . , k} → Z k defined by the equation Then f is certainly a logarithmic function of length k. If f happens to be bijective, then f is a logarithm. We say (following Galovich and Stein [6]) that f is a Kummer-Mills-logarithm, or KM-logarithm, if it arises in this way for some prime p. (The Galovich-Stein definition for a KM-logarithm f is that f extends to a k-character Z * p → Z k . The relevant k-characters of Z * p , restricted to {1, . . . , k}, correspond precisely to the choices for our function f as ζ varies over the primitive kth roots of unity.) Theorem 5.1 (immediate from Theorem 3 of Mills [13]). Every logarithm of odd length k is a KM-logarithm. If k ≡ 2 mod 4 then a logarithm f of length k is a KMlogarithm if and only if f (m) is even whenever both m divides k and m ≡ 1 mod 4.
If k ≡ 0 mod 4, then a logarithm f is a KM-logarithm if and only if f (m) is even whenever m divides k/4. If f is a KM-logarithm of length k, then there are infinitely many primes p that exhibit f as a KM-logarithm.
A logarithm f of length k will be called a special KM-logarithm if either (i) k is odd, or (ii) k is even and f (m) is even whenever m divides k/2. Any special KMlogarithm is a KM-logarithm, and indeed unless k ≡ 2, 4, or 6 mod 8, the concepts of a KM-logarithm and a special KM-logarithm coincide. (For k odd this is clear. If 8|k and f is a KM-logarithm then from Theorem 5.1 we see that f (m) is even whenever m divides k/4. In particular this holds for prime values of m dividing k/4. Since 8|k, the primes dividing k/4 are the same as those dividing k/2. Hence f (m) is even for each prime m dividing k/2, and hence for all m dividing k/2. Thus f is a special KM-logarithm.) A special KM-logarithmic function will naturally be a logarithmic function that satisfies the parity conditions for being a special KM-logarithm, but need not be bijective.
Lemma 5.2. There are infinitely many k for which there is a special KM-logarithm of length k. Indeed we have: (i) if p = k +1 is prime and 8|k, then there is a special KM-logarithm of length k; (ii) if p = 2k + 1 is prime, then there is a special KM-logarithm of length k.
Proof. (i) For such p any KM-logarithm is a special KM-logarithm, and a discrete logarithm in Z * p is a KM-logarithm. (ii) Let f be a logarithm of length k induced by a discrete logarithm in Z * p . If k is odd, then we are done: f is a special KM-logarithm. If k is even, then p ≡ 1 mod 4, and hence for any odd prime q dividing k we have q p = p q = 1, and since k is even we conclude that f (q) must be even. If 4 | k then p ≡ 1 mod 8, so 2 p = 1, and hence f (2) must be even. We see that in all cases f is a special KM-logarithm.

Logarithms and tilings.
Let r be a positive integer, and let C ⊆ Z r be a finite set; we refer to C as a cluster. A Z-tiling of Z r by the cluster C is a set L ⊆ Z r of points such that the union x∈L (x + C) is a disjoint union and is equal to Z r . If L is an integer lattice of determinant k (i.e., L is a subgroup of Z r of index k), then L is a Z-tiling of Z r by C if and only if C is a set of coset representatives for L; in other words if and only if the natural map from Z r to the quotient Z r /L is bijective when restricted to C. The tiling terminology comes from imagining C as a set of r-dimensional unit hypercubes, indexed by the positions in Z r of their centres. A Z-tiling is then a tiling of R r by translates of C in the usual sense.
We now show how to use logarithms to produce certain tilings. Let q 1 , q 2 , . . . , q r be the primes in the set {1, 2, . . . , k}; so r = π(k). Let N 0 be the set of non-negative integers, and let C k be the cluster of points in Z r defined by We identify the points in C k with the integers 1, . . . , k.
Theorem 5.3. Let k be a fixed positive integer, let r = π(k) and define C k as above. If there exists a logarithm of length k, then there exists a Z-tiling of Z r by C k .
Proof. Let f be a logarithm of length k. Define a group homomorphism φ : so φ sends the jth standard basis vector to f (q j ). Define the lattice L ⊆ Z r to be the kernel of φ. By our remarks above, the union So the restriction of φ to C k is equal to f . Since f is a bijection, we have the tiling we require.

k-radius sequences
This section contains the main result of our paper: the leading term of f k (n) for infinitely many values of k (including all k ≤ 194). We need to establish a simple geometric lemma before we begin the proof.
For linearly independent vectors x 1 , x 2 , . . . , x r ∈ R r , we define the r-dimensional parallelotope P (x 1 , x 2 , . . . , x r ) to be the region Lemma 6.1. Let r be a fixed positive integer, and let δ be a positive real number. For any linearly independent vectors x 1 , x 2 , . . . , x r ∈ R r with |x 1 | ≤ |x 2 | ≤ · · · ≤ |x r |, let P be the parallelotope P = P (x 1 , x 2 , . . . , x r ), and let Q be the set of points in R r within a distance δ of P . Then where the implicit constant depends only on r and δ.
Proof. The parallelotope has a bounded number of proper subfaces F (it has r i 2 r−i subfaces of dimension i). For a proper subface F , define Q F to be the set of points v ∈ R r such that (i) v is within a distance δ of F , and (ii) the nearest point in F to v does not lie in a proper subface of F . Then where the union runs over all proper subfaces F of P . This decomposition in the case r = 2 is illustrated in Figure 1. Here, the parallelotope P (a parallelogram as we are in dimension 2) is in bold; the circles are the sets Q F when F has dimension 0 and the rectangles are Q F when F has dimension 1. This decomposition shows that It is not difficult to see that when Since the ball B r−i is contained in a hypercube with sides of length 2δ, we find that The lemma now follows by (6.1), since the number of terms in the sum in (6.1) is bounded.
Theorem 6.2. Let k be a fixed positive integer, and let r = π(k). Suppose there exists a Z-tiling L of Z r by C k (as defined by (5.1)). Then (Recall that such a tiling exists whenever there is a logarithm of length k, so in particular when k ≤ 194 or when either k + 1 or 2k + 1 is prime.) Proof. By (1.1) we may assume that k > 1. Let q 1 , q 2 , . . . , q r be the primes in the set {1, 2, . . . , k}, where q 1 = 2. Let p be any prime such that −1 p = −1 and qi p = 1 for all i ∈ {1, 2, . . . , r}. A sufficient condition for a prime p to satisfy these character constraints is that p ≡ −1 mod 8q 2 q 3 · · · q r , so by Theorem 2.3 we find that for all sufficiently large n there exists such a prime p with n ≤ p ≤ n+ n 0.525 . We aim to show that This suffices to prove the theorem, since we may then deduce that as required.
Recall the definition of the sets B k,p (d) from Section 3. We will establish the bound we require by constructing a good covering of Z * p by sets of the form B k,p (d) and then applying Theorem 3.1.
Define the subgroup H of the multiplicative group Z * p by H = q 1 , q 2 , . . . , q r . Define = |H|. We may write Z * p as the disjoint union of the cosets of H: Just as in the proof of Theorem 4.1, we note that |C i | = for all i ∈ {1, 2, . . . , t} and t = (p − 1)/ .
Since qi p = 1 for i ∈ {1, 2, . . . , r}, we see that H consists of quadratic residues modulo p and so all the elements in a coset share the same Legendre symbol. For any i ∈ {1, 2, . . . , t}, −C i = C j for some j ∈ {1, 2, . . . , t}. Since −1 p = −1, the Legendre symbols of the elements of C i have opposite sign to the Legendre symbols in C j , and so in particular i = j. Hence t is even and, by relabelling cosets if necessary, we may assume that C 2s+1 = −C 2s for all s ∈ {1, 2, . . . , t/2}.
as required. It remains to show the existence of the elements d 1 , d 2 , . . . , d w ∈ H with the properties we need. Let L ⊆ Z r be such that {z + C k : z ∈ L} is a Z-tiling of Z r . Let φ : Z r → H be the group homomorphism sending the ith standard basis vector of Z r to q i for i ∈ {1, 2, . . . , r}. Note that Z r is written additively but H is written multiplicatively, so φ(x + y) = φ(x)φ(y) for all x, y ∈ Z r . Also note that, using the definition of C k , φ(x + C k ) = A k,p φ(x) . Let K = ker φ, so K is a lattice. Since H is generated by q 1 , q 2 , . . . , q r , we see that φ is onto and so K has determinant . Let x 1 , x 2 , . . . , x r be a basis for this lattice. We may choose our basis such that r i=1 |x i | ≤ 2 r(r−1)/4 det(K) = 2 r(r−1)/4 , by LLL-reducing this basis if necessary; see Cohen [3, Section 2.6], for example. Moreover, by reordering the basis if needed, we may assume that |x 1 | ≤ |x 2 | ≤ · · · ≤ |x r |.
We claim that the shortest non-zero vector in K has length at least (log k p)/r, and so in particular |x 1 | ≥ (log k p)/r. To establish our claim, suppose that the vector (i 1 , i 2 , . . . , i r ) ∈ K has length less than (log k p)/r. We need to show that this vector is zero. Our bound on the length of the vector implies that |i j | < (log k p)/r for all j, and so r j=1 |i j | < log k p. Define non-negative integers i j and i j by But both the left hand side and right hand side of the equation above are integers bounded above by p. For example, So no modular reduction can have taken place in (6.2) and therefore i j = i j for j ∈ {1, 2, . . . , r}. This implies that i 1 = i 2 = · · · = i r = 0, and our claim follows.
Let R ⊆ Z r be defined by Since R is the intersection of Z r with a fundamental region of the lattice K, we see that φ(R) = H (indeed, the restriction of φ to R is bijective). Define W to be the set of translations z ∈ L in our tiling such that (z + C k ) ∩ R = ∅, and define w = |W |. We have that and since φ(z + C k ) = A k,p φ(z) we have a covering of H consisting of w sets of the form A k,p (d). To prove the theorem, it suffices to show that w ≤ ( /k) 1 + O(1/ log p) . Define C k to be the union of those unit hypercubes in Z r whose centres lie in C k . Let δ be the diameter of C k ; note that δ depends only on k. Now, R is contained in the parallelotope P = P (x 1 , x 2 , . . . , x r ) of volume . Define Q ⊆ R r to be the set of points within a distance δ of P . When z ∈ W , the set z + C k contains a point of R and so z + C k ⊆ Q. Since W ⊆ L and L is a Z-tiling of C k , the interiors of the sets z + C k with z ∈ W are disjoint, and so Vol r (Q) ≥ z∈W Vol r (x + C k ) = wk. However, Lemma 6.1 implies that as required.

k-radius primes
We now introduce the notion of a k-radius prime, and show that k-radius primes exist if and only if there exists a special KM-logarithm of length k. This allows us to prove (Corollary 7.3) an upper bound on f k (n) with a better error term than that of Theorem 6.2, provided we are willing to accept a bound for infinitely many values of n rather than for all values. In §8 we will determine the density of kradius primes, and this will allow us, for values of k where k-radius primes exist, to improve the error term in Theorem 6.2 without restricting n; see Theorem 8.4.
We say that a prime p is a k-radius prime if the following two conditions both hold: • p ≡ 1 mod 2k ; (7.1a) • the elements 1 (p−1)/k , 2 (p−1)/k , . . . , k (p−1)/k in Z * p are pairwise distinct. (7.1b) Note that z (p−1)/k is a k-th root of unity in Z * p for any z ∈ Z * p . So the condition (7.1b) is quite a strong one, as there are only k such roots of unity. We remark, for later use, that the congruence condition (7.1a) implies that (p − 1)/k is even. Proposition 7.1. Let p be a k-radius prime. Then there exists a p-ary k-radius sequence of length (p − 1)/2k (p + k − 1) + 1. In particular, when p is a k-radius prime.
The next theorem provides a connection between k-radius primes and special KM-logarithms. It shows us that for infinitely many values of k there exist kradius primes. In particular, if 2k + 1 is prime, or if k is divisible by 8 and k + 1 is prime, then there exist infinitely many k-radius primes.
Theorem 7.2. If there is a special KM-logarithm of length k, then there are infinitely many k-radius primes. Conversely, if there is a k-radius prime then there is a special KM-logarithm of length k.
If k is odd, then Theorem 5.1 gives infinitely many primes p ≡ 1 mod k satisfying the condition (7.1b), and with k odd these automatically satisfy the congruence condition (7.1a) too.
If k is even, then definef : {1, . . . , 2k} → Z 2k to be any logarithmic function that agrees with f modulo k on the primes between 2 and k. In particular, we then have thatf (a) ≡ f (a) mod k for 1 ≤ a ≤ k. Since f is a special KM-logarithm, the values off provide legitimate character values mod 2k for Theorem 5.1 to apply: there exist infinitely many primes p ≡ 1 (mod 2k) such that a (p−1)/2k ≡ zf (a) 2k mod p for 1 ≤ a ≤ k, where z 2k is some primitive 2k-th root of unity in Z * p . We certainly have the congruence condition (7.1a), but now we must check the condition (7.1b). Suppose that a (p−1)/k ≡ b (p−1)/k mod p. Then a (p−1)/2k ≡ ±b (p−1)/2k mod p, so zf Butf agrees with f mod k, and f is a logarithm, so we must have a = b.
Conversely, suppose that p is a k-radius prime, and let z k be a primitive k-th root of unity in Z * p . Define f : {1, . . . , k} → Z k by a (p−1)/k ≡ z f (a) k mod p. Then f is certainly a logarithm. We now use (7.1a) to proceed via quadratic reciprocity (as in the proof of Lemma 5.2) to verify that f is a special KM-logarithm.

The density of k-radius primes
We believe the notion of a k-radius prime is a very natural one. So it is of interest to determine the density of such primes; and this can be done, using some of the theory of cyclotomic field extensions. For technical background material, see [10]. As an application of our result on the density of k-radius primes, we improve the error term in Theorem 6.2 for values of k such that special KM-logarithms exist.
Theorem 8.1. Let k be a fixed positive integer, and let f spec (k) be the number of special KM-logarithms of length k. Let There exists a positive constant A k such that the number of k-radius primes less than or equal to x is as x → ∞, where the implied constant depends on k.
Heuristically the main term is clear: the fraction 1/ϕ(2k) gives the proportion of primes satisfying (7.1a); the remaining fraction gives the proportion of special KM-logarithmic functions that are special KM-logarithms (when k is even, the parity constraint on each prime dividing k/2 means that the number of special KM-logarithmic functions is only k π(k) /2 ω(k/2) rather than k π(k) ). We shall make use of a theorem of Elliott [4,Theorem 1]. See also [12] for a discussion of similar density results, some of these conditional on the generalized Riemann Hypothesis.
Proof. Suppose first that k is odd. Let ζ k = exp(2πi/k). We work in the cyclotomic field Q(ζ k ), and associate any logarithmic function f : {1, . . . , k} → Z k with the vector ε f = (ζ ). If p ≡ 1 mod k, then p splits completely in Q(ζ k ) as a product of ϕ(k) degree-1 prime ideals. Apart from a finite number of ramified primes, all degree-1 prime ideals in Q(ζ k ) arise in this way. For any degree-d prime ideal p, the k-th power residue symbol β p k is defined for β ∈ Z[ζ k ] to be zero if p | β, and otherwise is the unique power of ζ k that is congruent to β (p d −1)/k mod p. We can associate to any prime ideal p the vector ε p = 1 p k , . . . , k p k . Let S be the finite set of all vectors that arise as ε p for some degree-1 prime ideal p dividing a rational unramified prime p. For a degree-1 prime ideal p dividing p ≡ 1 mod k, we observe that the powers of ζ k appearing in ε p correspond to the powers of some primitive kth root of unity modulo p that appear in the sequence in (7.1b). The different prime ideals dividing p correspond to different choices of the kth root of unity. For condition (7.1b) to hold we require the entries of ε p to be distinct.
Given any vector ε = (ε 1 , . . . , ε k ) whose entries are powers of ζ k , Elliott's theorem [4,Theorem 1] gives an asymptotic estimate for the number of prime ideals p with norm less than or equal to x such that ε p = ε, namely and where the sum in (8.2) is over all 1 ≤ ν 1 , . . . , ν k ≤ k such that 1 ν1 · · · k ν k = β k for some β ∈ Z[ζ k ]. Since the number of prime ideals of degree greater than 1 and  Table 1. Predicted and observed (primes up to 10 8 ) densities of k-radius primes norm less than or equal to x is dominated by the error term in this estimate, we have the same asymptotic formula if we restrict to degree-1 prime ideals. Now we observe that if ε = ε p is in S, then for each term in (8.2) we have Hence each ε ∈ S gives us the same main term in the asymptotic estimate for the number of degree-1 prime ideals of norm less than or equal to x such that ε p = ε, and with the same form for the error term. Now Mills' thoerem [13, Theorem 3] tells us that the ε ∈ S are precisely those that correspond to (special KM-) logarithmic functions (as we are assuming k is odd there are no parity constraints), hence amongst all degree-1 prime ideals the proportion that yield special KM-logarithms (corresponding to k-radius primes) is precisely f spec (k)/k π(k) . For k even there are a few twists, but essentially the same argument works. We now work in Q(ζ 2k ). For each special KM-logarithmic function f : {1, . . . , k} → Z k we associate a set of 2 π(k) vectors (ε 1 , . . . , ε k ), where each ε i is a power of ζ 2k such that for primes q between 1 and k we have either ε q = ζ f (q) 2k 2k , extended logarithmically to all other ε j . The parity conditions for f being a special KM-logarithmic function are precisely those needed for Mills' theorem to tell us that for any of these 2 π(k) vectors ε there exist infinitely many degree-1 prime ideals p ∈ Q(ζ 2k ) such that ε = ε p = . Bearing in mind these parity conditions, we have 2 π(k) k π(k) /2 ω(k/2) vectors associated to special KM-logarithmic functions, and the proportion of degree-1 prime ideals that correspond to special KM-logarithms is f spec (k)2 ω(k/2) /k π(k) . The rest of the argument proceeds as before, using N (2k, k) rather than N (k, k) (the ν j run between 1 and 2k).
The proportion of all primes less than or equal to x that are kradius primes is c k , defined by (8.1).
To illustrate this corollary, Table 1 compares the predicted densities with the proportion of k-radius primes observed for primes up to 10 8 and k ≤ 10.
Corollary 8.3. If f spec (k) > 0, then with A k as in Theorem 8.1 there is a k-radius prime between n and n + O n log n exp(−A k √ log n) .
Proof. From Theorem 8.1 we have that the number of k-radius primes between n and n + g (with 1 ≤ g ≤ n) is This is strictly positive provided that the main term c k n+g log(n+g) − n log n is strictly larger than the absolute value of the error term. This main term is asymptotic to c k g/ log n as n → ∞, so with g larger than some constant multiple of n log n exp(−A k √ log n) we are assured of a k-radius prime between n and n+g. We remark that this improves the bound of Theorem 6.2 for those values of k where a special KM-logarithm exists, since exp(A k √ log n) grows faster than (log n) 2 .
Proof. Let p be the smallest k-radius prime such that n ≤ p.
as required.

Computational results
In this section, we present our computational results. We begin by describing the techniques we used to design an efficient search for logarithms, and to enumerate them. We then describe the results themselves. 9.1. Finding logarithms. Let q 1 < · · · < q r be the primes in {1, . . . , k}. A logarithmic function f of length k is uniquely determined by the values of f (q 1 ), . . . , f (q r ), which can be chosen independently, so there are k π(k) = k r of them.
Let V = Z k k be the set of all vectors of length k, with components in Z k . We can conveniently represent any logarithmic function f of length k as the element Logarithms are bijective logarithmic functions, so a naive strategy would be to search over all k r logarithmic functions. Forcade and Pollington [5] observed that it is sufficient to search over all possibilities for f (q i ) with q i ≤ k/2. Once these values are fixed, f is determined on all (k/2)-smooth numbers in {1, 2, . . . , k}.
If the resulting partial function is injective with image X, then f may always be completed to a logarithm by assigning the remaining values of f (q i ) for q i > k/2 to be an arbitrary permutation of Z k \ X. This trick reduces the size of our search from k π(k) to k π(k/2) . Another way of thinking of this is as follows. We partition the set of logarithmic functions into parts; two functions are in the same part if and only if they agree on q i for q i ≤ k/2. We search over parts rather than logarithmic functions. Each part contains π(k) − π(k/2) ! logarithms if the appropriate partial function is injective, otherwise the part contains no logarithms. In our computations, we made use of a generalisation of this, which we now describe.
Partition the primes q 1 , . . . , q r into blocks B 1 , . . . , B t in following way. Any prime ≤ √ k appears on its own in a block of size 1. Primes q in the interval ( √ k, k] are grouped together in blocks according to the value of such that k/( + 1) < q ≤ k/ . Observe that if π is a permutation of {1, . . . , r} that induces a permutation of each block, and f = r i=1 a i e i is a logarithm, then so is r i=1 a π(i) e i . Logarithms that are related in this way we call combinatorially equivalent.
If f is a logarithm of length k, then so is af for any a ∈ Z * k . Two logarithms f and g will be called linearly equivalent if f = ag for some a ∈ Z * k . Two logarithms f and g will be deemed equivalent if there is a logarithm h such that f is combinatorially equivalent to h and h is linearly equivalent to g. For finding and counting logarithms it is extremely useful to work up to equivalence.
We remark that a small modification of this technique works when counting KM-logarithms or special KM-logarithms. If f is a KM-logarithm (or a special KM-logarithm), then so is af for any a ∈ Z * k , for if k is odd then there are no parity conditions to check, whilst if k is even then a must be odd, and the parity of af (j) (reduced modulo even k) is the same as the parity of f (j). When dealing with special KM-logarithms or KM-logarithms, any primes dividing k must be put in singleton blocks. Since for simple logarithms the only primes q in blocks of size greater than 1 satisfy q > √ k, there is at most one block that is affected by this change, having one of its primes removed to a singleton block.
Given k, our search for a logarithm f proceeds by attempting to assign values for f (q 1 ), . . . , f (q r ) in that order. Having found compatible values for f (q 1 ), . . . , f (q j−1 ) and having computed v j−1 = i≤j−1 f (q i )e i , we consider each possibility for f (q j ) in turn: the vector v j = v j−1 + f (q j )e j is computed; the q j -smooth components of v j are extracted (using a precomputed list of q j -smooth numbers), sorted, and checked for repeats; if a repeat is found then the next value of f (q j ) is tried, backtracking once all possibilities are exhausted; if no repeat is found then j is increased.
The backtracking makes use of equivalence. Within each block {q i1 , . . . , q it } of primes, we constrain the values of the logarithms to satisfy f (q i1 ) < · · · < f (q it ). Linear equivalence is exploited by insisting that f (2) | k, and restricting values of f (3) so that there does not exist a with gcd(a, k) = 1 and af (2) ≡ f (2) mod k such that af (3) mod k is smaller than f (3).
For computing KM-logarithms and special KM-logarithms, the parity conditions are checked on q j -smooth numbers before accepting the legitimacy of f (q j ).

Counting logarithms.
To count the total number of logarithms (or KMlogarithms, or special KM-logarithms) of length k, we need to know the size of each equivalence class, and how many representatives of each class appear in the output of our algorithm (now not terminating when a logarithm is found, but continuing to search the entire space of logarithmic functions). If f is a logarithm, scaled so that f (2) | k, then the number of a ∈ Z * k such that af (2) ≡ f (2) mod k equals the number of a ∈ Z * k with a ≡ 1 mod (k/f (2)), which is the size of the kernel of 9.3. Results and comments. We write f log (k) for the number of logarithms of length k, and f spec (k) for the number of special KM-logarithms. Table 2 shows f log (k) and f spec (k) for small values of k. Table 2 shows that logarithms of length k are common when k is small. This entire table took just a few minutes to compute. However, logarithms of length k do not always exist: Forcade and Pollington [5]   Evidence from the enumeration in Table 2, together with heuristic combinatorial considerations, seem to point towards logarithms of length k being common when k is prime. However, this is not the case in general: the smallest prime k for which there is no logarithm is k = 211.
The largest known k for which there exists a logarithm without either k + 1 or 2k + 1 being prime is k = 277. For k above 200, these 'sporadic' logarithms appear to be increasingly rare: k = 201, 202, 203, 206, 207, 213, 223, 225, 234, 236, 237, 241, 272, 277. (Could it possibly be the case that the only large values of k such that logarithms exist are when k + 1 or 2k + 1 is prime?) To illustrate our output, we present the values of a logarithm of length 277: it is enough to give the values at primes below k/2 (which determine the values at all (k/2)-smooth numbers up to k), as the values at remaining primes below k may be assigned the missing logarithm values in any order. The bold numbers in Table 3 indicate the start of each of the blocks of primes; within each block, the logarithm values are seen to increase.

Open problems
The big open question 1 for the asymptotics of k-radius sequences is the following: Open Problem 1. For any fixed k, determine lim n→∞ f k (n)/ n 2 (if it exists). The results in this paper show that 1/k ≤ f k (n)/ n 2 ≤ 1/ k + o(k) for sufficiently large n, but is it the case that lim n→∞ f k (n)/ n 2 = 1/k? In particular, is it the case that lim n→∞ f 195 (n)/ n 2 = 1/195? Our results say that this limit (if it exists) lies in the interval [1/195, 1/194]. It is not difficult to see that whenever there exists a covering of Z π(195) by translated copies of C 195 with density 1 + , 1 Recent work by the first author has used probabilistic methods to prove that this limit exists and equals 1/k. However the problem of explicitly constructing asymptotically good k-radius sequences for all k remains open. then the limit is at most (1 + )/195. So one approach to determining this limit might be to find good coverings of Z π(195) by copies of C 195 .
Open Problem 2. Determine the set of integers k such that there exists a logarithm of length k.
Is it the case that for all sufficiently large k, logarithms exist if and only if either k + 1 or 2k + 1 is prime? If this is not true, is it the case that the set of integers k such that there exists a logarithm of length k has density zero? Our computer searches for logarithms suggest this is very possible. In particular, is there an infinite sequence of integers k such that no logarithms of length k exist? We believe this is very likely, and give a heuristic argument below.
Let M k be the largest size of the image of a logarithmic function from {1, . . . , k} to Z k , and let R k ≤ k be maximal such that there exists a logarithmic function from {1, . . . , k} to Z k whose restriction to R k -smooth elements is injective. Thus a logarithm exists if and and only if M k = R k = k, and when a logarithm does not exist the numbers M k and R k give natural measures of failure.
Open Problem 3. Investigate M k and R k .
We have that lim sup k→∞ M k /k = lim sup k→∞ R k /k = 1. Is it the case that lim inf k→∞ M k /k = lim inf k→∞ R k /k = 0? We give a heuristic argument for R k (with thanks to Carl Pomerance for suggesting this line of reasoning). Fix small > 0. Let ψ(x, y) denote the number of y-smooth numbers below x. With u = log x/ log y we shall use repeatedly the estimate ψ(x, y) = xu −u+o(u) , uniformly as u → ∞ with u < (1 − ) log x/ log log x [1]. Let the rth prime be q r , and for a logarithm f of length k, let f r be the restriction of f to the q r -smooth numbers between 1 and k. Suppose we have a possibility for f r , with q r ≈ exp( √ log k). We have therefore used up ψ(k, q r ) of the elements of Z k as values of f on q rsmooth numbers. If we assume suitably random behaviour, the expected number of possibilities for f r+1 that extend f r is bounded above by k 1 − ψ(k, q r )/k ψ(k/qr+1,qr+1) , since there are ψ(k/q r+1 , q r+1 ) numbers between 1 and k that are q r+1 -smooth but not q r -smooth. Now with u = log k/ log q r ∼ √ log k we have ψ(k, q r ) = ku −u+o(u) ≥ k 1− for all large enough k; and with v = log(k/q r+1 )/ √ log k ∼ √ log k we have ψ(k/q r+1 , q r+1 ) = kv −v+o(v) /q r+1 ≥ k 1− for all large enough k. Thus a heuristic upper bound for the expected number of possibilities for f r+1 (given f r ) is k(1 − k − ) k 1− . Since there are O(k r ) = O(k exp( √ log k) ) possibilities for f r , our heuristic bound for the number of possibilities for f , summed over all k ≥ k 0 , tends to 0 as k 0 → ∞. Without some structural reason (such as k + 1 being prime), this suggests that only finitely many k would achieve R k as large as exp( √ log k) (and indeed this bound could heuristically be reduced still further).
Computations show that M k = k for k ≤ 194, and we computed further that M k ≥ k − 1 for k ≤ 257, but that M 258 = 256. primes in arithmetic progressions, and thank Glyn Harman, Carl Pomerance and Igor Shparlinski for other helpful comments. Finally we thank the referee for a careful reading of the paper and for several helpful suggestions.