constructing orthogonal pandiagonal latin squares and panmagic squares from modular n-queens...

14
Constructing Orthogonal Pandiagonal Latin Squares and Panmagic Squares From Modular n-Queens Solutions Jordan Bell, Brett Stevens School of Mathematics and Statistics, Carleton University, Ottawa, ON K1S 5B6, E-mail: [email protected]; [email protected] Received October 12, 2005; revised November 6, 2006 Published online 15 February 2007 in Wiley InterScience (www.interscience.wiley.com). DOI 10.1002/jcd.20143 Abstract: In this article, we show how to construct pairs of orthogonal pandiagonal Latin squares and panmagic squares from certain types of modular n-queens solutions. We prove that when these modular n-queens solutions are symmetric, the panmagic squares thus constructed will be associative, where for an n × n associative magic square A = (a ij ), for all i and j it holds that a ij + a ni1,nj1 = c for a fixed c. We further show how to construct orthogonal Latin squares whose modular difference diagonals are Latin from any modular n-queens solution. As well, we analyze constructing orthogonal pandiagonal Latin squares from particular classes of non-linear modular n-queens solutions. These pandiagonal Latin squares are not row cyclic, giving a partial solution to a problem of Hedayat. © 2007 Wiley Periodicals, Inc. J Combin Designs 15: 221–234, 2007 Keywords: orthogonal Latin squares; pandiagonal Latin squares; panmagic squares; n-queens problem; Knut Vik designs 1. INTRODUCTION In this article, we show how to construct orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions. We take Latin squares with entries from the set {0, 1,...,n 1}= Z n . Let us number the rows from 0 at the top to n 1 at the bottom and the columns from 0 at the left to n 1 at the right. We refer to the cell on row i and column j by (i, j). By a modular sum diagonal, we mean the set of cells {(i, j)|i + j c (mod n)} for a particular c, and by a modular difference diagonal, we mean the set of cells {(i, j)|i j c (mod n)} for a particular c.A pandiagonal Latin square is a Latin square whose modular sum diagonals and modular difference diagonals are permutations of Z n , together with their rows and columns; that is, each element of Z n appears once and only once Contract grant sponsor: NSERC. © 2007 Wiley Periodicals, Inc. 221

Upload: jordan-bell

Post on 11-Jun-2016

231 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

Constructing Orthogonal PandiagonalLatin Squares and Panmagic SquaresFrom Modular n-Queens Solutions

Jordan Bell, Brett StevensSchool of Mathematics and Statistics, Carleton University, Ottawa, ON K1S 5B6,E-mail: [email protected]; [email protected]

Received October 12, 2005; revised November 6, 2006

Published online 15 February 2007 in Wiley InterScience (www.interscience.wiley.com).DOI 10.1002/jcd.20143

Abstract: In this article, we show how to construct pairs of orthogonal pandiagonal Latinsquares and panmagic squares from certain types of modular n-queens solutions. We prove thatwhen these modular n-queens solutions are symmetric, the panmagic squares thus constructedwill be associative, where for an n × n associative magic square A = (aij), for all i and j it holdsthat aij + an−i−1,n−j−1 = c for a fixed c. We further show how to construct orthogonal Latinsquares whose modular difference diagonals are Latin from any modular n-queens solution.As well, we analyze constructing orthogonal pandiagonal Latin squares from particular classesof non-linear modular n-queens solutions. These pandiagonal Latin squares are not row cyclic,giving a partial solution to a problem of Hedayat. © 2007 Wiley Periodicals, Inc. J Combin Designs15: 221–234, 2007

Keywords: orthogonal Latin squares; pandiagonal Latin squares; panmagic squares; n-queensproblem; Knut Vik designs

1. INTRODUCTION

In this article, we show how to construct orthogonal pandiagonal Latin squares and panmagicsquares from modular n-queens solutions. We take Latin squares with entries from the set{0, 1, . . . , n − 1} = Zn. Let us number the rows from 0 at the top to n − 1 at the bottomand the columns from 0 at the left to n − 1 at the right. We refer to the cell on row i andcolumn j by (i, j). By a modular sum diagonal, we mean the set of cells {(i, j)|i + j ≡ c

(mod n)} for a particular c, and by a modular difference diagonal, we mean the set of cells{(i, j)|i − j ≡ c (mod n)} for a particular c. A pandiagonal Latin square is a Latin squarewhose modular sum diagonals and modular difference diagonals are permutations of Zn,together with their rows and columns; that is, each element of Zn appears once and only once

Contract grant sponsor: NSERC.© 2007 Wiley Periodicals, Inc.

221

Page 2: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

222 BELL AND STEVENS

in each of their rows, columns, modular sum diagonals, and modular difference diagonals. ALatin square is cyclic when each row is a cyclic permutation of the first row and each columnis a cyclic permutation of the first column, and is semi-cyclic when either its rows are cyclicpermutations of the first row or its columns are cyclic permutations of the first column, butnot both. A panmagic square is a magic square for which the elements in each modular sumdiagonal and modular difference diagonal sum to its magic constant, along with its rowsand columns. A semi-magic square is a square which is magic in rows and columns, but notnecessarily in its main sum and difference diagonals, which is necessary to be a magic square.An n × n normal magic square is a magic square whose entries are each of the integers from1 to n2. An n × n associative magic square is a magic square A = (aij) such that for all iand j it holds that aij + an−i−1,n−j−1 = c for a fixed c. A modular n-queens solution is aplacement of n queens on the n × n modular chessboard such that no two queens share a row,column, modular sum diagonal, or modular difference diagonal, that is, a placement of nnon-attacking queens on the modular chessboard for which opposite sides are identified likea torus. An n-queens solution can be represented as a permutation g of Zn, of the columnsinto the rows; we can further express g by g = (g(0), g(1), . . . , g(n − 1)). It is clear thata permutation g of Zn is a modular n-queens solution if and only if g(x) + x (mod n)and g(x) − x (mod n) are themselves permutations, to avoid modular sum and differencediagonal attacks respectively. A linear modular n-queens solution is a modular n-queenssolution of the form g(j) ≡ cj + d (mod n) for fixed c and d, and a non-linear modular n-queens solution is any modular n-queens solution which is not linear. A symmetric n-queenssolution g is a solution that is invariant under 180-degree rotation, which is equivalent tothe condition that a queen being on the square (i, j) implies that there is a queen on thesquare (n − i − 1, n − j − 1), which is equivalent to the condition that g(n − j − 1) =n − g(j) − 1 for all j.

2. BACKGROUND

That modular n-queens solutions can be used to construct pandiagonal Latin squares andvice versa follows from Polya’s 1918 proof in [10] that a modular n-queens solutions re-mains a solution when all its queens are shifted horizontally modulo n by 1 < x < n orvertically modulo n by 1 < y < n. It follows clearly from this property that shifting a mod-ular n-queens solution vertically 0, 1, . . . , n − 1 squares modulo n yields n superimposablemodular n-queens solutions. We write i in place of the queens in the solution verticallyshifted i squares, for i = 0, 1, . . . , n − 1. Since the is replace the queens in a modular n-queens solution, there will be exactly one i in each row, column, modular sum diagonal, andmodular difference diagonal, for i = 0, 1, . . . , n − 1. On the other hand, given an n × n

pandiagonal Latin square, for any fixed i ∈ Zn putting a queen in place of each i yields amodular n-queens placement. Polya’s result that modular n-queens solutions exist if andonly if gcd(n, 6) = 1 therefore implies Hedayat’s later proof in [6] that n × n pandiagonalLatin squares (he refers to them as Knut Vik designs) exist if and only gcd(n, 6) = 1.

Further, that Latin squares can be used to construct magic squares is well known. Thiswas shown by Euler in [4], presented to the St. Petersburg Academy on October 17, 1776,in which Euler shows how to construct a magic square from an orthogonal pair of Latinsquares. (This article has been translated from the Latin by the first author in [5].) Eulerconstructs magic squares from orthogonal Latin squares, for which the first has as entriesthe first n letters of the Latin alphabet {a, b, c, . . .} and for which the second has as entries

Page 3: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 223

the first n letters of the Greek alphabet {α, β, γ, . . .}. In fact, the term “Latin” square comesfrom Euler’s use in this work of the Latin characters as the n symbols permuted in therows and columns of the first square, and the term “Graeco-Latin” square comes fromhis constructing the orthogonal mate of the first Latin square with entries from the Greekcharacters.

However, the connection between n-queens solutions and magic squares is not wellknown. The only article in the literature which discusses this is [3] by Demirors, Rafraf andTanik, but it only constructs semi-magic squares, and further does not provide proofs forits results. Furthermore, employing modular n-queens solutions in constructing orthogonalpandiagonal Latin squares and panmagic squares allows us to construct previously unknown(orthogonal) pandiagonal Latin squares and panmagic squares from non-linear modular n-queens solutions. (The only non-linear modular n-queens solutions in the literature are thoseobtained by composing modular n-queens solutions, Bruen and Dixon’s solutions from [2],and Kløve’s solutions from [7,8], all of which we discuss in Section 4.) This is useful, sincepandiagonal Latin squares have not been extensively studied themselves. Moreover, Hedayatin [6] notes that the pandiagonal Latin squares constructed by his method are cyclic, andthat finding a method for constructing non-cyclic pandiagonal Latin squares is an unsolvedproblem. However, Atkin, Hay and Larson in [1] do in fact construct pandiagonal Latinsquares which are semi-cyclic. Atkin, Hay and Larson’s article appears to be the onlyone in the literature which gives semi-cyclic pandiagonal Latin squares (there are nonewhich give non-cyclic pandiagonal Latin squares). Their semi-cyclic pandiagonal Latinsquares correspond to a generalization of Bruen and Dixon’s solutions, and we discussthis further later. Yet, using Kløve’s non-linear modular n-queens solutions, we are able toobtain additional semi-cyclic pandiagonal Latin squares, giving more partial solutions toHedayat’s problem. Finally, in Section 5, we show that all panmagic squares constructedby our method from symmetric modular n-queens solutions will be associative. In thisarticle, when it is clear from context we will not necessarily specify that a magic square isnormal.

3. MAIN RESULTS

Let g be a modular n-queens solution, either linear or non-linear, and let us have A =(aij) defined by aij = (i − g(j) + n−1

2 ) mod n and B = (bij) defined by bij = (j − i +g(j)) mod n. For instance, with g(j) ≡ 2j (mod n) and n = 5, this gives:

A =

2 0 3 1 4

3 1 4 2 0

4 2 0 3 1

0 3 1 4 2

1 4 2 0 3

, B =

0 3 1 4 2

4 2 0 3 1

3 1 4 2 0

2 0 3 1 4

1 4 2 0 3

.

It is clear that both A and B are 5 × 5 pandiagonal Latin squares and that they are orthogonalto each other. It is easy to check that this construction results in cyclic pandiagonal Latinsquares if and only if the modular n-queens solution is linear.

Page 4: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

224 BELL AND STEVENS

Let us form the n × n array C such that C = nA + B + J , with J an n × n array with a1 in each cell. For A and B as above, we obtain:

C =

11 4 17 10 23

20 8 21 14 2

24 12 5 18 6

3 16 9 22 15

7 25 13 1 19

.

We find C to be a 5 × 5 normal panmagic square. We generalize the above in the followingtheorem:

Theorem 3.1. If g is a modular n-queens solution, with A = (aij) defined by aij =(i − g(j) + n−1

2 ) mod n and B = (bij) defined by bij = (j − i + g(j)) mod n, then A andB will be orthogonal, A will be a pandiagonal Latin square, and B will be a Latin squarewhose modular difference diagonals are permutations of Zn. Moreover, B is a pandiagonalLatin square if and only if g(x) + 2x (mod n) is injective.

Proof. First we will show that A and B are orthogonal. Suppose for some (i, j) �=(k, l) that (aij, bij) = (akl, bkl). Then ((i − g(j) + n−1

2 ) mod n, (j − i + g(j)) mod n) =((k − g(l) + n−1

2 ) mod n, (l − k + g(l)) mod n). Thus i − g(j) ≡ k − g(l) (mod n) andj − i + g(j) ≡ l − k + g(l) (mod n), and by adding we get that j ≡ l (mod n). Butfrom this we get i − g(l) ≡ k − g(l) (mod n) and so i ≡ k (mod n), a contradiction.Hence A and B are orthogonal.

It can be verified without difficulty that A is a pandiagonal Latin square (cf. Polya’s resultsdiscussed in Section 2).

It is easy to show that B is a Latin square, i.e., that its rows and columns are permuta-tions of Zn. Now, suppose that two distinct cells bij, bkl on the same modular differencediagonal of B have the same entry. Sharing the modular difference diagonal gives i − j ≡ c

(mod n), k − l ≡ c (mod n). Having the same entry means j − i + g(j) ≡ l − k + g(l)(mod n). Thus j − c − j + g(j) ≡ l − c − l + g(l) (mod n) and g(j) ≡ g(l) (mod n),a contradiction since g is a permutation. Thus the modular difference diagonals of B arepermutations of Zn.

Suppose that two distinct cells bij, bkl on the same modular sum diagonal of B havethe same entries. Then i ≡ c − j (mod n), k ≡ c − l (mod n) and j − i + g(j) ≡ l −k + g(l) (mod n), so j − c + j + g(j) ≡ l − c + l + g(l) (mod n). Hence g(j) + 2j ≡g(l) + 2l (mod n). If g(x) + 2x (mod n) is injective this is a contradiction and so B willbe a pandiagonal Latin square. If g(x) + 2x (mod n) is not injective then at least twomodular sum diagonals of B will not be permutations of Zn and B will therefore not be apandiagonal Latin square. �

Since to construct orthogonal pandiagonal Latin squares from modular n-queens solu-tions g in the above way we require that g(x) + 2x (mod n) is injective, it is interestingto know the number of such solutions for different n. Gunter Stertenbrink has computedresults for n = 1 to 25, which we give in Table I, in which solutions equivalent under thegroup of symmetries of the square are considered distinct.

Page 5: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 225

TABLE I. Number of Modular n-Queens Solutions g Such That g(x) + 2x (mod n) IsInjective, for n = 1 to 25

n 1 5 7 11 13Number 1 5 21 77 455n 17 19 23 25Number 1,377 3,895 5,727 46,875

An easy corollary of Theorem 3.1 is that a linear n-queens solution g(j) ≡ cj +d (mod n) yields a pair of orthogonal pandiagonal Latin squares if and only ifgcd(c + 2, n) = 1.

The following result which employs orthogonal Latin squares to construct magic squarescan be attributed to Euler:

Theorem 3.2 Euler. For A and B orthogonal Latin squares with entries from Zn, C =nA + B + J will be a normal semi-magic square. If the modular sum (difference) diagonali + j ≡ c (mod n)(i − j ≡ c (mod n)) is a permutation of Zn in both A and B, thenC will be magic in the modular sum (difference) diagonal i + j ≡ c (mod n)(i − j ≡ c

(mod n)). In particular, if both A and B are pandiagonal Latin squares, C will be a normalpanmagic square.

Thus, for g a modular n-queens solution and with A and B as defined in Theorem 3.1, C =nA + B + J will be a normal semi-magic square which is magic in its modular differencediagonals, and if g(x) + 2x (mod n) is injective then C will be a normal panmagic square.For a linear solution, C will be a normal panmagic square if and only if gcd(c + 2, n) = 1.

4. NON-LINEAR MODULAR N-QUEENS SOLUTIONS AND SEMI-CYCLICPANDIAGONAL LATIN SQUARES

We can easily obtain non-linear modular n-queens solutions by composing modular n-queens solutions. If f = (a1, . . . , am) and g = (b1, . . . , bn) are modular n-queens solu-tions, their composition is (nb1 + a1, . . . , nb1 + an, nb2 + a1, . . . , nb2 + an, . . . , nbm +a1, . . . , nbm + an). Intuitively, each queen in f is replaced with the solution g. It was provedby Polya [10] in the linear case and Kløve [8] in the general case that the compositionof solutions for the m × m and n × n modular boards will be a solution for the mn × mn

modular board. However, it is clear that even if both of these modular n-queens solutionsare linear, their composition will not in general be linear.

Bruen and Dixon in [2] construct non-linear solutions for the modular p × p board for pprime. The non-zero squares in Zp form a multiplicative subgroup S of Z

∗p = Zp \ {0}. Each

element in S is assigned a plus (+) sign, and each element in Z∗p \ S is assigned a minus

(−) sign. Bruen and Dixon note that for p > 11, there are at least two distinct consecutivetriples in the natural ordering of the elements of Z

∗p having the same quadratic parity pattern

of length 3 (e.g., for p = 13, the triples 2, 3, 4, and 8, 9, 10 both have the quadratic paritypattern − + +). They take u equal to the middle entry of the first triple and v equal to themiddle entry of the second triple. They then define a permutation g of Zp by g(x) ≡ ux

(mod p) if x ∈ S, g(x) ≡ vx (mod p) if x /∈ S, and then the permutation f of Zp definedby f (x) ≡ g(x) + w (mod p) for w ∈ Zp will be a non-linear modular n-queens solution.

Page 6: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

226 BELL AND STEVENS

We then have the following theorem for constructing panmagic squares from this class ofnon-linear modular n-queens solutions:

Theorem 4.1. Let g be a Bruen and Dixon solution for the p × p modular board for pprime, with u and v the middle entries of two distinct consecutive triples with the samequadratic parity patterns. Let us have B = (bij) defined by bij = (j − i + g(j)) mod p. If(u + 2)(v + 2)−1 is a non-zero square in Zp, then B is a pandiagonal Latin square.

Proof. (Certainly, for (u + 2)(v + 2)−1 to be defined we must have v + 2 �≡ 0 (mod p).)Suppose that for x �≡ y (mod p), g(x) + 2x ≡ g(y) + 2y (mod p). If x, y ∈ S, thenwe have ux + 2x ≡ uy + 2y (mod p) and (u + 2)x ≡ (u + 2)y (mod p), thus x ≡ y

(mod p), a contradiction. If x ∈ S and y /∈ S, then ux + 2x ≡ vy + 2y (mod p), hence(u + 2)(v + 2)−1x ≡ y (mod p). Now, since (u + 2)(v + 2)−1 is a non-zero square, theleft-hand side of the equation is a non-zero square but the right-hand side is not, a contradic-tion. Similarly, the cases x /∈ S, y ∈ S, and x, y /∈ S yield contradictions. Hence g(x) + 2x

(mod p) is injective, so by Theorem 3.1, B is a pandiagonal Latin square. �Therefore, for g a Bruen and Dixon modular n-queens solution with u and v the middle

entries of consecutive triples with the same quadratic parity pattern (in Z∗p), for A as pre-

viously defined and B as defined in the above theorem, if (u + 2)(v + 2)−1 is a non-zerosquare in Zp then C = nA + B + J is a normal panmagic square.

For p = 13, the elements 2, 3, 4 and 8, 9, 10 are two consecutive triples both withquadratic parity pattern − + +. Taking u = 3, v = 9 yields the non-linear modular n-queenssolution made by Bruen and Dixon’s method (0, 3, 5, 9, 12, 6, 2, 11, 7, 1, 4, 8, 10). In Z13,(v + 2)−1 = 6, hence (u + 2)(v + 2)−1 = 4, a non-zero square in Z13. Thus by Theorem4.1, we have the orthogonal pair of 13 × 13 pandiagonal Latin squares in Figure 1, neither ofwhich are cyclic in their rows; in turn by taking C = 13A + B + J , we obtain the 13 × 13normal panmagic square in Figure 2.

In general, (u + 2)(v + 2)−1 being a non-zero square in Zp is equivalent to u + 2 andv + 2 having the same quadratic parity. There are 24 = 16 possible quadratic parity patternsfor four consecutive elements in Z

∗p; hence for p ≥ 17, there must be distinct u, v ∈ Z

∗p

such that u − 1, u, u + 1, u + 2, and v − 1, v, v + 1, v + 2 have the same quadratic paritypatterns, since there must be a repeated length four parity sequence in the natural order ofthe elements of Z

∗p.

Kløve in [7] gives polynomial solutions to the modular n-queens problem. Let Pn be theproduct of the distinct prime factors of n. Kløve proves that for gcd(n, 6) = 1, if gcd((a1 −1)a1(a1 + 1), n) = 1 and ai ≡ 0 (mod Pn) for i ≥ 2, then f (x) ≡ ∑r

i=0 aixi (mod n)

is a modular n-queens solution. If we further assume that gcd(a1 + 2, n) = 1, it followsimmediately from his proof that f (x) + 2x (mod) n is injective. Since f is non-linear, wesee that B cannot be cyclic, and from Theorem 3.1, we find that B will be pandiagonal:

Theorem 4.2. Take f (x) ≡ ∑ri=0 aix

i (mod n) to be a Kløve modular n-queens solu-tion. Let us have B = (bij) defined by bij = (j − i + g(j)) mod n. If gcd(a1 + 2, n) = 1,then B is a semi-cyclic pandiagonal Latin square.

For instance, for n = 25, take a0 = 13, a1 = 12, a2 = 5, a3 = 20, This gives the fol-lowing (non-linear) Kløve solution f for the 25 × 25 modular chessboard, for whichgcd(a1 + 2, n) = 1:

f = (13, 0, 17, 9, 21, 23, 10, 2, 19, 6, 8, 20, 12, 4, 16, 18, 5, 22, 14, 1, 4, 15, 7, 24, 11).

Page 7: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 227

A =

9112512840710136

1012360951811247

1104711062912358

1215821173100469

0269312841115710

1371040951226811

2481151106037912

3591262117148100

4610073128259111

5711184093610122

6812295110471103

7903106211581214

8101411731269025

B =

9611025811312740

8509147102116312

7412803691105211

6311712258094110

5210611147128309

4195100361172128

3084912251061117

2127381114950106

1116271003841295

0105169122731184

1294058111621073

1183124710051962

1072113691240851

FIGURE 1. An orthogonal pair of 13 × 13 pandiagonal Latin squares.

As well, the above solution is symmetric; we prove conditions under which modular n-queens solution are symmetric in Section 5. This solution yields an orthogonal pair of25 × 25 pandiagonal Latin squares, neither of which are cyclic in their rows, which in turnproduce an 25 × 25 normal panmagic square. This magic square also is associative, whichwe explore in Section 5.

Kløve in [8] gives further solutions to the modular n-queens problem, constructing doublysymmetric (that is, invariant under rotation by 90 degrees) solutions for the pα × pα modularboard, with p an odd prime. This is done using an intricate but elementary argument withprimitive roots g of p such that g is also a primitive root of all powers of p; it is well known

Page 8: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

228 BELL AND STEVENS

C =

1271502876159110611295143214479

1391624088212273241071553356104

1515651001413485361191674568116

1631777112391469748131105780128

629891245115810960156226992140

1841101136631121721683481117152

3053113148752613384114693129164

427812516087381459623581051417

549013739950157108357013015319

66102149151116213120478214216531

911141612712374251325994154843

1031264521358637144711061662055

115138166414798491698311893267

FIGURE 2. A 13 × 13 normal panmagic square.

that if g is a primitive root of an odd prime p then either g or g + p is a primitive root of pα

for all α [9, Section 4.1].We modify Kløve’s construction slightly to produce solutions f such that f (x) + 2x

(mod pα) is also a permutaion, and thus the squares A and B produced by our methods willboth be pandiagonal Latin squares and orthogonal to each other.

Let p ≡ 1 (mod 4) be a prime. We define Wβ by Wβ = 0 if β = 0, andWβ = pβ−1(p − 1)/4 if β > 0, and define Zβ = (pβ − 1)/4. We also define 〈r, s〉 ={(r, s), (s, −r), (−r, −s), (−s, r)}; in these solutions, the middle cell of the board is (0, 0).Kløve defines a triple (α, κ, V ) to be permissible if there exist integers µ and ν such that

gκ − 1 ≡ gµ (mod pα)

gκ + 1 ≡ gν (mod pα)

V |κ, V |µ − ν, V |Wα

v(V ) = v(κ) = v(µ − ν) ≤ v(Wα),

where v(V ) denotes the multiplicity of 2 in V. Let vp(V ) denote the multiplicity of p in V.We extend this definition to the following:

Definition 4.3. A triple (α, κ, V ) with α ≥ 1 is said to be extra permissible if it is permis-sible and there exist integers s, s′, t and t′ such that

gκ + 2 ≡ gs (mod pα)

gκ − 2 ≡ gs′ (mod pα)

1 − 2gκ ≡ gt (mod pα)

Page 9: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 229

1 + 2gκ ≡ gt′ (mod pα)

V |(s − t), V |(s′ − t′)

v(s − t) = v(s′ − t′) = v(V ).

With this definition, we get the following variants of three of Kløve’s theorems [8]; weomit the proofs because they are straightforward analogs of Kløve’s own proofs:

Theorem 4.4. Let (α, κ, V ) be extra permissible and let

{(0, 0)} ∪Zα−1⋃i=1

〈ri, si〉

be a doubly symmetric solution f of the pα−1 × pα−1 modular board such that f (x) + 2x

(mod pα−1) is a permutation. Then

{(0, 0)} ∪Zα−1⋃i=1

〈pri, psi〉 ∪V⋃

j=1

U⋃i=1

⟨g2iV+j, g2iV+j+κ

where U = Wα/V , is a doubly symmetric solution h of the pα × pα modular board suchthat h(x) + 2x (mod pα) is a permutation.

Theorem 4.5.

1. If (α, κ, V ) is extra permissible, then (α, κ + 2λWα, V ) is extra permissible for allintegers λ.

2. If (α, κ, V ) is extra permissible, V ′|V and v(V ′) =v(V), then (α, κ, V ′) is extra per-missible.

3. If (α − 1, κ, V ) is extra permissible, then (α, κ, V ) is extra permissible.4. If (α, κ, V ) is extra permissible and vp(V ) ≤ α − 2, then (α − 1, κ, V ) is extra per-

missible.5. If (α, κ, V ) is extra permissible and vp(V ) ≥ 1, then (α − 1, κ, V/p) is extra permis-

sible.6. (α, Wα, Wα) is extra permissible for all α ≥ 1.

Finally we can explicitly construct solutions with the following:

Theorem 4.6. Let p ≡ 1 (mod 4) be a prime not equal to 5. For each β = 1, 2, . . . , α

let

1. δβ be an odd integer such that 1 ≤ δβ ≤ β,2. λβ be an odd integer,3. Vβ, Uβ be integers such that Uβ is odd and VβUβ = Wδβ

.

Page 10: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

230 BELL AND STEVENS

Then

{(0, 0)} ∪α⋃

β=1

Vβ⋃j=1

Uβ⋃i=1

〈pα−βg2iVβ+i+λβWδβ , pα−βg2iVβ+i〉

is a doubly symmetric solution f of the pα × pα modular board with the property that f (x) +2x (mod pα) is a permutation. Thus B = (bij) defined by bij = (j − i + f (j)) mod pα isa semi-cyclic pandiagonal Latin square.

5. SYMMETRIC MODULAR N-QUEENS SOLUTIONS AND ASSOCIATIVEPANMAGIC SQUARES

We prove here that orthogonal pandiagonal Latin squares constructed by our method froma symmetric modular n-queens solutions yield associative normal panmagic squares:

Theorem 5.1. Let g be a symmetric modular n-queens solution such that g(x) + 2x

(mod n) is injective, A = (aij) be defined by aij = (i − g(j) + n−12 ) mod n and B = (bij)

be defined by bij = (j − i + g(j)) mod n. Then C = nA + B + J is an associative normalpanmagic square.

Proof. We have from Theorems 3.1 and 3.2 that C is a normal panmagic square. We willshow that aij + an−i−1,n−j−1 = bij + bn−i−1,n−j−1 = n − 1. We have the following:

aij + an−i−1,n−j−1 =((

i − g(j) + n − 1

2

)mod n

)

+((

n − i − 1 − g(n − j − 1) + n − 1

2

)mod n

)

=((

i − g(j) + n − 1

2

)mod n

)

+((

n − i − 1 − (n − g(j) − 1) + n − 1

2

)mod n

)

=((

i − g(j) + n − 1

2

)mod n

)+

((g(j) − i + n − 1

2

)mod n

)= n − 1.

Similarly, we have:

bij + bn−i−1,n−j−1 = ((j − i + g(j)) mod n) + ((n − j − 1 − (n − i − 1)

+ g(n − j − 1)) mod n)

= ((j − i + g(j)) mod n) + ((−j + i + n − g(j) − 1) mod n)

= n − 1.

Page 11: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 231

Therefore we have:

cij + cn−i−1,n−j−1 = naij + bij + 1 + nan−i−1,n−j−1 + bn−i−1,n−j−1 + 1

= n(aij + an−i−1,n−j−1) + bij + bn−i−1,n−j−1 + 2

= n2 − n + n − 1 + 2

= n2 + 1,

showing that C is associative. �It is can easily be verified that a linear modular n-queens solution g(j) ≡ cj + d

(mod n) is symmetric if and only if c ≡ 2d + 1 (mod n). We now characterize whichtranslations of Bruen and Dixon modular n-queens modular solutions are symmetric. Weshow that a Bruen and Dixon modular solution is symmetric if and only if p ≡ 1 (mod 4)and the board is cyclically shifted p−1

2 entries to the right and p−12 entries vertically.

Theorem 5.2. For p ≡ 1 (mod 4) a prime, let S be the non-zero squares in Zp. Let uand v be the middle entries of two consecutive triples in Z

∗p with the same quadratic parity

pattern. Define the map g by:

g(x) ≡{

u(x − w) + h (mod p), if x − w ∈ S

v(x − w) + h (mod p), if x − w /∈ S.

Then g is a symmetric solution for the modular p × p board if and only if w ≡ h ≡ p−12

(mod p).On the other hand, for p ≡ 3 (mod 4) a prime, no translation of a Bruen and Dixon

solution for the modular p × p board will be symmetric.

Proof. Let p ≡ 1 (mod 4), and take w ≡ h ≡ p−12 (mod p). We shall show that for

all j, g(p − j − 1) ≡ p − g(j) − 1 (mod p), i.e., that g is symmetric. If p − j − 1 −p−1

2 ∈ S, that is p−12 − j ∈ S, theng(p − j − 1) ≡ u(p − j − 1 − p−1

2 ) + p−12 (mod p).

Thus g(p − j − 1) ≡ up−1

2 − uj + p−12 (mod p). Since p ≡ 1 (mod 4), −1 ∈ S, so

j − p−12 ∈ S, hence g(j) ≡ u(j − p−1

2 ) + p−12 (mod p), so p − g(j) − 1 ≡ p − uj +

up−1

2 − p−12 − 1 (mod p). Thus g(p − j − 1) ≡ p − g(j) − 1 (mod p) for p−1

2 − j ∈S. In the same way, for p−1

2 − j /∈ S we find that g(p − j − 1) ≡ p − g(j) − 1 (mod p),and thus g is symmetric.

Conversely, take w and h not both equal to p−12 , and suppose that g is symmetric. If there is

a j such that both j − w and p − j − 1 − w are in S, then g(j) ≡ u(j − w) + h (mod p)and g(p − j − 1) ≡ u(p − j − 1 − w) + h (mod p). Since g is symmetric, p − u(j −w) − h − 1 ≡ u(p − j − 1 − w) + h (mod p), and so u(2w + 1) ≡ 2h + 1 (mod p).Similarly, if there is also a j such that both j − w and p − j − 1 − w are not in S, then we getv(2w + 1) ≡ 2h + 1 (mod p). But by assumption u and v are distinct, hence 2w + 1 ≡ 0(mod p), i.e., w ≡ p−1

2 (mod p), which in turn gives h ≡ p−12 (mod p).

We now shall show that for all p ≥ 5, there exists a j such that both j − w and p − j − 1 −w are in S, and a j such that both j − w and p − j − 1 − w are not in S, for w fixed. Supposethat for all j such that j − w ∈ S, p − j − 1 − w /∈ S. Thus for all such j, j + 1 + w /∈ S,and therefore for all t ∈ S, t + 2w + 1 /∈ S. Similarly, because for x non-zero, x ∈ S if and

Page 12: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

232 BELL AND STEVENS

only if −x ∈ S, we have that for all t /∈ S except one t = ξ, t + 2w + 1 ∈ S. Thus we findthat

S = {ξ + 2(2w + 1), ξ + 4(2w + 1), ξ + 6(2w + 1), . . . , ξ + (p − 1)(2w + 1)},

If ξ is even this implies that all the non-zero squares are even, contradicting that 1 is anon-zero square. If ξ is odd this implies that all the non-zero squares are odd, contradictingfor all p ≥ 5 that 4 is a non-zero square. Hence for all p ≥ 5, there is a j such that bothj − w and p − j − 1 − w are in S. Similarly, we find that for all p ≥ 5, there is a j suchthat both j − w and p − j − 1 − w are not in S. Therefore for w and h not both congruentto p−1

2 modulo p, g is not symmetric.On the other hand, let p ≡ 3 (mod 4). We note that −1 /∈ S. We define g by:

g(x) ≡{

u(x − w) + h (mod p), if x − w ∈ S

v(x − w) + h (mod p), if x − w /∈ S.

Suppose that g is symmetric. By the change of coordinates (i, j) �→ (i + p−12

(mod p), j + p−12 (mod p)), this is equivalent to the condition that for all x, g(x) ≡

−g(−x) (mod p). For each x, one and only one of the following must hold:

� x − w, −x − w ∈ S, which implies h ≡ uw (mod p)� x − w, −x − w /∈ S, which implies h ≡ vw (mod p)� x − w ∈ S, −x − w /∈ S, which implies 2h ≡ vx + vw − ux + uw (mod p)� x − w /∈ S, −x − w ∈ S, which implies 2h ≡ ux + uw − vx + vw (mod p)

Say −w ∈ S and therefore w /∈ S. Starting with x = 0 gives h ≡ uw (mod p). But2w − w /∈ S and therefore −2w − w ∈ S, otherwise h ≡ vw (mod p). Then, since−3w ∈ S, 3w /∈ S. But now 4w − w /∈ S and therefore −4w − w ∈ S, otherwise h ≡ vw

(mod p). Then, since −5w ∈ S, 5w /∈ S, and so on. Thus we obtain:

Zp \ S = {w, 3w, 5w, 7w, . . . , (p − 2)w, pw},

and since w /∈ S, S = {1, 3, 5, . . . , p − 2}. But for p ≥ 7, 4 ∈ S, a contradiction. Hence, itcannot be that −w ∈ S.

Say −w /∈ S and therefore w ∈ S. Hence h ≡ vw (mod p). But 2w − w ∈ S, thus−2w − w /∈ S, otherwise h ≡ uw (mod p), and since −3w /∈ S, 3w ∈ S. Now, 4w − w ∈S, therefore −4w − w /∈ S, otherwise h ≡ uw (mod p), and since −5w /∈ S, 5w ∈ S, andso on. Thus, we find:

S = {w, 3w, 5w, . . . , (p − 2)w},

and since w ∈ S, S = {1, 3, 5, . . . , (p − 2)w}. But for p ≥ 7, 4 ∈ S, a contradiction. Thusit cannot be that w ∈ S, and therefore g cannot be symmetric. �

We can also give a characterization of which Kløve [7] modular n-queens solutions aresymmetric:

Page 13: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

ORTHOGONAL PANDIAGONAL LATIN SQUARES AND PANMAGIC SQUARES 233

Theorem 5.3. For f (x) ≡ ∑ri=0 aix

i (mod n) a Kløve modular n-queens solution,if

∑ri=0(−1)iai ≡ −a0 − 1 (mod n) and

∑ri=j

(ij

)(−1)iai ≡ −aj (mod n) for j =

1, . . . , r, then f is symmetric.

Proof. For f to be symmetric, we recall that it is sufficient (and necessary) that f (n − j −1) = n − f (j) − 1.

We have f (n − j − 1) ≡ a0 + a1(−j − 1) + a2(−j − 1)2 + · · · + ar(−j − 1)r (mod n)We know n − f (j) − 1 ≡ n − a0 − a1j − a2j

2 − · · · − arjr − 1 (mod n). If

∑ri=0(−1)iai

= n − a0 − 1, the constant terms of f (n − j − 1) and n − f (j) − 1 are equal. If∑ri=1

(i1

)(−1)iai ≡ −a1 (mod n), the terms of degree 1 of f (n − j − 1) and n − f (j) − 1

are equal. Similarly, the terms of higher degree f (n − j − 1) and n − f (j) − 1 are equal,hence f (n − j − 1) = n − f (j) − 1, and thus f is symmetric. �

We recall that Kløve’s [8] solutions for the pα × pα modular board given in Theorem4.6 are doubly symmetric, and thus symmetric.

6. CONCLUSION

In this article, we have shown how to construct orthogonal pandiagonal Latin squares andthus normal panmagic squares from modular n-queens solutions. These applications ofmodular n-queens solutions had not been studied up to now. We have used our method withnon-linear modular n-queens solutions to make previously unknown orthogonal pandiagonalLatin squares and panmagic squares.

We have also given additional partial solutions to Hedayat’s problem of finding non-cyclicpandiagonal Latin squares to those already given by Atkin, Hay and Larson in [1]. However,the columns of the pandiagonal Latin squares we make are still cyclic permutations of thefirst column. Methods for constructing pandiagonal Latin squares which are not cyclic inrows or columns remain to be found in order to fully solve Hedayat’s problem.

It would be interesting as well to investigate constructing orthogonal d-dimensionalpandiagonal Latin hypercubes and d-dimensional panmagic hypercubes from d-dimensionalmodular n-queens solutions.

ACKNOWLEDGEMENTS

We would like to thank Gunter Stertenbrink for reading several earlier versions of this articleand for giving helpful suggestions, and also for computing the results given in Table I. Weare very grateful to the anonymous referees for helpful recommendations. This researchwas supported by NSERC.

REFERENCES

[1] A. O. L. Atkin, L. Hay, and R. G. Larson, Enumeration and construction of pandiagonal Latinsquares of prime order, Comput Math Appl 9(2) (1983), 267–292.

[2] A. Bruen and R. Dixon, The n-queens problem, Discrete Math 12(4) (1975), 393–395.

[3] O. Demirors, N. Rafraf, and M. M. Tanik, Obtaining N-queens solutions from magic squaresand constructing magic squares from N-queens solutions, J Recreational Math 24(4) (1992),272–280.

Page 14: Constructing orthogonal pandiagonal Latin squares and panmagic squares from modular n-queens solutions

234 BELL AND STEVENS

[4] L. Euler, De quadratis magicis, Leonhardi Euleri commentationes arithmeticae collectae, P.-H. Fuss and N. Fuss (Editors), vol. 2, Academiae imperialis scientiarum Petropolitanae, 1849,pp. 593–602.

[5] L. Euler, On magic squares, arXiv math.CO/0408230, 2004, translation from the Latin by JordanBell.

[6] A. Hedayat, A complete solution to the existence and nonexistence of Knut Vik designs andorthogonal Knut Vik designs, J Combin Theory Ser A 22(3) (1977), 331–337.

[7] T. Kløve, The modular n-queen problem, Discrete Math 19(3) (1977), 289–291 (1978).

[8] T. Kløve, The modular n-queen problem. II, Discrete Math 36(1) (1981), 33–48.

[9] W. J. LeVeque, Fundamentals of number theory, Addison-Wesley Publishing Co., Reading,Mass-London-Amsterdam, 1977.

[10] G. Polya, Uber die “doppelt-periodischen” losungen des n-damenproblem, Mathematische Un-terhaltungen und Spiele, W. Ahrens (ed.), Vol. 2, B. G. Teubner, second ed., 1918, pp. 364–374.