User Tools

Site Tools


strategies

Strategies in counting magic squares

For the definitions of terminologies, see this.

Preparing 2N+2 magic series

To construct a magic square of order N, We need 2N+2 magic series for rows, columns and diagonals which satisfy the following constraints:

  • row magic series don't have common elements with each other,
  • column magic series don't have common elements with each other,
  • each row magic series shares only one element with each column magic series,
  • up/down diagonal magic series shares only one element with each row/column magic series, and
  • diagonal magic series don't have common elements for even N, and share only one common element for odd N.

With these 2N+2 magic series, we have the following freedom to rearrange them.

  1. Permuting rows (N! ways)
  2. Permuting columns (N! ways)
  3. Exchanging rows and columns (2 ways)
  4. Exchanging up and down diagonals (2 ways)

Excluding duplicates

By definition and for efficiency, we have to avoid duplicates from rotations and reflections. These transformations of order 8 can be expressed in many way, and it is convenient to adopt the following three generating transformations:

  1. reflection with respect to down diagonal line (, rows-columns exchange, or transposition)
  2. horizontal reflection
  3. 180deg rotation (or horizontal/vertical simultaneous reflection)

Duplicates from the above 1. and 2. can be eliminated using the freedom 3. and 4. in the preceding subsection, respectively. We technically assume

  • the largest row magic series is greater than the largest column magic series
  • up diagonal magic series is greater than the down diagonal magic series

Transformation 3. is a part of M-transformations and will be discussed in the last subsection.

Complementary pair

Most of magic squares have their complementary counterparts and we can save counting efforts by producing only one of pair. We, however, have to be careful in handling exceptional cases in which the complement of a magic square happens to be equivalent to the original one.

We introduce three cases in which the largest row magic series is

  1. greater than the complement of every row/column magic series,
  2. equal to the complement of a row/column magic series, or
  3. less than the complement of a row/column magic series.

We can omit counting the case 3. by doubling the count for the case 1 because the cases 1. and 3. transform into each other under the complementary transformation, In the case 2., we just count magic squares without doubling.

Eligibility for magic square

Given 2N+2 magic series satisfying the above conditions, we have not yet known whether the diagonal magic series aligned correctly. We have to check if a magic square can be constructed using the remaining freedom (1. and 2. in the first subsection ).

  • Permuting columns alone always allows us to make the down diagonal magic series aligned diagonal.
  • Permuting simultaneously rows and columns always keeps the down diagonal elements within the right positions.
  • Thus the final question is:
    • “Can we make up-diagonal magic series aligned correctly by permuting simultaneously rows and columns?”
  • The answer is “It depends”. We, however, can utilize the help of symmetry. Up diagonal line is symmetric under the row-column exchange and any simultaneous permutations for rows and columns always preserve that symmetry. We, therefore, have the following lemma.
    • Up-diagonal elements can be aligned correctly only if they are symmetric under the row-column exchange.
  • While we cannot simply claim that symmetric patterns are always transformable into the up-diagonal line (the down-diagonal line is a counter example), it is an easy task to check all symmetric patterns in which up-diagonal candidates can sit for a specific small N. We have only 15 such patterns for N=6 and all of them are transformable into the up-diagonal line. Once we find an up-diagonal candidate of one of the symmetric patterns, we obtain as many magic squares as the number of M-transformations.
  • As mentioned in the second subsection, duplicates form 180deg rotation should be eliminated, we, therefore, have the multiplicity of 24 for N=6.
strategies.txt · Last modified: 2024/04/23 13:49 by mino

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki