# An Order-5 Pandiagonal, Associative, Compact, and Self-similar Magic Square

### Introduction

The example on this page is used to show some of the number patterns that sum to the magic constant.
Also some definitions to help you understand my explanation of this square.

### The Order-5 Magic Square

See how five numbers can combine in 1128 (?) ways to sum to 65.

 Pandiagonal Associative Compact Self-similar Wrap-around 5 Symmetrical cell pairs 8 Non-symmetrical patterns

The Order-5 Magic Square

### Total combinations of five cell patterns summing to 65 = 1128 Do you arrive at the same total? (Note: see addendum for correct total)

 1 15 24 8 17 23 7 16 5 14 20 4 13 22 6 12 21 10 19 3 9 18 2 11 25
 Combination # Example Wrap Example Rows 5 1, 15, 24, 8, 17 wrap-around is not counted columns 5 1, 23, 20, 12, 9 wrap-around is not counted diagonals 10 1, 7, 13, 19, 25 includes wrap-around 15, 16, 22, 3, 9 corners of 3 x 3 squares + center 25 1, 24, 7, 20, 13 including wrap-around 12, 10, 18, 1, 24 corners of 5 x 5 squares + center 25 1, 17, 13, 9, 25 including wrap-around 23, 14, 10, 1, 17 corners of 2 x 2 rhombics + center 25 23, 15, 7, 4, 16 including wrap-around 11, 3, 25, 17, 9 corners of 3 x 3 rhombics + center 25 20, 24, 13, 2, 6 including wrap-around 2, 6, 25, 14, 18 corners of 4 x 4 rhombics + center 25 all are wrap-around 1, 22, 8, 19, 15 corners of 5 x 5 rhombics + center 25 all are wrap-around 7, 20, 23, 1, 14 Plus 58 combinations of any 2 symmetrical cell pairs plus the center cell. (see diagrams below) 1, 15, 13, 11, 25 wrap-around doesn’t work Plus 900 combinations of 8 non-symmetrical patterns (see diagrams below) 1, 8, 17, 14, 25 15, 17, 1, 23, 9

 July 31/99 Not so! See the addendum now at the end of this page, which explains a very big error in my count! I have chosen to leave the original page as is to better explain how wrap-around can cause   apparently different patterns. Nov. 29, 2012 Another Addendum This one, from Oscar Lanzi, shows the actual count is only 120 magic patterns in all pandiagonal squares, although there are more in some.

2

Definitions

Pandiagonal

Also known as Diabolic, Nasic, Continuous, Indian, Jaina or Perfect M.S. To be pandiagonal, the broken diagonal pairs must also sum to the magic constant. This is considered the top class of magic squares. Some pandiagonal magic squares are also associative (order 5 & higher) . Because of the vast number of combinations possible, individual magic squares may contain other unique features that make them more magic.
There is only 1 basic order 3 magic square and it is not pandiagonal.
Of the 880 basic order 4 magic squares, only 48 are pandiagonal and none of these are associative.
Order 5 has 3600 basic pandiagonal magic squares (Only 36 essentially different).
Order 7 has 678,222,720 basic pandiagonal magic squares. (38,102,400 regular plus 640,120,320 irregular pan-magic squares). (Order 8 has more then 6.5 billion pandiagonal magic squares.)

See Benson & Jacoby, New Recreations With Magic Squares, Dover Publ., 1976.

 1 15 24 8 17 23 7 16 5 14 20 4 13 22 6 12 21 10 19 3 9 18 2 11 25

Associative

A magic square where all pairs of cells diametrically equidistant from the center of the square equal the sum of the first and last terms of the series, or m2 + 1. Also called Symmetrical or Regular. The center cell of odd order associated magic squares is always equal to the middle number of the series. Therefore the sum of each pair is equal to 2 times the center cell and the sum of any 2 symmetrical pairs plus the center cell is equal to the constant. This permits a great many combinations (the order 5 square above has 58 of this type).
In an even order magic square, the sum of any 2 symmetrical pairs will equal the constant.
There are NO singly-even Associated magic squares.
The one order-3 magic square is associative.

 Self-similar means that when each number is changed to its complement (i.e. subtracted from m+1), an identical magic square is formed but rotated 180 degrees. This term was coined by Mr. Mutsumi Suzuki who discovered six such squares. See his excellent site at http://www.pse.che.tohoku.ac.jp/~msuzuki/  (This is now available at http://www.archive.org/  (the Wayback Machine) Wrap-around means when you go off of one edge, continue (wrap-around) to the corresponding cell on the opposite edge. The easiest way to accomplish this is to lay out the magic square in a repeating pattern on the plane as shown to the right. Then any 5 x 5 array is an equivalent pan-diagonal magic square. So, to complete a line, you can just keep going in the same direction. The red cell values  illustrate wrap-around when applied to a broken diagonal pair. Wrap-around works only with pan-diagonal magic squares.

A Symmetrical cell pair is defined as 2 cells that are symmetrical around the center cell i.e. 1 & 25, 8 & 18, 4 & 22, 7 & 19 etc. Wrap-around doesn't work with these. The 3 squares illustrate the 5 basic  pairs. Each of these may be rotated and/or reflected and used in any unique combination of 2 pairs plus the center cell.

 Note that some of these combinations are duplicates of the basic patterns counted at the start. Example; if the 2 patterns in the center diagram are lined up, this combination constitutes a main diagonal which has already been counted.

Eight Non-symmetrical patterns

The seven  patterns on the left (below) each appear 25 times because of wrap around and 4 times due to rotation ( i.e. 7 x 25 x 4 = 700).
They are symmetrical about a horizontal, vertical or diagonal axis and so cannot be reflected for unique solutions.
That pattern 1 will always be magic in an order-5 pandiagonal magic square, if it is rotated so the 3 adjacent cells are in any of the 4 corners was proven by Rosser and Walker in 1939. [1]

The pattern on the right is not symmetrical around a vertical, horizontal, or diagonal axis, so appears 25 times because of wrap around, 4 times due to rotation and 2 times because of reflection (i.e. 25 x 4 x 2 = 200).
Starting a given pattern on a different cell, in combination with a rotation or a reflection, may result in the same 5 cells being used. Example, start the first pattern with 9, 23, 1, 15, 17. Now rotate the pattern 90 degrees clockwise and start with 15,17, 1, 23, 9. Both combinations use the same 5 cells, but in a different arrangement. I consider them different combinations.
Of course, we could say the same about the use of wrap-around when computing the number of combinations for rows, columns and the diagonals. However, by convention, these extra combinations are not counted.

[1] R. Rosser and R.J Walker, The Algebraic Theory of Diabolic Magic Squares, Duke Mathematical Journal, Vol. 5, No, 4, Dec. 1939 pp 705-728 (p.717)

On June 28/99, I received an e-mail from Aale de Winkel advising me that he thought  non-symmetric pattern 1, above, was actually equivalent to the wrap-around 2 by 2 rhombic, and patterns 2 and 8 were equivalent to the wrap-around 2 by 2 square.

Subsequent investigation on my part confirmed these equivalents, and also that four of  the other five patterns are also equivalent to symmetric patterns already counted.
1. is equivalent to wrap-around 2 by 2 rhombic ( now called plusmagic --- see Quadrant Magic Squares)
2. is equivalent to wrap-around 2 by 2 square ( now called crosmagic)
3. is equivalent to wrap-around 3 by 3 rhombic corners.
4. is equivalent to wrap-around 5 by 5 square corners.
5. is just a reflected 4. (another goof!).
6. is unique, so add 100 combinations to the total.
7.
is equivalent to wrap-around 5 by 5 square corners.
8. is equivalent to wrap-around 2 by 2 square

The three diagrams below demonstrate the equivalence of  the 2 x 2 rhombic (plusmagic) and non-symmetric pattern 1.
Diagram A shows pattern 1 within the magic square and the plusmagic with two cells outside of the square. diagrams B and C show the patterns shifted down and to the right. In each of these cases, the plusmagic pattern is within the square and two cells of the pattern 1 outside.

Yet to be determined. Should the rotated non-symmetric patterns be counted and included in the total?
For now, let us say that there are 328 different combinations!
By the way. There are 1394 sets of 5 numbers, from the first 25 consecutive numbers, that sum to 65!

How many magic sums are there in a general 5x5 pandiagonal magic square? It turns out that the answer is actually just 120, not 328 or any larger number.

All 5x5 pandiagonal magic squares are regular; they are sums of two pandiagonal Latin squares. We may render these Latin squares with labels:

A1 A2 A3 A4 A5           B1 B2 B3 B4 B5
A3 A4 A5 A1 A2           B4 B5 B1 B2 B3
A5 A1 A2 A3 A4           B2 B3 B4 B5 B1
A2 A3 A4 A5 A1           B5 B1 B2 B3 B4
A4 A5 A1 A2 A3           B3 B4 B5 B1 B2

To identify a magic sum, we pick five positions in the first Latin square and the corresponding positions in the second Latin square, requiring each of the ten distinct labels (A1 through A5, B1 through B5) to appear exactly once in our selected squares. It turns out that there are just 120 ways to do this. Five are the rows, five are the columns, ten are the diagonals and the rest are “quincunx” sums in the form of plus-sign or x patterns.

There are some 5x5 pandiagonal squares with more magic sums, such as associative squares, because of additional symmetry. But these additional patterns are not general to all 5x5 pandiagonal squares and are not preserved by the transformations that preserve pandiagonality. For example, if we cyclically permute the rows of a 5x5 associative square, we no longer have an associative square. The extra sums in the associative square, beyond the 120 general ones described above, are then lost. The 120 remain.

Oscar Lanzi       November, 2012

 This page was originally posted June 1998 It was last updated November 30, 2012 Harvey Heinz   harveyheinz@shaw.ca Copyright © 1998-2009 by Harvey D. Heinz