# The Anti-Magic Square Project: Construction

Madachy asks "Are there any systematic methods by which antimagic squares may be constructed?" It seems that up until now, no such method was known. Here, we present several constructions discovered this summer.

## Constructing an AMS(4k+1) for k>=1

This construction involves the juxtapositioning of two matrices, H and L in the following way, to produce A:

```{Ai,j} = n*{Hi,j} + {Li,j} ```

In other words, to form the i,j'th element of A, use {Hi,j} as the most significant digit, and {Li,j} as the least significant digit (base n)

Note: In the following discussion, all matrix entrys are written as a value relative to the average entry in a magic square. That is, {Li,j} = relative value + (1/2)(n-1).

### The high-order square

Let H be the unbordered Cayley table of the group Z(n) under addition, permuted so that the back-diagonal consists entirely of 1/2(n-1)'s.

H is called a doubly diagonal latin square, because each entry appears exactly once in each row, column and diagonal. From the border of sums we notice that having this latin property means the square is "magic" in the sense that all row, column and diagonal sums are the same. However, it is not a magic square since we haven't used the integers 1 up to n2.  ### The low-order square:

If we could find a low order square L which is anti-magic in the same sense that H is magic AND is orthogonal to H, then juxtapositioning them as described above would result in a AMS(n).

To the left is such an arrangement. The numbers in pink are the final relative sums of each row, column and diagonal. Notice that they form the set {-n-1} U [-n, +n]. The heart of this scheme is in the construction of this low order square. We lay down numbers in sequence along broken diagonals like a staircase, to ensure orthogonality with the high-order square. Go grab some coloured pens and some graph paper and follow along as we work through this 9x9 example.

Four groups of staircases work together to form this square, represented by different background colours:

### Red - The Anti-Magic

We start by putting the integers 0 to n-1 in ascending order along the back diagonal, beginning at the center. This gives two sets of consecutive integers and puts the low-order magic constant (zero) in the upper right corner. Also note that we've contributed -1/2(n-1) to the main diagonal sum.

### Blue - The Filler

The blue's job is to disturb things as little as possible. That is, together they must act as if they were composed completely of the average element, thus contributing zero to the relative values.

We construct them in groups of four1, arranged in staircases surrounding the back diagonal. Notice how group of four adds up to zero row-wise, column-wise, and along the main diagonal. This very special arrangement can always be achieved, no matter what order nor offset from the back diagonal.

Proceed in the following way: Build a layer of two staircases on both sides of the red back diagonal. Start with the top layer. Place a zero (the average entry) at the intersection with the main diagonal, then a one above and to the right of it. Continue in this way, placing entries in ascending order as you move up and to the right. Remember that -n follows n and that moving off the top or side of the grid lands you back at the bottom or opposite side respectively.

Now build this staircase's mate. It should fit in between the blue we just made and the red. Let each entry be the additive inverse of the entry one unit to the left. In other words, arrange it so that the row sum of the two blues is always zero. Notice that the column sums are not zero -- that's where the next two blue staircases come in.

These will be constructed on the other side of the red back diagonal. They will have the same row-wise additive inverse property as the first set of two blues. Also each entry must be the additive inverse of the blue entry three rows above it. Such an arrangement amounts to shifting the our previous blues down three rows and transposing it (flip along the main diagaonal axis).

Continue placing self-complementing layers on each side of the back diagonal until there are only four diagonals in the grid left unfilled. Blue serves to scale the square to the desired size -- Use as many as it takes (n-5 staircases) to flesh out the square.

Notice that, by construction, we have contributed zero to the row and column sums, plus the main diagonal.

1. This is why the odd construction breaks down into two cases modulo 4.  ### Green & Turquoise - The projection

If you wrote out the square at this point, using absolute entry's, you'd see we have identical sets of consecutive integers as the row and column sums, with the magic constant on the back-diagonal. The consecutive numbers were created by the red staircase, and moved into the right range by the blues. Now all we have to do is map both sets [-a, +a] onto [-n,+n] - {0}. Also we need to get a -n-1 on the main diagonal.

That's a lot to ask for, but backtracking using the ams3 program shows that there is a systematic way to use four staircases of consecutive integers to do this mapping for any order n.

(See examples of orders 5, 9, 13 & 17)

In H, all elements along broken diagonals are the same. In L, every symbol appears exactly once in every broken diagonal. Therefore, every ordered pair of symbols occurs exactly once among the n2 pairs (Hi,j, Li,j)

This next page shows you how to piece it together.

Composed by John Cormie Updated: July 21 1999