## Abstract

All 8th order Franklin bent diagonal squares with distinct elements 1, …, 64 have been constructed by an exact backtracking method. Our count of 1, 105, 920 dramatically increases the handful of known examples, and is some eight orders of magnitude less than a recent upper bound. Exactly one-third of these squares are pandiagonal, and therefore magic. Moreover, these pandiagonal Franklin squares have the same population count as the eighth order ‘complete’, or ‘most-perfect pandiagonal magic’, squares. However, while distinct, both types of squares are related by a simple transformation. The situation for other orders is also discussed.

## 1. Introduction

A resurgence of interest in the handful of Benjamin Franklin's bent diagonal squares of 8th and 16th order which he constructed in 1736–1737 (Pasles 2001, 2003; Ahmed 2004*a*,*b*) may be related to the tercentenary of his birth which occurred on 17 January 2006. The same year also marks the 250th anniversary of Franklin's election as a Fellow of the Royal Society of London. While Franklin squares must have the semi-magic property where the entries of all rows and columns add to the same magic sum, they do not have to have the same sum for the main diagonals which are required for fully magic squares. A distinguishing feature of Franklin's famous squares is that they have ‘bent’ diagonals with elements adding to the magic sum as indicated for the ‘right’ bends by following the symbols in the following square (with allowance for tiling, wrap-around or periodic boundary conditions, and with this square rotated for ‘down’, ‘left’ and ‘up’ bends):(1.1)Both the types of squares interest the same investigators, whether they are professional or recreational mathematicians. In both cases, the greatest interest involves *n*×*n* squares composed of each element of the set 1, …, *n*^{2}, the so-called natural (or classical, or normal, or traditional, or pure) squares, which have the magic sum (*s*_{n}) of a natural magic square, where(1.2)Recently, Pasles (2001) in a critical historical study examined the handful of natural squares actually constructed by Franklin, while Ahmed (2004*a*,*b*) used techniques in geometric combinatorics to count 228, 881, 701, 845, 346 eighth order Franklin squares with the natural magic linesum (*s*_{8}=260). However, many of Ahmed's squares have degenerate elements, leaving a smaller undetermined number of natural squares. This open question is solved in the present work. Ahmed (2004*a*,*b*) separately exploited the Hilbert bases of polyhedral cones to construct a few new natural Franklin squares.

There are two goals in enumeration, a formula giving the total number of such squares for all orders, and a convenient method of construction. A general formula has proved elusive except for natural ‘complete’ or ‘most-perfect pandiagonal magic squares’ for which Ollerenshaw (1986) enumerated those of 8th order and for which later Ollerenshaw & Brée (1998) obtained a combinatorial count for doubly even orders 4*p*, *p*=1, 2, 3, ….

In pandiagonal squares, the broken diagonals (*n* consecutive elements parallel to the main diagonals under tiling as indicated below) have the same sum as the main diagonals, but need not even be semi-magic squares (Loly & Steeds 2005).

(1.3)McClintock (1897) had defined ‘complete’ squares in 1897 as pandiagonal magic squares with two further properties: all 2×2 subsquares (‘blocks of four’, which we will call ‘quartets’) have the same sum, , and each element is complementary to the one distant from it *n*/2 places in the same diagonal by summing to . These ‘complete’ squares share the ‘quartet’ property with Franklin squares. Table 1 helps to compare the defining conditions of McClintock's ‘complete’ squares and Franklin bent diagonal squares, together with the number of constraints and their totals.

Earlier Frost (1878) had discovered a method for constructing pandiagonal magic squares, including one of 8th order which McClintock (1897) later identified as being ‘complete’. McClintock (1897) also noted that Franklin had constructed a 16th order bent diagonal square with the ‘quartet’ property which was not pandiagonal. McClintock's study was a cornerstone of the landmark work begun by Dame Kathleen Ollerenshaw (1986) for 8th order, and completed with Professor David Brée (Ollerenshaw & Brée 1998).

In the absence of any other combinatorial counts for squares with distinct elements, it has been possible to make significant progress with backtracking methods which were pioneered by Schroeppel (1971) in order to count 5th order natural magic squares. Walter Trump (2003) devised a hybrid Monte Carlo backtracking approach for estimating the population of normal magic squares for *n*>5, which is more efficient than a different Monte Carlo approach of Pinn & Wieczerkowski (1998). In 2004, we realized that Trump's techniques could be used to obtain an estimate for 8th order natural Franklin squares, but in the end, we were able to perform a direct count, finding 1, 105, 920 eighth order natural Franklin squares, eight orders of magnitude less than Ahmed's upper bound. To find an exact result in a reasonable time was a very pleasant surprise. The present count is exactly three times the exact count for ‘complete’ squares (Ollerenshaw & Brée 1998) of the same order, namely 368, 640, which itself is a product of 10 principal reversible squares and a transformation factor. When the present work began, we had no idea that Franklin squares were so closely related to the work of Ollerenshaw & Brée (1998), nor apparently did they appear to anticipate this outcome.

## 2. The backtracking computation

We took a fairly simple-minded approach to make a backtracking code for counting natural Franklin squares which is easy to debug. We excluded rotations and reflections from the count, but used no other symmetries. In essence, we have done little more than try every possible combination of numbers, stopping each time a set of numbers breaks a constraint in the definition of Franklin squares, whether it be quartet sums, half row (or column) sums or bent diagonal conditions.

Natural Franklin squares using each member of the set 1, …, 64 are ensured by a rigorous bookkeeping procedure modelled after that used by Trump (2003) in his code for estimating the number of natural 6th order magic squares by a very effective hybrid Monte Carlo backtracking procedure. In essence, a list of the 64 numbers is kept that records which are in use at each stage of the backtracking process. When a condition fails, the process backs up one step with the next iteration having the elements which fail the conditions, and those otherwise no longer used in the square, restored to the list for the next trial.

In what follows, we illustrate the basic steps involved via a sequence of squares. In the upper left quartet, we try every possibility for A and B (1, …, 64), and each time calculate from the quartet sum, , where ‘130’ is half of the value of *s*_{8}(2.1)Then we loop through all possible values of C (and thus D) for this constraint on their sum.

Next, we expand to the upper left quadrant where X's indicate cells already set, and we start by finding E (and G) in the same manner as we did for C (and D). F and H are calculated from the half row sums, and are further checked by the quartet sum EFGH:(2.2)Then, we can move on to I which is looped through the available members of the complete set 1, …, 64. Y's follow from quartet sums, while Z's follow from half row (or column) sums, and the lower quartet sums need to be checked as well.

Now, we extend to the whole left half, first looping J over available values, and then find the cells to its right via the quartet sums, before proceeding similarly with K and L. The Z's follow from the half column sums, but the lower quartet sums need to be checked, and B's indicate right and left bent diagonal conditions which can now be tested:(2.3)Lastly, we fill in the right half of the final square in a similar manner with a looping over available values for M, N and O. After each of these the remaining cells follow from quartet sums and half row (and column) sums.(2.4)In the above square, the central quartet of four cells involved in excluding rotations and reflections is shown in bold. As soon as this is found, rotations and reflections can be excluded by requiring *a*<*c*<*b*, *a*<*d* in(2.5)This reduces the overall running time by a factor of two to three. Finally, there are also bent diagonal sums to check.

A review of the conditions which apply in each cell may be useful(2.6)A's can be any unused number from the set 1, …, 64, and so they must be cycled through all those possibilities, either alone or in tandem with a constrained element. Y and Z cells have already been defined. Lastly, cells for which bent diagonals need to be checked are indicated by B's. Also, if all elements of a Franklin square satisfy these conditions except for the last element, that element must necessarily meet the conditions for a Franklin square.

Just 11 A cells in the top row and left column run over the available members of the set of 1, …, 64 integers, with the rest determined by the constraints defining Franklin squares.

## 3. Experimental results

The strategy outlined in the previous section was coded in C++ and run under Linux on a 2 GHz Pentium 4 machine. The run time was about 15 h and produced 1, 105, 920 natural squares, of which exactly one-third, 368, 640, are pandiagonal, and therefore, fully magic natural Franklin squares. An improved code which takes account of a symmetry described by Ahmed (2004*a*) whereby interchanging the alternate columns (respectively, rows) 1, 3; 2, 4; 5, 7; 6, 8 gives a symmetry factor of 2^{8}=256. When coded, this reduced the run time to about 10 min, and yields a dataset of 4320 squares of which 1440 are pandiagonal. Two other symmetries identified by Ahmed give a further symmetry factor of 16, but were not coded (The faster code and the dataset are available in electronic supplement).

Our count is lower than Ahmed's upper bound by a factor of some two hundred million. Moreover, in generating the complete set via the backtracking process, the number of distinct natural Franklin squares is now greatly increased over those previously published.

An example of one of our non-pandiagonal (semi-magic) natural Franklin squares (the 81st produced by the program) follows.(3.1)An example of a pandiagonal Franklin square (the 151st produced by the program) follows next:(3.2)Until recently, very few natural Franklin bent diagonal squares were known (Pasles 2001); one of 8th order and one of 16th order have been known from Franklin's writings for a long time; a second square of each order were lost for a long time (Pasles 2001). Recently, Ahmed (2004*a*,b) gave three more 8th order natural Franklin squares. A subset of the 8th order natural Franklin bent diagonal squares is pandiagonal and therefore magic. Three such variants found by Hagstrom were also shown in Ahmed's (2004*b*) thesis.

As noted in §1, the count of 368, 640 is the same as Ollerenshaw & Brée's (1998) combinatorial count for ‘complete’ squares in 8th order. Perhaps, this is not so surprising given the comparisons in table 1. However, we have checked that none of our set of 1440 pandiagonal squares satisfies the (*n*/2) complementary property required for the ‘complete’ squares, and so they are completely distinct, but remarkably, have the same count.

## 4. Conclusion

The natural 8th order Franklin squares have been counted exactly, and also have a convenient method of construction which yields a modest dataset which can be reordered in any desired manner. Exactly one-third of the total are pandiagonal, and therefore, magic squares.

### (a) Transformation to ‘complete’ squares

A simple transformation has also been found which converts pandiagonal Franklin squares to ‘complete’ squares. Observe that a combination of row and column transformations (first swap rows 3 and 5, then swap rows 4 and 6, next swap columns 3 and 5, and finally swap columns 4 and 6) on the pandiagonal example in equation (3.2) results in a ‘complete’ square:(4.1)We have written Maple code to perform this transformation on all of our 4320 dataset of natural Franklin squares, finding that exactly one-third (1440), all the pandiagonal squares, transform to a ‘complete’ square, while none of the remaining squares do so. This transformation to ‘complete’ squares accounts for the enumeration of 368, 640 pandiagonal natural Franklin squares obtained in this work. It also means that we can use Ollerenshaw & Brée's (1998) combinatorial result to claim an identical result for 8th order pandiagonal natural Franklin squares. The present work also gives a method of constructing all ‘complete’ squares in 8th order.

### (b) Conjecture

Before discovering the transformation above we had observed that the example in equation (3.1) shares four columns with the pandiagonal example in equation (3.2) (the first and last are identical, and two are displaced), and that the remaining columns in equation (3.2), after a set of row changes involving swapping pairs of McClintock (1897) couplets, can be moved to obtain equation (3.1) exactly. These couplets are a consequence of overlapping quartets so that, e.g. the 5, 42 and 31, 52 complementary (under the half column property) couplets in column 5 of equation (3.2) are swapped in column 2 of equation (3.1). We conjecture that all of our pandiagonal Franklin squares will generate two non-pandiagonal Franklin squares, in order to account for our total count of 1, 105, 920 eighth order natural Franklin squares.

### (c) Questions

What is the population of 16th order natural Franklin squares? For 16th order ‘complete’ squares Ollerenshaw & Brée's (1998) combinatorial result gives . Since a few natural Franklin squares have been found in this order, we conjecture that there may be a transformation between this large number of ‘complete’ squares and pandiagonal Franklin squares which is similar to that in §4

*a*, and further that the number of all 16th order natural Franklin squares is likely several times that number, but whether it is a factor of three, or perhaps more, is speculation at this time.Natural Franklin squares cannot be constructed for singly-even

*n*, because the half row (column) sum is then half integral. Are there any doubly even natural Franklin squares? Pasles (2001) (see his footnote 22 on p. 506) answered NO for 4th order. It is easy to see that for 4th order the half row and half column sums can never be satisfied in a quadrant (which is a quartet) because filling any of the four cells with a number from the set 1, …,*n*^{2}means that the other positions in its row and column would be the same, which is impossible. The obvious question is then: are there 12th order natural Franklin squares? The literature appears to be silent on this issue. Jacobs (1971) found a prescription for constructing a few Franklin squares of triply even order 8*m*,*m*=1, 2, 3, … which does not include 12th, 20th, 28th… orders, while we know that ‘complete’ squares exist for doubly even orders. Ollerenshaw & Brée (1998) in enumerating the ‘complete’ squares of doubly even orders give for 12th order squares.Can one find a general combinatorial formula for the enumeration of

*n*th order natural Franklin squares along the lines of Ollerenshaw & Brée's (1998) combinatorial result for ‘complete’ squares?

## Acknowledgments

We thank Professor Robert Thomas for drawing our attention to Ahmed's paper, Ian Cameron for continuing helpful feedback and the referees for helpful suggestions. Walter Trump kindly provided a copy of his 6×6 magic square hybrid Monte Carlo backtracking code before it was available on the Web, and Harvey Heinz a copy of Schroeppel's (1971) work. Professors Paul Pasles and Matthias Beck kindly commented on an earlier version of the manuscript and gave welcome encouragement. D.S. acknowledges summer scholarship support from the Natural Sciences and Engineering Research Council of Canada and from the Faculty of Science at the University of Manitoba in 2003 and 2004; M.R. and P.D.L. acknowledge support from a Post-Secondary Research Grant from the Winnipeg Foundation in 2003. Some testing procedures used to check squares are an extension of Maple codes originally constructed by Marcus Steeds and reported in a paper on a new class of pandiagonal non-magic squares (Loly & Steeds 2005).

## Footnotes

↵† Present address: Department of Physics & Astronomy, Michigan State University, East Lansing, Michigan 48824-2320, USA.

The electronic supplementary material is available at http://dx.doi.org/10.1098/rspa.2006.1684 or via http://www.journals.royalsoc.ac.uk.

- Received January 20, 2006.
- Accepted January 23, 2006.

- © 2006 The Royal Society