Order-4, Transformations & Patterns

Magic Squares Home Home Page Magic Stars Home But_Patt.gif (1837 bytes)

Introduction

A brief introduction this page and it's contents.

Order-4 groups

The 880 order-4 magic squares may be classified into 12 groups.

Normalized position & Magic Lines

A method for indexing and enumerating. Explanation of sequence patterns.

More on Magic Lines

Examples and a more in-depth discussion.

Complementing

A method of transforming one magic square into another one. Any order.

Swapping rows and columns

Several of these methods will always produce a square in the same or a different group.

Pandiagonal m. s. Transformations

Shown here is one of the 3 sets of 16 magic squares related by cyclic row and column changes.

Associated m. s. Transformations

15 methods to transform one order-4 associated magic square into another one.

Transformation between groups

Between groups I and III by swapping quadrants and rows. Between groups with like number of magic squares by row and column permutation.

More Order-4 Transformations

Includes a table listing and comparing 32 different order-4 transformations.

Summary

A summary of more then 45 order-4 transformations. Also included on this page - 12 binary digit transformations.

Ralph Fellows

His base-4 digit manipulation transformations. Also a 4 magic square loop.

The Order-4 magic squares

Dudeney group patterns. Groups I, II, III, XI and XII in magic square format.. All 880 magic squares in index order, in a tabular list format.

Introduction

On this page I will discuss ways of transforming one magic square into another one. Also I will discuss various patterns and the use of patterns for classification.

The magic squares discussed will all be order-4 because;

  1. The only order for which all magic squares are known (except for the one order-3).
  2. There are a suitably large number of magic squares to work with.
  3. The small size makes it quicker to form the magic squares and easier to see the patterns.

Methods described here may be extended to work with higher orders.

The transformations discussed will be from pure magic squares (those using numbers from 1 to 16) to pure magic squares.
However, it is worth mentioning here that any magic square may be converted to another magic square (not pure) simply by applying any constant to each number in the square using any arithmetic operator. In many cases, if a constant is applied to the units digit of each number, and a different constant applied to the ten's digit of each number, the result will also be a magic square.

The transformation principles may be extended also to work with higher dimensions (cubes, tesseracts, etc).

Two sources for the complete set of order-4 magic squares are:
W. H. Benson & O. Jacoby, New Recreations With Magic Squares, Dover Publications, Inc, 1976, 0-486-23236-0
Matsumi Suzuki's Magic Squares web page are now found in the MathForuml
(Note however that Suzuki's list is not normalized or in index order.)
Since this page was originally written, I have written and ran a program to find all order-4 magic squares.
The various lists may be found from my Order-4 Lists page.

rule-w.gif (2718 bytes)

Order-4 groups

There are 880 basic magic squares of order-4. The complete set was published in 1693. (Frénicle de Bessey, Des Quarrez Magiques. Acad. R. des Sciences).
They were classified into 12 groups by H. E. Dudeney and first published as such in The Queen, Jan. 15, 1910. It (the classes) appeared later in Amusements in Mathematics, 1917 published by Thomas Nelson & Sons, Ltd.

Dudeney-1.gif (2186 bytes)
Group I
Dudeney-2.gif (2126 bytes)
Group II
Dudeney-3.gif (2205 bytes)
Group III
Dudeney-4.gif (1935 bytes)
Group IV
Dudeney-5.gif (2236 bytes)
Group V
Dudeney-6.gif (2123 bytes)
Group VI
Dudeney-7.gif (2153 bytes)
Group VII
Dudeney-8.gif (2203 bytes)
Group VIII
Dudeney-9.gif (2054 bytes)
Group IX
Dudeney-10.gif (2297 bytes)
Group X
Dudeney-11.gif (2145 bytes)
Group XI
Dudeney-12.gif (2307 bytes)
Group XII

The 12 groups
The 12 groups are classified by the patterns formed by the 8 complement pairs.
A complement pair is two numbers that together sum to n2 + 1. For order-4 that number is 17.

Group Characteristic # of basic magic squares
I Pandiagonal 48
II Semi-pandiagonal 48
III Semi-pandiagonal & Associative 48
IV Semi-pandiagonal 96
V Semi-pandiagonal 96
VI Semi-pandiagonal 96
VI Simple 208
VII Simple 56
VIII Simple 56
IX Simple 56
X Simple 56
XI Simple 8
XII Simple 8
Some comments
  • Group VI has some semi-pandiagonal and some simple magic squares.
  • All groups are vertically symmetrical and all except XI and XII are horizontally symmetrical.
  • Group III has all complement pairs symmetrical around the center of the magic square.

Be aware that for some of the normalized magic squares and in some of the transformations to follow, the Dudeney pattern will be rotated from that shown here.

Similar patterns may be formed for higher orders as well, although Dudeney only published those for order-4.

Top.gif (1256 bytes)rule-w.gif (2726 bytes)

Normalized position & Magic Lines

Any magic square can appear in 8 different aspects due to rotations and reflections. For enumeration purposes, one of these 8 squares must be designated as the fundamental or basic one. The other 7 are often referred to as disguised versions of this one.

Frénicle # 175
Four_2.gif (1976 bytes)
A.
Rotated 90°
Four_2-b.gif (1971 bytes)
B.
Rotated 180°
Four_2-c.gif (1979 bytes)
C.
Rotated 270°
Four_2-d.gif (1971 bytes)
D.
Dudeney group III
Dudeney-3.gif (2205 bytes)

E.
Horizontal Reflection
Four_2-e.gif (1964 bytes)
F.
Vertical Reflection
Four_2-f.gif (1971 bytes)

G.
Vertical then 90°
Four_2-g.gif (1971 bytes)
H.
Horizontal then 90°
Four_1.gif (1976 bytes)
I. Dürer  square
Magic line pattern
Lines_4-1.gif (2045 bytes)
J. for square A.

Here we use Frénicle's # 175 as an example to illustrate how one fundamental magic square can also appear in 7 disguised versions. All 8 aspects are Dudeney group III so are associated magic squares.
Note that whether the magic square is rotated right or left is arbitrary. Here I use right (clockwise) rotation.
H. may also be considered as reflected around the leading diagonal and I. as being reflected around the right diagonal .
I. is the magic square from Albrecht Dürer’s engraving, Melancholia, 1514.

 Lines_4-1b.gif (1712 bytes) The magic line pattern  at J. is constructed by following the magic square numbers of A.  in sequence. To the left is the same diagram with some of the areas filled in. This may be done in various ways to produce artistic designs.
As well as making pretty patterns, these are sometimes used for classification purposes.
Jim Moran has a lot of material on these in The Wonders of Magic Squares, Random House, 1982, 0-394-74798-4.
He refers to these as sequence designs.

Normalized position

For enumerating and listing the magic squares of a given order, one of the eight above positions must be designated the normal position. This standard prevents confusion and permits easy comparison. Frénicle established two simple rules to determine the standard position for order-4. These same rules may be used for all other orders as well.

  1. The smallest number in any corner of the magic square must be in the top left corner. If it is not, rotate the square until it is.
  2. The second number in the top row must be of lower then the first number in the second row. These are the two numbers adjacent to the one in the top left corner.

Notice that magic square A. (# 175 above) and  # 727 (below) satisfy these two conditions.

I put a lot of emphasis on the use of index numbers. Otherwise, in comparing lists or tables of magic squares published by different authors, the casual observer is liable to think that the lists are not the same. Magic squares obtained by  transformations are usually not normalized. I generally indicate them as disguised and give the index numbers.

rule-w.gif (2726 bytes)

More on Magic Lines

Normally magic lines are drawn between the centers of the cells. However, this sometimes results in a longer line hiding a shorter one.
Shown here are two versions of magic line diagrams for magic square #727 (Group VIII).
For interest, each is also shown with some areas filled in, forming a type of abstract art.

Four_11.gif (1976 bytes) Lines_4-11a.gif (2067 bytes) Lines_4-11b.gif (1731 bytes) Lines_4-11c.gif (2101 bytes) Lines_4-11d.gif (1758 bytes)

In the first line diagram, notice that the top line from 12 to 13 is covered up by the line from 4 to 5. In fact, it looks like the line goes from 4 to 12 to 13 to 5.
Likewise the left line looks like it is going from 14 to 1 to 15.
These concerns are resolved by offsetting the necessary lines as I did with the second diagram.
Which  method is actually used is a matter of personal preference. The first method looks tidier because all points appear as on a regular grid pattern. The second method gives a truer picture.

 Top.gif (1256 bytes)rule-w.gif (2726 bytes)

Complementing

Any order of magic square may be transformed to another magic square simply by subtracting each number in turn from
n2 + 1.
The resulting magic square is a disguised version of another magic square belonging to the same group.

A.
Four_12-a.gif (1976 bytes)
#202            XI
B.
Four_12-b.gif (1975 bytes)
Complement of A.
C.
Four_12-c.gif (1975 bytes)
B. Normalized = #724
D.
Dudeney-11.gif (2145 bytes)
Group XI
E.
Four_12-d.gif (2176 bytes)
Line pat. for A. & B.

The resulting magic line diagram will be exactly the same for the original and the complement magic squares. You simply move around it in the opposite direction. However, it requires rotation for the normalized version of the complement.
This may be considered complementing the magic square. Robert Sery refers to the process as complementary pair interchange (CPI).

When complementing some magic squares you end up with the original square except that it is rotated or reflected. Any order of associated (group III) magic square is of this type and the complement will be rotated 180 degrees. Any magic square with a complementary pair pattern like that of group VI also has this self-similar pattern with the complementary reflected either vertically or horizontally, depending on the orientation of the pattern. See my Self-similar page for more information on this type of magic square.

 Top.gif (1256 bytes)rule-w.gif (2726 bytes)

Swapping rows and columns

Complementing each number in a magic square will ALWAYS produce a magic square in the same group.
The following row and column swaps will also always produce an order-4 magic square.
Swap rows and columns 1 and 4
Swap rows and columns 2 and 3.
Change row and column orders to 2, 1, 4, 3.
Change row and column orders to 3, 1, 4, 2.
However, the resulting magic square is likely to belong to a different group. See the bold lines in the Summary table.

rule-w.gif (2726 bytes)

Transformations from a pandiagonal magic square

A. # 204 is the pandiagonal magic square example used in this section.
B. is it's complement, # 744 (disguised). All pandiagonal magic squares create new pandiagonals when complemented.
C. is the magic square obtained by adding 8 mod(16) to each number. It also is a disguised # 744. However, complementing   and adding 8 mod(16) to each number sometimes give different magic squares. See. # 117 whose complement is # 483 and  +8 is # 646.
D. is obtained by exchanging the two outside columns and also the two outside rows. However, it is no longer pandiagonal but a group II, (# 63 disguised). Any magic squares can be transposed to another with this method.
E. is the Dudeney pattern for all pandiagonal (group I) magic squares.
F. is the magic line pattern for the example, # 204. Other pandiagonal magic squares will have other patterns.

A. #204        I
Four_13-a.gif (1988 bytes)
B. #744        I
Four_13-b.gif (1986 bytes)
C. #744        I
Four_13-c.gif (1979 bytes)
D. #63           II
Four_13-d.gif (1984 bytes)
E. Type I
Dudeney-1.gif (2186 bytes)
F. for # 204
Four_13-e.gif (2134 bytes)

Following is a set of 15 transformations that work only with pandiagonal magic squares and result in other pandiagonal magic squares.
Here we move a row from the top to the bottom of the magic square, a column from the left to the right, or both a row and a column.
All of these magic squares are disguised except # 469, and of course, the original, # 204.
I have used leading zeros simply to allow simpler formatting.

Rows/columns             No
                          column change            1 col.                     2 col.                    3 col.

no row change   Original # 204       # 109                     #396                      #294
                           01  14  11  08       14  11   08  01       11  08  01  14        08  01  14  11
                           15  04  05  10       04   05  10  15       05  10  15   04       10  15  04  05
                           06  09  16  03       09  16   03  06       16  03  06  09        03  06  09  16
                           12  07  02  13       07   02  13  12       02  13  12   07       13  12  07  02

1 row                   # 171                    #107                      #691                      #788
                        
  15   04  05  10       04  05   10  15       05  10  15  04        10  15  04  05
                           06   09  16  03       09  16  03   06       16  03  06  09        03  06  09  16
                           12   07  02  13       07  02  13   12       02  13  12  07        13  12  07  02
                           01   14  11  08       14  11  08   01       11  08  01  14        08  01  14  11

2 rows                 # 560                     #621                      #744                      #469
                           06   09  16  03       09  16  03   06       16  03  06  09        03  06  09  16
                           12   07  02  13       07  02  13   12       02  13  12  07        13  12  07  02
                           01   14  11  08       14  11  08   01       11  08  01  14        08  01  14  11
                           15   04  05  10       04  05  10   15       05  10  15  04        10  15  04  05

3 rows                 # 532                     #839                      #355                      #292
                       
   12   07  02  13       07  02  13   12       02  13   12  07       13  12  07  02
                           01   14  11  08       14  11  08   01       11  08  01  14        08  01  14  11
                           15   04  05  10       04  05  10   15       05  10  15  04        10  15  04  05
                           06   09  16  03       09  16  03   06       16  03  06  09        03  06  09  16
This set contains 16 magic squares out of the 48 pandiagonal magic squares of order-4. Thus all 48 pandiagonal magic squares can be derived from 3 essentially different magic squares.
Any one of these 16 magic squares could be considered to be the origin of the set of 16. If the lowest index number is taken as the starting square, then the other two sets of 16 would start with #104 and # 116.

Top.gif (1256 bytes)rule-w.gif (2726 bytes)

Transformations between associated magic squares

Here are 15 ways to transform an associated magic square to another associated magic square (there are many more).
The result is 10 different group III magic squares with 5 of these appearing twice.
Complementing is not included here because, as mentioned previously, you obtain only a disguised version of the original.
The original is normalized as are 2 of the resulting magic squares. The other 13 are all disguised versions of their index number.

#126     III            #124 Exchange           #206 Exchange           #183 Exchange rows

Original                rows  1 and 4          columns 1 and 4          and columns 1 and 4

 1  8 15 10               7  2  9 16              10  8 15  1              16  2  9  7

14 11  4  5              14 11  4  5               5 11  4 14               5 11  4 14

12 13  6  3              12 13  6  3               3 13  6 12               3 13  6 12

 7  2  9 16               1  8 15 10              16  2  9  7              10  8 15  1



#206 Exchange        #478 Exchange rows      #308 Swap col. 1 and 2     #632 Swap rows and

columns 2 and 3     1 and 2 with 3 and 4       with col. 3 and 4       col. 1 and 2, 3 and 4

 1 15  8 10              12 13  6  3              15 10  1  8               6  3 12 13

14  4 11  5               7  2  9 16               4  5 14 11               9 16  7  2

12  6 13  3               1  8 15 10               6  3 12 13              15 10  1  8

 7  9  2 16              14 11  4  5               9 16  7  2               4  5 14 11



#124  Exchange       #789 Move quadrants      #289 Move quadrants         #632 Swap kitty-

rows 2 and 3              clockwise            counter-clockwise          corner  quadrants

 1  8 15 10              12 13  1  8              15 10  6  3                6  3 12 13

12 13  6  3               7  2 14 11               4  5  9 16                9 16  7  2

14 11  4  5               6  3 15 10               1  8 12 13               15 10  1  8

 7  2  9 16               9 16  4  5              14 11  7  2                4  5 14 11



#183 Swap columns       #478 swap rows          #395 swap columns        #741 Swap columns and

and rows 2 and 3       1 and 2, 3 and 4         1 and 2, 3 and 4        rows 1 and 2, 3 and 4

 1 15  8 10              14 11  4  5              15  1 10  8                4 14  5 11

12  6 13  3               1  8 15 10               4 14  5 11               15  1 10  8

14  4 11  5               7  2  9 16               6 12  3 13                9  7 16  2

 7  9  2 16              12 13  6  3               9  7 16  2                6 12  3 13
rule-w.gif (2726 bytes)

Transformation between groups

In almost all cases, the resulting magic square will be a disguised version of the index number shown.

Between Group I and II by exchanging rows 2 and 3 and columns 2 and 3.
Each of the 48 group I magic squares transforms to one of the 48 group II.
In this and all following cases the transformation works in reverse, so in this case, group II can also be transformed to group I

#171        I
Four_14-b.gif (1987 bytes)
Group I
Dudeney-1.gif (2186 bytes)
Exchange rows 2 & 3
Four_18-a.gif (1984 bytes)
and col. 2 & 3 = #57
Four_18-b.gif (1977 bytes)
Group II
Dudeney-2.gif (2126 bytes)

The same result is obtained by swapping rows and columns 1 and 4 instead of 2 and 3. The same index number magic square is obtained but it is a reflected version.

rule-n.gif (1968 bytes)

Between Group II and III by exchanging rows 1 and 3 and columns 1 and 3.
Each of the 48 group II magic squares transforms to one of the 48 group III.

#213        II
Four_19-a.gif (1986 bytes)
Group II
Dudeney-2.gif (2126 bytes)
Exchange rows 1 & 3
Four_19-b.gif (1986 bytes)
and col. 1 & 3 = # 808
Four_19-c.gif (1982 bytes)
Group III
Dudeney-3.gif (2205 bytes)

The same result is obtained by swapping rows and columns 2 and 4 instead of 1 and 3. This time a different magic square is obtained. From #213 it would be #361. 

rule-n.gif (1968 bytes)

Between Group I and Group III using quadrants to rows or rows to quadrants.
There are 48 magic squares of Group I and 48 of Group III. Each of these may be transformed from one type to a magic square of the other type by the following procedure. See A. and B. Use the same procedure but start at a different number in the quadrants (or rows) to get three more squares of the second type from the one original.

A. #183       III
Four_14-a.gif (2469 bytes)
B. #171         I
Four_14-b.gif (1987 bytes)

Using #183  Group III for our original, construct #171 Group I by taking the four numbers in turn from each quadrant to form the four lines of # 171. C. and D. are the Dudeney patterns for the two magic squares.
E. F. and G. illustrate how we can get three more pandiagonal magic squares from the same associated magic square, by simply starting at a different cell in the original.
C.  Type III
Dudeney-3.gif (2205 bytes)
D. Type I
Dudeney-1.gif (2186 bytes)
E. #204         I
Four_14-c.gif (1977 bytes)
F. #532         I
Four_14-d.gif (1983 bytes)
G. #560         I
Four_14-e.gif (1973 bytes)
H. #171         I
Four_14-b.gif (1987 bytes)
J. #183         III
Four_14-a.gif (2469 bytes)
#808        III
Four_14-f.gif (1983 bytes)
#698        III
Four_14-g.gif (1986 bytes)
#361        III
Four_14-h.gif (1980 bytes)

Those first 4 pandiagonal magic squares were obtained by starting with quadrant a. of the original associated magic square. By repeating the procedure but starting with quadrant b., then c. and finally d., 12 more pandiagonal magic squares are obtained. In fact we end up with the same set of 16 squares that were obtained by shifting rows and/or columns (proceeding section).

The bottom row illustrates how by reversing the process, four associated magic squares can be formed from one pandiagonal magic square.
Simply form the 4 quadrants of J. in turn from the 4 rows of H. to get back to the original associated square. The other 3 squares are formed by starting each quadrant from a different  position in the row. And by starting with a different quadrant we end up with 16 associated magic squares generated by 1 pandiagonal.
If we try the same procedure on any of the other 15 pandiagonal magic squares obtained above, we obtained disguised versions of the same 16 associated magic squares.

Another method (not shown). Exchange the last two columns, then exchange the last two rows, to convert magic squares between Group I and Group III.

rule-n.gif (1968 bytes)

Between Group IV and Groups V and VI interchanging rows (and columns)
There are 96 magic squares of Group IV. Each of these may be transformed to one of the 96 magic squares of Group V and to one of the 96 magic squares of Group VI. Here we use Group IV #251 as  an example.

#251     IV
Four_15-a.gif (2264 bytes)
Group IV

Dudeney-4.gif (1935 bytes)
exchange rows
Four_15-b.gif (2249 bytes)
& columns = # 356
Four_15-c.gif (2253 bytes)
Group V

Dudeney-5.gif (2236 bytes)
To transform from a Group IV to a Group V simply exchange rows 2 & 3 and columns 2 & 3.

To transform from a Group IV to a Group VI simply exchange rows 2 & 4 and columns 2 & 4.

Exchange rows
Four_15-d.gif (2253 bytes)
& columns = #227
Four_15-e.gif (2252 bytes)
Group VI

Dudeney-6.gif (2123 bytes)

Note that this transformation works in both directions i.e. also from V or VI to IV.
However, for Group VI,  it works only on the 96 that are semi-pandiagonal. On the 208 simple magic squares of order-VI, the result of  this transformation is only semi-magic.

rule-n.gif (1968 bytes)

Between Group VII and Groups VIII, IX and X
There are 56 magic squares of Group VII. Each of these may be transformed to magic squares of Groups VIII, IX or X by simple permutation of  rows and columns.

#717      VII
Four_16-a.gif (2253 bytes)
Group VII

Dudeney-7a.gif (1940 bytes)
change row order
Four_16-b.gif (2251 bytes)
& columns = # 332
Four_16-c.gif (2240 bytes)
Group VIII

Dudeney-8a.gif (2013 bytes)
To transform from a Group VII to a Group VIII   change row and column order to 3, 1, 4, 2.

To transform from a Group VII to a Group XI  change row and column order to 2, 1, 4, 3.

To transform from a Group VII to a Group X  exchange rows 2 & 3 and columns 2 & 3.

Note that for each of these four magic squares the Dudeney pattern is rotated 90 degrees from that shown by Dudeney (although in the case of #373, if the square is normalized the Dudeney pattern would be correctly orientated).

change row order
Four_16-d.gif (2260 bytes)
& columns = # 373
Four_16-e.gif (2253 bytes)
Group IX

Dudeney-9a.gif (1976 bytes)
exchange rows
Four_16-f.gif (2260 bytes)
& columns = # 652
Four_16-g.gif (2266 bytes)
Group X

Dudeney-10a.gif (2041 bytes)

rule-n.gif (1968 bytes)

Between Group XI and Group XII
There are 8 magic square each of Groups XI and XII. Magic squares of one group may be transformed to magic squares of the other group by exchanging rows 2 & 4 and columns 2 & 4.

#374       XI
Four_17-a.gif (2255 bytes)
Group XI

Dudeney-11.gif (2145 bytes)
exchange rows
Four_17-b.gif (2263 bytes)
& columns = # 209
Four_17-c.gif (2252 bytes)
Group XII

Dudeney-12.gif (2307 bytes)

rule-w.gif (2726 bytes)

Please send me Feedback about my Web site!Top.gif (1256 bytes)home07.gif (2303 bytes)003l.gif (305 bytes)Aro_up.gif (318 bytes)Aro_right.gif (304 bytes)

Last updated September 01, 2009
Harvey Heinz  harveyheinz@shaw.ca
Copyright © 1998, 2000 by Harvey D. Heinz