# Affine Magic Squares

## Magic Squares and Affine Subspaces

The rows, columns, diagonals, and other "magic" features of Dürer's square can be seen to be affine subspaces or "flats", naturally sorted into groups of four parallels. It is not surprising that the rows and columns are two groups of parallel flats. One may feel surprised that the two diagonals are parallel, and that the other two flats parallel to them are what we usually call the "short broken diagonals." The "long broken diagonals" are another family of parallel flats.

A magic square is called"pandiagonal" if each of its broken diagonals adds up to the magic sum. If a 4x4 magic square is magic on short broken diagonals but not on the long broken diagonals, it is called "semi-pandiagonal." The 4x4 magic squares that are pandiagonal or semi-pandiagonal are an interesting set; following Kraitchik (p. 187), I will call them "algebraic magic squares."

In a square modeled by Fp2m , the diagonals have a different structure depending on whether p is 2 or an odd prime. In the case p=2, as we have seen, the two diagonals are parallel flats. If p is odd, however, they are flats but they are not parallel. Indeed, they intersect at the central cell of the square. We shall see that this has a mixed effect on the construction of affine magic squares.

## Magic Squares and Affine Functions

Looking at the Dürer square, we see that each base-p digit is determined by an affine function, which is non-constant on the first row, the first column, and the main diagonal. This fact is what makes the Dürer square magic. Why? Because an affine function which is non-constant on a linear subspace must take every possible value equally often on that subspace; in this case, it takes the values 0 and 1 two times each. Moreover, it has the same distribution of values on every parallel flat. Therefore, it makes a uniform contribution to the sums over all of those parallel flats.

Definition 1. An affine square over Fp2m, determined by the affine map A, is a square of order pm in which (for each u in Fp2m) position Pu contains the number C(Au); here P and C are the position map and content map respectively. The map A is the content mapping of the square, and its component affine functions are the content coordinates of the square.

For a magic square, we want the values in the square to include 0, ..., p2m-1, without omissions or repetition. We can have this, if the linear parts of the digit coordinates are linearly independent. So we make this definition:

Definition 2. A nonsingular affine square over Fp2m is an affine square, as in Definition 1, in which the digit mapping is nonsingular.

An affine map on Fp2m is nonsingular if and only if it maps Fp2m onto itself in a one-to-one way.

As we saw from the example of the Dürer square, we achieve the magic uniformity of sums of values over parallel subspaces by making the affine functions non-constant on those subspaces. Therefore we make this definition:

Definition 3. Let E be a linear subspace of Fp2m. Then an affine map A is uniform on E if each of its components is non-zero on E.

Note that if an affine map is uniform on E then, on every affine subspace parallel to E, every component of the map takes each of the values 0, ..., p-1 equally often.

Definition 4. An affine magic square over Fp2m is a nonsingular affine square, in which the content coordinates are nonconstant on the subspaces corresponding to the rows, columns, and diagonals.

The first column of the square corresponds to the linear subspace spanned by {e0 ,..., em-1}, and the first row corresponds to the linear subspace spanned by {em ,..., e2m-1}. The main diagonal corresponds to the linear subspace spanned by {e0+em ,..., em-1+e2m-1}. The other diagonal does not correspond to a linear subspace, but to an affine subspace which is parallel to the linear subspace spanned by {e0-em ,..., em-1-e2m-1}. Here we find a considerable difference between the cases p = 2 and p > 2. When p = 2, the secondary diagonal is parallel to the main diagonal. When p > 2, however, the diagonals are not parallel; indeed, they intersect. Thus the definition of an affine magic square imposes four conditions on each content coordinate when p > 2, but only three conditions when p = 2. This makes the construction of affine magic squares more difficult when p > 2.

When p > 2, we can impose a looser condition on the digit coordinates and still construct magic squares. If a digit function is constant on a diagonal subspace, then it will have different sums on the different affine subspaces parallel to that subspace. But we can choose the constant part of the affine function so that the digit coordinate will have the value (p - 1)/2 at the central position; then this digit coordinate will contribute just the right amount to the sum along each diagonal. This leads us to the following definition.

Definition 5. A semi-affine magic square over Fp2m is a non-singular affine square in which each content coordinate Ai satisfies the following conditions: it is nonconstant on the linear subspaces corresponding to the first row and the first column, and either
(a) it is nonconstant on the linear subspace corresponding to the main diagonal, or
(b) p > 2 and Ai takes the value (p - 1)/2 at the vector ((p-1)/2 ,..., (p-1)/2), which corresponds to the central cell of the square.

Below is an interactive display to construct affine squares. At the top are controls to select the values of p and m, as for the displays on the Finite Vector Spaces page. These will affect the size of a rectangular array in which you can specify the content coordinates. The square will be filled in whenever the content coordinates are completely specified.

Each content coordinate is controlled by a column in the array. It presents controls in which you can select the constant part and the value of the linear part at each of the basis vectors {e0 ,..., e2m-1}. Initially each of these values is indeterminate, represented by a dash.

If there is a linear relation between the linear parts of the content coordinates, then the affine square is singular. The display will warn you of this by reddening the labels of a set of coordinates that are related. In general, there might be several such sets; the display finds one whose rightmost member is as far to the left as possible.

If the linear part of a content coordinate is zero on either {e0 ,..., em-1} or {em ,..., e2m-1}, then the display puts a pale yellow background on that part of the array for this coordinate. Below the array of controls, there is an array of cells which show the values of the linear parts on {e0+em-1 ,..., em+e2m-1}, and light these up if they are all zero for a content coordinate. If p > 2, then there is a similar array for {e0- em-1 ,..., em- e2m-1}.

If p > 2, then one may choose the constant part of a content coordinate so as to give the function the value (p - 1)/2 at the central cell of the square. The display provides for this option by a "*" in the control corresponding to the constant part of the coordinate. When you choose the "*", and the linear part is fully determined, then the appropriate value is filled in, with a pale green background.

P: M:

Last modified on \$Date: 2015-05-02 12:51:16 -0400 (Sat, 02 May 2015) \$

Christopher J. Henrich