This is an old revision of the document!
Table of Contents
Definition of subsets
We introduce some terminologies here to divide the whole set of magic squares into small subsets.
A magic set and its binary representation
- We define a magic set of order n as a set of n distinct integers in the range [1..n2] whose sum is equal to the magic sum ( ( n2 + 1 ) * n ) / 2.
- Examples:
- { 2, 9, 4 } is a magic set of order 3.
- { 10, 7, 14, 3 } is a magic set of order 4.
- Any set of distinct positive integers { a1, a2, a3 … } can be represented as an integer whose value is equal to 2a1-1 + 2a2-1 + 2a3-1 + … . We call it the binary representation of a distinct integer set.
- Examples:
- { 2, 9, 4 } is represented as 1 0000 10012 = 0x10b.
- { 10, 7, 14, 3 } is represented as 0010 0010 0100 01002 = 0x2244.
Order on distinct integer sets
- We can define order on sets of distinct integers in accord with the order of their binary representation.
- Example:
- A magic set { 5, 16, 2, 11 } is larger than { 12, 1, 15, 6 } because their binary representations are 1000 0100 0001 0010 ( = 0x8412 ) and 0100 1000 0010 0001 ( = 0x4821 ), respectively, and 0x8412 > 0x4821.
Complement of a magic set
If you replace each element a of a magic set by n2 + 1 - a , the result is also a magic set. We call the resulting set the compliment of the original magic set.
- Examples in the case of order 4:
- { 12, 1, 15, 6 } is the compliment of { 5, 16, 2, 11 }.
- { 7, 10, 3, 14 } is the compliment of itself.
In binary representations, the compliment of a magic set is obtained by the bit reverse manipulation.
- Example in the case of order 4:
- The compliment of 1000 0100 0001 0010 is 0100 1000 0010 0001.
The representative line of a magic square
Every row and column of a magic square always forms a magic set. We define the representative line of a magic square as the largest magic set which forms a row, a column, compliment of a row, or compliment of a column and classify magic squares by their representative lines. This classification is invariant under rotations, reflections, and the compliment transformation. Note that diagonal or counter-diagonal magic set is not considered the representative line.
Example:
