A circulant matrix of order is an matrix whose elements depend only on . Thus, an circulant is a matrix of the form
. Circulants arise in various applications in signal processing and combinatorics, and have a close connection with Fourier transforms. The set of all circulants of order(with elements in some fixed ring ) form a commutative algebra, since the sum and product of two circulants is a circulant, and it is easy to see that multiplication of circulants is commutative.
We write for the circulant whose first row is .
By a binary matrix we mean a matrix whose elements are in one of the sets or . It will be clear from the context which of these two cases is being considered. A binary circulant is a circulant matrix whose elements are in or .
There is a natural correspondence between the integers and the binary circulant matrices of order . If has the representation
so may be written in binary as , we associate with , where in the case of , and in the case of .
The maximal determinant problem is concerned with the maximal value of for an binary matrix . The Hadamard bound  states that, in the case of binary matrices over , we have
There is a well-known connection between the determinants of -matrices of order and -matrices of order . This implies that an -matrix always has determinant divisible by . See Neubauer and Radcliffe  for details. We give an example with , starting with an binary matrix and ending with an -matrix , with .
The doubling step is the only step where the determinant changes, and there it is multiplied by .
Thus, Hadamard’s bound (1) gives the bound
which applies for all -matrices of order . We shall refer to both (1) and (2) as Hadamard’s inequality, since it will be clear from the context which inequality is intended.111In fact, Hadamard in  proved a more general inequality than (1), and as far as we are aware he never stated (2) explicitly. A simple proof of (1) is given by Cameron .
The mapping from -matrices to -matrices is reversible if we are allowed to normalize the first row and column of the -matrix by changing the signs of rows/columns as necessary.
The transformation illustrated above (or its reverse) does not preserve any circulant structure.
Hadamard matrices are square matrices with entries in and mutually orthogonal rows. The order of a Hadamard matrix is , , or a multiple of . It is not known whether a Hadamard matrix of order exists for every positive integer — this is the Hadamard conjecture.
Various constructions for Hadamard matrices use circulant matrices. For example, the first Paley construction (Paley ) uses a circulant matrix of order , where is a prime, , to construct a Hadamard matrix of order . (The Paley construction also works for prime powers, e.g., , but does not involve circulants in such cases.) Fletcher, Gysin and Seberry  use two circulants and a border of width two to construct Hadamard matrices. The Williamson construction (Williamson ) requires four matrices which satisfy certain conditions, and for computational reasons these matrices are usually taken to be circulants.
Circulant matrices also play an important role in noisy convolutional Gaussian channels. Given a channel in which the output vector is given by the convolution of the input vector with a chosen mask vector, in the presence of additive Gaussian noise, the choice of mask that maximizes the mutual information of the channel in high-SNR regimes is the first row of a-circulant with near-flat Fourier spectrum, and this circulant is often one with maximal or close to maximal determinant. This has important applications in X-ray and gamma ray astronomy, optics, and computational imaging [1, 2, 11, 15, 25, 42].
It is well-known that the (unnormalized) eigenvectors ofare given by , , where is a primitive -th root of unity. For example, in we can take
. It follows that the eigenvalues are
and the determinant is
The polynomial is called the associated polynomial of the circulant. Also, is called a Littlewood polynomial if the coefficients , and a Newman polynomial if the and .
If is nonsingular, then (4) gives
This may be regarded as a discrete analogue of the Mahler measure 
Using (4) to compute for a circulant matrix takes arithmetic operations, whereas Gaussian elimination does not take advantage of the circulant structure and takes of order operations. If we are considering binary matrices, whose determinants are integers, it is necessary to perform the operations in to sufficient precision to obtain a result with absolute error less than , so that the correct result can be found by rounding to the nearest integer. From the Hadamard bounds (1)–(2), this means that we may have to work with of order bits of precision.
To avoid the problem of rounding errors altogether, we can work over a finite field. If is a prime such that , and is a primitive root (mod ), then222It is not necessary to know a primitive root (mod ). We can choose a random , compute , and check if are distinct (mod ). If not, reject and repeat with another random . In this way we work in a (small) group of order , instead of a (large) group of order , and there is no need to factor . The expected number of iterations is .
is a primitive -th root of unity in the finite field , and we can use (4) to compute . If is an upper bound on , and , then the result is sufficient to determine . Thus, if we use a Hadamard bound for , the prime should have of order bits. Alternatively, we could use several smaller primes with a sufficiently large product, and reconstruct the result using the Chinese Remainder Theorem.333Tests indicate that, at least for , it is faster to use a single prime. One reason for this is that the value needs to be reconstructed for each circulant , so the cost of the reconstruction steps is not negligible.
2 Lyndon words and necklaces
The usual definition of a Lyndon word is a nonempty string that is strictly smaller in lexicographic order than all of its proper rotations. Thus, the first six Lyndon words over are , , , , , and . Lyndon words were introduced by Shirshov  (who called them “regular words”) and Lyndon  (who called them “standard lexicographic sequences”).
Since we consider words of a fixed length , it is convenient to use the concept of a (binary) necklace. We say that is a necklace of length if is not larger (in the lexicographic order) than any of its rotations. This corresponds to Duval’s “representative of a class of words of length ” [12, (3) on p. 258], where two words are said to be in the same class if one is a rotation of the other.
For example, according to our definition, the six necklaces of length over are , , , , , and . It can be seen that, if we strip off leading zeros, we obtain the first six Lyndon words. Thus, the concepts of “Lyndon word” and “necklace” are closely related, and algorithms for one may often by modified to apply to the other.
The number of necklaces of length over a binary alphabet is
where is Euler’s phi function. is tabulated in OEIS A000031.
If is a circulant, then is invariant under rotations of the first row . Thus, when searching for circulants of order with maximal determinants, it is sufficient to consider circulants whose first row is a necklace of length . From (5), this saves a factor of approximately .
In our computations we use two nontrivial algorithms related to Lyndon words/necklaces. One is the algorithm of Booth , which determines in linear time if a word is in fact a necklace.444We use a simplified version of Booth’s algorithm since we do not need to know the rotation that would convert into a necklace.
Booth’s algorithm is closely related to the initial phase of the Knuth, Morris and Pratt fast pattern-matching algorithm.
The other algorithm that we use is Duval’s algorithm  which, given a necklace of length , returns the next necklace (of length ) in lexicographic order555Duval’s paper  considers Lyndon words but, using [12, comment (3) on p. 258], we easily get a similar algorithm for necklaces., in amortized (i.e., average) constant time, see . Using Duval’s algorithm we can cycle through all necklaces of length in time .
Other algorithms could be used. For example, Shiloach  gives an algorithm that reduces the number of comparisons used by Booth’s algorithm. We used Booth’s algorithm because it was sufficient for our purposes, and simpler to implement than Shiloach’s algorithm. The overall complexity of our algorithms is dominated by the time required to evaluate determinants using (4), not by the time required to check or enumerate necklaces.
3 Fast evaluation of circulant determinants
Standard algorithms of linear algebra, such as Gaussian elimination, require of order operations to evaluate the determinant of an matrix . Using formula (4), this can be reduced to order if is a circulant. In fact, using the fast Fourier transform (FFT), operations suffice.
However, in our application we can do even better. Because Duval’s algorithm takes constant time (on average), the number of symbols that are changed as we go from one necklace to the next is on average.666We find experimentally that the mean number of symbols changed is as . The limiting value is the same as the mean number of bits changed when counting up in binary. Thus, each value given by (3) can be updated in operations (on average), and the determinant, given by (4), can be updated with operations (on average). Since there are necklaces of length , the computation of all the relevant determinants can be done with operations. The cost of precomputing a table of powers is negligible.
Note that we used the term “operations” rather than “time”, because the arithmetic operations need to be performed using of order bits of precision, as noted above. Thus, the overall complexity is , where is the time required to multiply -bit numbers.
In theory, a slightly better complexity can be attained by using several small primes and reconstructing the result via the Chinese Remainder Theorem. However, the cost of reconstructions must be taken into account. In practice, is never large, because of the exponentially growing factor in the complexity, so the difference between the two approaches is essentially an implementation-dependent constant factor.
4 Parallel algorithms
Suppose we wish to use processors in parallel. If the necklaces of length are , we would like processor () to compute the determinants corresponding (approximately) to necklaces . The problem is how to determine the starting point for processor , without enumerating . Kociumaka et al.  sketch a deterministic polynomial-time algorithm for this problem, but it is very complicated. We used a simpler, randomized algorithm.777A similar algorithm, although not specifically intended for parallel computation, is described by Briggs and Ying . For related references, see Ghosh and Pasupathy .
The idea is to take a random sample of necklaces, each of length . Sort the sample, and then divide it into equal-sized segments. Modify the initial segment to start with and the final segment to end with . Thus, each processor has approximately words to process. Also, we know the necklace starting each segment, so we can use Duval’s algorithm to enumerate all necklaces in a segment.
How large does the sample size need to be? Suppose the procedure just described gives the -th processor necklaces to process, where and . Define by , so measures the relative difference between and the mean . Using extreme-value theory it can be shown that, as , we have
Simulations show that (6) gives a reasonable approximation even for small , provided . Thus, for a given (one-sided) tolerance , we should take
With this choice888In fact, our program used simply , equivalent to taking in (7). We had , so . of we can expect that, on average, the slowest processor will take only about times as long as the average processor.999This ignores any random variations in speed due to other users in a shared multi-processor computer system. In practice such variations may be larger than the variations caused by random sampling.
We now describe how to randomly and uniformly sample the set of all necklaces of length . Generate a random binary string of length , and test (using Booth’s algorithm) if it corresponds to a necklace. If so, accept the string. Otherwise, reject the string and try again.101010It is not sufficient to rotate the string until we obtain a necklace. This would not give each necklace an equal probability of selection. Consider, for example, the case , where the three necklaces , , and would be selected with probabilities , , and respectively. This process is repeated until we have the desired number
of necklaces (not necessarily distinct). Clearly each necklace is equally likely to appear in the final list. Since the probability of a random binary string of lengthbeing a necklace is , the expected number of random binary strings that are needed is . The algorithm that we have described is an example of Von Neumann’s rejection method . Other examples may be found in Devroye’s book .
For we can speed up the generation of random necklaces, if we exclude the special cases and , and take advantage of the fact that all other necklaces have the form , where .
5 Computational results
Our computations extend some entries in the OEIS . Tables 1–2 give computational results for the maximal determinants of -circulants of orders . The third column of each table gives the ratio , where is the maximum of for -circulants of order , and is an upper bound on .
Similarly, Tables 3–4 give computational results for the maximal determinants of -circulants of orders . Here the third column is the ratio , where is an upper bound on . In Tables 3–4 we scale the determinants of -circulants by dividing by the known factor . In the last column of Table 3, “” and “” are used as abbreviations for and respectively.
The bounds and are defined as follows. Let
Then is an upper bound on for -matrices of order . The case is due to Hadamard ; the case is due to Ehlich  and Wojtas ; and the remaining case (odd) is due to Barba , Ehlich , and Wojtas . We do not use Ehlich’s slightly sharper, but more complicated, bound that applies when . For this bound, see Ehlich  or Orrick .
In view of the discussion in §1, we take
It is an open question whether attains the bound for any . (If we restrict attention to the cases , this is the circulant Hadamard problem.) On the other hand, for all primes . This follows from the first Paley construction , which constructs a Hadamard matrix of order with a circulant submatrix of order . Inspection of Tables 1–2 reveals that in some other cases, specifically .
Table 2 extends the list of values given for in OEIS A086432 and the associated b-file. Table 4 extends the list of values given for in OEIS A215897. This implies a corresponding extension for OEIS A215723, which lists the unscaled values .
As an indication of the time required to compute the tables, we note that the computation of using our parallel program (implemented in C using GMP ) took processor-years using 128 Intel Xeon3 (2.2GHz) and 224 Xeon4 (2.6GHz) processors. The computation time for order was roughly proportional to .
For verification, all the values given in the tables for orders were computed at least twice, using different programs and/or different prime moduli . No discrepancies were found.
6 Conjecture A
From the third column of Table 1, the determinant of a -circulant can attain the upper bound in the cases . The Paley construction explains this for , and larger cases where is a prime and . However, it does not explain the case . Also, the upper bound is not attained for . Thus, a plausible conjecture is that the upper bound can be attained whenever is the product of at most two distinct primes. Support is provided by the computation for , since .
Our computation for disproves this conjecture, since is a product of two distinct primes, but . Another counter-example is . We find that .
After our computations were completed, we found an explanation for the cases and . In each case has the form , where and are both prime. Such are covered by case (2) of the following theorem, which we quote (with a change in notation) from Kotsireas et al. . Note that a “circulant core” of order refers to a -circulant matrix of order which can be used to construct a Hadamard matrix of order using the correspondence between -matrices and -matrices described in §1.
Theorem 1 (Hadamard circulant core construction).
A Hadamard matrix of order with circulant core of order exists if
is a prime;
, where and are prime;
, where is a positive integer; or
, where is a positive integer and is a prime.
Hall [21, p. ] remarks that case (4) is subsumed by case (1), since , but we mention case (4) since Hall’s construction is different from that of Paley.
We do not know if the list given by Theorem 1 is exhaustive. The computational results given in Tables 1–2 show that, for , only those given by Theorem 1 can provide a Hadamard matrix of order with a circulant core. Also, a circulant -matrix of order can achieve the upper bound (10) if and only if or satisfies condition (1), (2) or (3) of Theorem 1.
7 Conjecture B, case
When considering maximal determinants of matrices with real elements in the interval , we can see that the maximum occurs at extreme points of the polytope.111111This is already implicit in Hadamard . To prove this, we need only note that the determinant of a square matrix is a linear function of each variable considered separately. Thus, if a local maximum of occurs for some , we can replace by (at least one of) or without decreasing .
This argument does not apply if is restricted to be a circulant of order , because then the free parameters are just the elements of the first row of , and is not a linear function of each considered separately. For example, if we have . Nevertheless, inspection of small cases suggests the conjecture that the maximum of occurs at extreme points of the -dimensional polytope.
We were unable to prove the conjecture, so wrote a program to check it numerically, and found that, in general, the conjecture is false.
The idea is as follows. Consider all possible circulants of order with entries in . If , check if a small perturbation of towards the interior of the polytope would increase . Although such behaviour is rare, it does occur.121212For reasons of efficiency, our program takes as input a list (generated during the computation of Tables 1–2) of necklaces that define circulants with maximal , then considers all possible rotations of these circulants.
The smallest examples occur for . Consider with . We have , but . If for some small , then , so for sufficiently small . In fact, .
For , an example is , . Replacing by , we obtain .
We found examples of such behaviour for , and no other up to the limit of Table 2. However, there is a different class of examples that occur when is a prime, e.g., , etc. For this class we make a small modification to the Uniformly Redundant Arrays (URAs) of [8, 15], which are equivalent to Abelian difference sets .131313Our construction is also close to the “modified” URAs (MURAs) of . Define
where is a quadratic character, defined by the Legendre symbol
Then corresponds to a -D URA, but is not generally maximal in the class of circulant determinants. However, may be larger than the corresponding entry in Tables 1–2. It may be shown141414The proof uses the identity . that, for an odd prime,
In particular, , , and
We observe that the maximum of for is not at . One can show, by logarithmic differentiation of (11), that a local maximum occurs at
For example, if , we have , and
8 Conjecture B, case
The case is trivial because, for circulants of order over , we necessarily have at the extreme points .
The other cases are non-trivial. For example, if , consider
We find that
so sufficiently small gives . Indeed, we can take , as .
If , we find that
so in both cases a sufficiently small disproves the conjecture. A different type of exceptional case is illustrated by
where we find that is an even polynomial in , and
Similarly, for order , consider
Since (see Table 3), we have .
9 Remarks on periodic autocorrelations
It is hard to discern a pattern in the lex-least words given in Tables 1–4. It seems more fruitful to consider the periodic autocorrelations of the first rows of the corresponding circulants. Equivalently, we can consider the first rows of the Gram matrices , where is the relevant circulant.
In the case of -circulants, it can be useful to map , and consider the first row of . Provided , the upper bound is achieved in Tables 1–2 if and only if the first row of is . See, for example, MacWilliams and Sloane .
In some cases the maximal determinants given in Tables 1–4 have only small prime factors. For example, the entry for in Table 4 factors as , and this can be explained if we observe that the first row of is . Thus, we can write , where is the “circular shift” matrix. Similarly, the entry for in Table 4 is , and here .
We thank Jörg Arndt for correcting our terminology, Alex Arkhipov for his helpful comments about Hadamard matrices with circulant cores and related group theory, and the authors of Magma  and GMP  for their invaluable software. An anonymous referee helped us to clarify several points in §2 and §4. Computing resources were provided by the Australian National University and the University of Newcastle (Australia). The first author was supported in part by Australian Research Council grant DP140101417.
-  J. G. Ables, Fourier transform photography: a new method for X-ray astronomy, Proc. Astron. Soc. Austral. 1 (1968), 172–173.
-  M. S. Asif, A. Ayremlou, A. Sankaranarayanan, A. Veeraraghavan, and R. Baraniuk, Flatcam: Thin, bare-sensor cameras using coded aperture and computation, IEEE Trans. Comput. Imaging, to appear. Preprint, 2015, http://arxiv.org/abs/1509.00116.
-  G. Barba, Intorno al teorema di Hadamard sui determinanti a valore massimo, Giorn. Mat. Battaglini 71 (1933), 70–86.
-  J. Berstel and M. Pocchiola, Average cost of Duval’s algorithm for generating Lyndon words, Theoret. Comput. Sci. 132 (1994), 415–425.
-  K. S. Booth, Lexicographically least circular substrings, Inform. Process. Lett. 10 (1980), 240–242.
-  W. Bosma, J. Cannon, and C. Playoust, The Magma algebra system. I. The user language, J. Symbolic Comput. 24 (1997), 235–265.
-  54, 1 (Feb. 2018), 26–29.
-  A. Busboom, H. Elders-Boll, and H. D. Schotten, Uniformly redundant arrays, Experimental Astronomy 8 (1998), 97–123.
-  P. J. Cameron, Hadamard Matrices, in Encyclopaedia of Design Theory, Queen Mary, University of London, 2006. http://www.maths.qmul.ac.uk/~lsoicher/designtheory.org/%library/encyc/topics/.
-  L. Devroye, Non-Uniform Random Variate Generation, Springer-Verlag, New York, 1986, §II.3 Available from http://luc.devroye.org/rnbookindex.html.
-  R. H. Dicke, Scatter-hole cameras for X-rays and gamma rays, Astrophys. J. 153 (1968), L101–L106.
-  J.-P. Duval, Génération d’une section des classes de conjugaison et arbre des mots de Lyndon de longueur bornée, Theoret. Comput. Sci. 60 (1988), 255–383.
-  H. Ehlich, Determinantenabschätzungen für binäre Matrizen, Math. Z. 83 (1964), 123–132.
-  H. Ehlich, Determinantenabschätzungen für binäre Matrizen mit , Math. Z. 84 (1964), 438–447.
-  E. E. Fenimore and T. M. Cannon, Coded aperture imaging with uniformly redundant arrays, Applied Optics 17 (1978), 337–347.
-  R.J. Fletcher, M. Gysin, and J. Seberry, Application of the discrete Fourier transform to the search for generalised Legendre pairs and Hadamard matrices, Australas. J. Combin. 23 (2001), 75–86.
-  S. Ghosh and R. Pasupathy, Low-storage online estimators for quantiles and densities, Proc. 2013 Winter Simulation Conference, IEEE, New York, 2013, 778–789.
-  S. R. Gottesman and E. E. Fenimore, New family of binary arrays for coded aperture imaging, Applied Optics 28 (1989), 4344–4352.
-  T. Granlund, The GNU MP Bignum Library, http://gmplib.org/, 2016.
-  J. Hadamard, Résolution d’une question relative aux déterminants, Bull. des Sci. Math. 17 (1893), 240–246. Reprinted in Oeuvres de Jacques Hadamard, Tome 1, CNRS, Paris, 1968, 239–245.
-  M. Hall, Jr., A survey of difference sets, Proc. Amer. Math. Soc. 7 (1956), 975–986.
-  D. E. Knuth, J. H. Morris, and V. Pratt, Fast pattern matching in strings, SIAM J. Comput. 6 (1977), 323–350.
-  T. Kociumaka, J. Radoszewski, and W. Rytter, Computing -th Lyndon word and decoding lexicographically minimal de Bruijn sequence, CPM 2014, Lect. Notes in Comp. Sci., Vol. 8486, Springer, 2014, pp. 202–211.
-  I. S. Kotsireas, C. Koukouvinos, and J. Seberry, Hadamard ideals and Hadamard matrices with circulant core, J. Combin. Math. Combin. Comput. 57 (May 2006), 47–63.
-  A. Levin, R. Fergus, F. Durand, and W. Freeman, Image and depth from a conventional camera with a coded aperture, ACM Trans. Graph. 26.3 (2007), 70.
-  R. C. Lyndon, On Burnside’s problem, Trans. Amer. Math. Soc. 77 (1954), 202–215.
-  F. J. MacWilliams and N. J. A. Sloane, Pseudo-random sequences and arrays, Proc. IEEE 64 (1976), 1715–1729.
-  M. G. Neubauer and A. J. Radcliffe, The maximum determinant of -matrices, Linear Algebra Appl. 257 (1997), 289–306.
-  J. von Neumann, Various techniques used in connection with random digits, in Monte Carlo Method, Appl. Math. Series 12, US Nat. Bureau of Standards, 1951, 36–38 (summary written by G. E. Forsythe); reprinted in John von Neumann Collected Works, Vol. 5, Pergamon Press, New York, 1963, pp. 768–770.
-  OEIS Foundation Inc., The On-Line Encyclopedia of Integer Sequences, http://oeis.org, 2018.
-  W. Orrick, The Hadamard maximal determinant problem, http://www.indiana.edu/~maxdet/, 2018.
-  R. E. A. C. Paley, On orthogonal matrices, J. Mathematics and Physics 12 (1933), 311–320.
-  Y. Shiloach, Fast canonization of circular strings, J. Algorithms 2 (1981), 107–121.
-  A. I. Shirshov, Subalgebras of free Lie algebras, Mat. Sbornik N.S. 33 (1953), 441–452.
-  J. Singer, A theorem in finite projective geometry and some applications to number theory, Trans. Amer. Math. Soc. 43 (1938), 377–385.
-  C. Smyth, The Mahler measure of algebraic numbers: a survey, in Number Theory and Polynomials, J. McKee and C. Smyth (eds.), Cambridge Univ. Press, New York, 2008, 322–349.
-  R. G. Stanton and D. A. Sprott, A family of difference sets, Can. J. Math. 10 (1958), 73–77.
-  J. J. Sylvester, Thoughts on inverse orthogonal matrices …, London Edinburgh and Dublin Philos. Mag. and J. Sci. 34 (1867), 461–475.
-  A. L. Whiteman, A family of difference sets, Illinois J. Math. 6 (1962), 107–121.
-  J. Williamson, Hadamard’s determinant theorem and the sum of four squares, Duke Math. J. 11 (1944), 65–81.
-  M. Wojtas, On Hadamard’s inequality for the determinants of order non-divisible by , Colloq. Math. 12 (1964), 73–83.
-  A. Yedidia, C. Thrampoulidis, and G. Wornell, Analysis and optimization of aperture design in computational imaging, preprint, 2017, http://arxiv.org/abs/1712.04541.
11 Appendix: tables of maximal determinants
|order||maximal||ratio to||lex-least word|
|order||maximal scaled det||ratio to||lex-least word|