This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
Regular prime number, magic squares are constructed in an orderly manner composed of magic carpets (Latin squares) with the following properties:
Irregular. Panmagic squares which cannot be decomposed into regularly patterned Latin squares are called Irregular PanMagic Squares. Mutsumi Suzuk has recently described Abe Gakuho's construction technique for these squares which he called Pairwise Exchange.
Regular prime number panmagic squares decompose into two Magic Carpets  or Latin Squares if they are presented as letters. Although the smallest magic square (order3) is not panmagic it has the advantage that its decomposition is easily visualized. In addition, so can the subsequent assembly of the Latin squares into one GraecoLatin square.

= 3 x 

+ 


Latin Squares: 

+ 

= 

The two Latin squares are identical but rotated. They cannot be panmagic because the "Knight's" move is stunted to a 1x1 step and consequently produces diagonals which may be magic but never panmagic  the broken diagonals cannot add to the magic total. With larger prime number magic squares, there are more options.
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
Prime number Latin squares are made with "Knight's moves"  two steps forward and one to the side (2x1). A generalized Knight's move consists of any length of step forward and one step to the side, e.g., 1x1, 2x1, 3x1, 4x1, etc. For an orderN magic square, there are N1 knight's moves and, therefore, N1 "Orthogonal" Latin Squares:







These order7 squares (above) provide a convenient illustration  big enough but not overwhelming. Of these, 1 to 6 are Latin squares but the first and sixth are not panmagic because their steps produce diagonal rows of letters. Eliminating three leaves four panmagic Latin squares – 2, 3, 4, and 5. They are mutually orthogonal and can be combined to make "GraecoLatin" squares. Therefore, the total number of PanMagic Latin Squares (L) for prime order N is:
L = N  3 = 4
Observe that, despite using increasing steps, all four of these panmagic squares (2, 3, 4, 5) actually contain a 2x1 step in one or other axis. They are a related group. This will be important when we analyze the Fewest Representative GraecoLatin Squares below.
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
A GraecoLatin square is made from a pair of orthogonal Latin squares. Each one of the L Latin squares can combine with all the others (L  1). Because L = N  3, the total number of GraecoLatin squares (G) is:
G = ( N  3 ) x ( N  4)
For order7: G = ( 7  3 ) x ( 7  4 ) = 12
To make Regular PanMagic Magic Squares, numbers are substituted for the letters in each GraecoLatin square, e.g., in the order7 square, for the first letter in each cell, the numbers 0  6 can be substituted  a total of 7! (= 7x6x5x4x3x2) options. Similar considerations apply to the second letter. For the order7 square, therefore, there are (7!)^{2} panmagic squares for each Graecolatin square. The total number of PanMagic squares (P) is:
P = ( N  3 ) x ( N  4) x ( N ! )^{2}
For order7: P = ( 7  3 ) x ( 7  4 ) x ( 7 ! )^{2} = 304,819,200
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
The technique above properly calculates the total number of different panmagic squares; there are no duplicates if each square is constrained to stay in the same orientation with no translocation.
Huge duplication is apparent when squares are reflected, rotated, and translocated. Just by reflection and rotation, each square is present eight times; and by translocation, these groups of eight appear N^{2} times. The total number of duplicates (D) is:
D = 8 x N^{2}
For order7: D = 8 x 7^{2} = 392
A Unique PanMagic square is a normalised representative of all the duplicates. It is normalised by reflection, rotation, and translocation to put the zero in the top left square, with the smallest possible number beside it, the next smallest possible below it. When duplicates are eliminated, the number of Unique PanMagic squares (U) is:
U = ( N  3 ) x ( N  4) x ( N ! )^{2} / ( 8 x N^{2} ), or:
U = ( N  3 ) x ( N  4) x ( (N  1) ! )^{2} / 8
For order7: U = ( 7  3 ) x ( 7  4 ) x ( (71) ! )^{2} / 8 = 777,600
Translocation. Many of the duplicates arise from using ( N ! ) ^{2} in the formula for P above, which puts the zero just once in every possible cell. This is avoided by using ( (N  1) ! ) ^{2} in the formula for U, the mathematical equivalent of normalising the duplicates and keeping the zero in the top left position.
Reflections and Rotations. These rise from using all possible combinations of GraecoLatin squares. One GraecoLatin square produces two copies of each PanMagic square  oriented differently. Four related GraecoLatin squares actually produce four sets of similar pairs  which, between them, provide all eight different reflections/rotations of all the squares, i.e., any one of the four is capable of generating a sample of every Unique square.
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
Avoid the Duplication. If many of the GraecoLatin squares produce duplicates, the implied question is: "To represent the panmagic squares of orderN, what is the fewest number of GraecoLatin squares required?" For the order7 square it is a quarter (see paragraph above). However, this is too simplistic. The formula required to calculate the fewest number is more complicated:
Calculate Fewest. The Fewest Representative PanMagic squares is the number of GraecoLatin squares produced when a single representative of each group of related Latin squares is paired with just the remaining Latin squares not already paired. A "group" in this context comprises the Latin squares which contain similar Knight's move, e.g., as described above, the apparently different order7 panmagic latin squares all contain the 2x1 jump in different orientations. Any one of the four can, therefore, be chosen and combined with the remaining ones. The Fewest number is:
F = INT( N / 4 ) x ( 2 x N  INT( N / 4 )  7 ) / 2
For order 7: F = INT( 7 / 4) x (2 x 7  INT( 7 / 4)  7 ) / 2 = 1 x ( 14  1  7 ) / 2 = 3
For order11: F = INT(11 / 4) x (2 x 11  INT(11 / 4)  7 ) / 2 = 2 x ( 22  2  7 ) / 2 = 13
For order13: F = INT(13 / 4) x (2 x 13  INT(13 / 4)  7 ) / 2 = 3 x ( 26  3  7 ) / 2 = 24
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
The number of Regular PanMagic, Latin and GraecoLatin squares up to order 31 is given in the following table. The table following it summarizes the above formulae.
Numbers: (GL stands for GraecoLatin)
Order 
PanMagic Latin Squares 
All GL Squares 
Fewest GL Squares 
Total PanMagic Squares 
Dupli cates 
Unique PanMagic Squares 

N  L  G  F  P  D  U 
5  2  2  1  28800  200  144 
7  4  12  3  304,819,200  392  777,600 
11  8  56  13  8.92276 x 10^{16}  968  9.21773 x10^{13} 
13  10  90  24  3.48982 x 10^{21}  1352  2.58122 x10^{18} 
17  14  182  46  2.30254 x 10^{31}  2312  9.95911 x10^{27} 
19  16  240  54  3.55140 x 10^{36}  2888  1.22971 x10^{33} 
23  20  380  85  2.53964 x 10^{47}  4232  6.00104 x10^{43} 
29  26  650  154  5.08148 x 10^{64}  6728  7.55274 x10^{60} 
31  28  756  168  5.11169 x 10^{70}  7688  6.64893 x10^{66} 
This Page:  Construction Latin GraecoLatin Duplicates Fewest How Many Formulae 
Order of Magic Square:  N 
Number of PanMagic Latin Squares:  L = N  3 
Number of GL Squares:  G = (N  4) x (N  3) 
Fewest Representative GL Squares:  F = INT( N / 4 ) x ( 2 x N  INT( N / 4 )  7 ) / 2 
Total Number of PanMagic Squares:  P = ( N  3 ) x ( N  4 ) x ( N ! )^{2} 
Number of Duplicate PanMagic Squares:  D = 8 x N^{2} 
Number of Unique PanMagic Squares:  U = ( N  3 ) x ( N  4) x ( (N  1) ! )^{2} / 8 
Beyond order7, the number of Regular Prime Number Magic Squares are so vast that the only numbers we can begin to understand are the numbers of GraecoLatin squares. For the smaller squares the number is easy to visualize and can be fairly readily confirmed. The masses of squares which can be derived from each GraecoLatin square may all look quite different but they share the underlying Magic Carpets  their Latin Squares. For these reasons, when ennumerating the Magic Carpets and their product, counting the number of GraecoLatin squares is more fundamental.
Copyright © Mar 2010  Magic Squares Website 
Updated Mar 6, 2010 