# Associative Magic Squares

## Description

Every pair of cells symmetrically opposite from the center is a complementary pair,
for example, (a,a), (b,b) in these order 4 and order 5 patterns: ## Construction

AssociativeSquares makes these squares. It uses the methods outlined below. Associative squares can also be made with MagicSquares, the CompleteSquare utility, and MagicSquaresSODLS.

Order5Special makes all the order 5 associative squares.

## Odd Order

These squares can be made with the Siamese method. See "Demanding the square is associative" in math behind the Siamese method.

There are 48,544 order 5 associative magic squares. These are group 7 of the Complement Pair Pattern Groups.

There are 1,125,154,039,419,854,784 order 7 associative magic squares.
The number was determined by Go Cato in 2018.

See OEIS A081262. ## Singly-Even Order

There are no associative magic squares of singly-even order.

### Proof

This was shown by C. Planck in 1919.

A proof similar to that of Planck can be given directly for associative squares, (without involving pandiagonals). Let n be the order of the square, m = n/2, and Σ the magic sum. Consider a 4k+2, k≥1, square where (a A), (b B), ... are complement pairs and W, X, Y are the sums of square quarters: ```  Summing rows:             W + X = mΣ
Summing columns:          W + Y = mΣ
Summing complement pairs: X + Y = mΣ
```

Thus, W = X = Y = mΣ/2 = 2m⁴ + m²/2 which cannot be, because if m is odd, m²/2 is fractional.

### Near-associative

There are singly-even magic squares in which only two complement pairs are not center symmetric.
This is the minimum, because if one pair is not center symmetric, at least one other pair must not be.

AssociativeSquares makes these squares based on Conway's LUX method.

To get near-associative squares of order n = 4k+2:

• create an associative magic square for the (2k+1)x(2k+1) array
• replace each value v in this array by V = 4(v-1)+1
• use a modified LUX pattern to make the cells in each 2x2 block of the 4k+2 square symmetric with their complements in the symmetric 2x2 block
• fill each 2x2 block with V, V+1, V+2, V+3 in the order given by the pattern letter: where, for example, L' is the symmetric complement of L.

Possible patterns for n = 6, 10, 14, 18 are: Orders 6, 14, 22, 30, ... and 10, 18, 26, 34, ... have similar patterns, (differences shown in blue).

This gives a semi-magic square with only two complement pairs not center symmetric.
Swap appropriate row(s) or column(s) to make the square magic. ## Doubly-Even Order

See "Method of constructing a magic square of doubly-even order" in Magic square.

There are 48 order 4 associative magic squares. These are TYPE III in the classification by Dudeney. ## Transforms

Associative squares remain associative, not only under Transform 1 and Transform 2, but by swapping only the described rows or columns. So, from each even order associative square, the total number of resulting squares is:

2n-2(n/2)!2

For odd order, the number is that for order n - 1.

```         Order     Transforms1_2All    Swap Rows or Columns Only
--------   ------------------  ---------------------------
4,  5                  4                        16
7                 24                       576
8,  9                192                    36,864
11              1,920                 3,686,400
12, 13             23,040               530,841,600
``` ##### REFERENCES

Dudeney, Henry E. "Magic Square Problems"
https://archive.org/details/AmusementsInMathematicspdf

Heinz, Harvey "Order 4 Magic Squares"
http://www.magic-squares.net/order4list.htm#The 12 Groups

Hospel, Ton "The math behind the Siamese method of generating magic squares" http://www.xs4all.nl/~thospel/siamese.html

Kato, Go "The number of associative magic squares of order 7"
https://oeis.org/A081262/a081262.pdf

Planck, C. "PANDIAGONAL MAGICS OF ORDERS 6 AND 10 WITH MINIMAL NUMBERS."
http://www.jstor.org/stable/27900742?seq=1#page_scan_tab_contents

Trump, Walter "Notes on Magic Squares" http://www.trump.de/magic-squares/index.html

Weisstein, Eric W. "Associative Magic Square." From MathWorld--A Wolfram Web Resource.
http://mathworld.wolfram.com/AssociativeMagicSquare.html