Messing around with some magic-square puzzles, I faced the problem of deciding whether some two magical squares are, in fact, the one and same square wearing a different hat. It seemed to me, that for this job, the proper tool would be the application of
Magic-preserving permutations
Definition: A permutation of $N^2$ items is magic-preserving, if you can use it to reorder the numbers in any magic square of size $N \times N$ so that the resulting square is guaranteed to be magical.
For example, horizontal mirroring is a magic-preserving permutation for magic squares of any size: in the mirrored square
- each row has the same numbers as before
- each column has exactly the same numbers as some column in the original square
- the diagonals are the same as in the original square, only swapped
Naming the permutations
To distinguish between the permutations, let's name them so that when applied to an alphabetical square, their name is readable from the resulting square. Again using horizontal mirroring as an example, its name is dcba-hgfe-lkji-ponm
, because it works like this:
a b c d d c b a e f g h (mirror) h g f e i j k l --> l k j i m n o p p o n m
The "identity permutation" or ("no permutation") is of course also magic-preserving, and its name is abcd-efgh-ijkl-mnop
.
With these definitions out of the way, here's finally
The puzzle: Find all of them
How many different (distinguished by having a unique name) magic-preserving permutations exist for $4 \times 4$ magic squares?
Listing all of them constitutes a valid answer, and so does counting them (convincingly) without naming any of them. Providing a general formula of the count for different N is probably worth a scientific paper, or at least a research grant of a 100 rep provided by yours truly.
Epilogue
With the help of this tool, it's easy to identify duplicate magic-square puzzle solutions: magic square A is equivalent to magic square B if (and only if) one of the squares can be created by applying a magic-preserving permutation to the other.
Magic-preserving permutations are also of "immense" "practical" use, since they can be used to significantly narrow down the search space in a magic square puzzle.
I don't know how many times this particular idea has been invented by others, and by which names. Quick googling, followed by an exhaustive search of the magic-square tag (and a cursory glance at Wikipedia) revealed nothing. :-)
The graph-theory tag is there because there's definitely something graph-y going on in here; a graph-theoretical answer isn't required, though.