Pandiagonal magic square
A pandiagonal magic square or panmagic square (also diabolic square, diabolical square or diabolical magic square) is a magic square with the additional property that the broken diagonals, i.e. the diagonals that wrap round at the edges of the square, also add up to the magic constant.
A pandiagonal magic square remains pandiagonally magic not only under rotation or reflection, but also if a row or column is moved from one side of the square to the opposite side. As such, an n×n pandiagonal magic square can be regarded as having 8n2 orientations.
3×3 panmagic squares
It is easily shown that non-trivial pandiagonal numerical magic squares of order 3 do not exist. However, if the magic square concept is generalized to include geometric shapes instead of numbers—the geometric magic squares discovered by Lee Sallows—a 3×3 panmagic square does exist.
4×4 panmagic squares
The smallest non-trivial pandiagonal magic squares consisting of numbers are 4×4 squares.
|
In 4×4 panmagic squares, the magic constant of 34 can be seen in a number of patterns in addition to the rows, columns and diagonals:
- Any of the sixteen 2×2 squares, including those that wrap around the edges of the whole square, e.g. 14+11+4+5, 1+12+15+6
- The corners of any 3×3 square, e.g. 8+12+5+9
- Any pair of horizontally or vertically adjacent numbers, together with the corresponding pair displaced by a (2, 2) vector, e.g. 1+8+16+9
Thus of the 86 possible sums adding to 34, 52 of them form regular patterns, compared with 10 for an ordinary 4×4 magic square.
There are only three distinct 4×4 pandiagonal magic squares, namely A above and the following:
|
|
These three are very closely related. B and C can be seen to differ only because the components of each semi-diagonal are reversed. It is not as easy to see how A relates to the other two but:
i: if the components of each semi-diagonal of A are reversed (A1) and the left-hand column of A1 is moved to the extreme right (A2), the result is a reflection of B
|
|
ii: if the left-hand column of A is moved to the extreme right (A3), the components of each semi-diagonal of A3 are reversed (A4), and the right-hand column of A4 is moved to the extreme left (A5), the result is C
|
|
|
In any 4×4 pandiagonal magic square, the two numbers at the opposite corners of any 3×3 square add up to 17. Consequently, no 4×4 panmagic squares are associative, though they all fulfil the further requirement for a 4×4 most-perfect magic square, that each 2×2 subsquare sums to 34.
5×5 panmagic squares
There are many 5×5 pandiagonal magic squares. Unlike 4×4 panmagic squares, these can be associative. The following is a 5×5 associative panmagic square:
20 | 8 | 21 | 14 | 2 |
11 | 4 | 17 | 10 | 23 |
7 | 25 | 13 | 1 | 19 |
3 | 16 | 9 | 22 | 15 |
24 | 12 | 5 | 18 | 6 |
In addition to the rows, columns, and diagonals, a 5×5 pandiagonal magic square also shows its magic sum in four "quincunx" patterns, which in the above example are:
- 17+25+13+1+9 = 65 (center plus adjacent row and column squares)
- 21+7+13+19+5 = 65 (center plus the remaining row and column squares)
- 4+10+13+16+22 = 65 (center plus diagonally adjacent squares)
- 20+2+13+24+6 = 65 (center plus the remaining squares on its diagonals)
Each of these quincunxes can be translated to other positions in the square by cyclic permutation of the rows and columns (wrapping around), which in a pandiagonal magic square does not affect the equality of the magic sums. This leads to 100 quincunx sums, including broken quincunxes analogous to broken diagonals.
The quincunx sums can be proved by taking linear combinations of the row, column, and diagonal sums. Consider the panmagic square
A | B | C | D | E |
F | G | H | I | J |
K | L | M | N | O |
P | Q | R | S | T |
U | V | W | X | Y |
with magic sum Z. To prove the quincunx sum A+E+M+U+Y = Z (corresponding to the 20+2+13+24+6 = 65 example given above), one adds together the following:
- 3 times each of the diagonal sums A+G+M+S+Y and E+I+M+Q+U
- The diagonal sums A+J+N+R+V, B+H+N+T+U, D+H+L+P+Y, and E+F+L+R+X
- The row sums A+B+C+D+E and U+V+W+X+Y
From this sum the following are subtracted:
- The row sums F+G+H+I+J and P+Q+R+S+T
- The column sum C+H+M+R+W
- Twice each of the column sums B+G+L+Q+V and D+I+N+S+X.
The net result is 5A+5E+5M+5U+5Y = 5Z, which divided by 5 gives the quincunx sum. Similar linear combinations can be constructed for the other quincunx patterns H+L+M+N+R, C+K+M+O+W, and G+I+M+Q+S.
(4n+2)×(4n+2) panmagic squares with nonconsecutive elements
No panmagic square exists of order 4n+2 if consecutive integers are used. But certain sequences of nonconsecutive integers do admit order-(4n+2) panmagic squares.
Consider the sum 1+2+3+5+6+7 = 24. This sum can be divided in half by taking the appropriate groups of three addends, or in thirds using groups of two addends:
1+5+6 = 2+3+7 = 12
1+7 = 2+6 = 3+5 = 8
Note that the consecutive integer sum 1+2+3+4+5+6 = 21, an odd sum, lacks the half-partitioning.
With both equal partitions available, the numbers 1, 2, 3, 5, 6, 7 can be arranged into 6x6 pandigonal patterns A and B, respectively given by:
1 | 5 | 6 | 7 | 3 | 2 |
5 | 6 | 1 | 3 | 2 | 7 |
6 | 1 | 5 | 2 | 7 | 3 |
1 | 5 | 6 | 7 | 3 | 2 |
5 | 6 | 1 | 3 | 2 | 7 |
6 | 1 | 5 | 2 | 7 | 3 |
6 | 5 | 1 | 6 | 5 | 1 |
1 | 6 | 5 | 1 | 6 | 5 |
5 | 1 | 6 | 5 | 1 | 6 |
2 | 3 | 7 | 2 | 3 | 7 |
7 | 2 | 3 | 7 | 2 | 3 |
3 | 7 | 2 | 3 | 7 | 2 |
Then 7xA + B - 7 gives the nonconsecutive pandiagonal 6x6 square:
6 | 33 | 36 | 48 | 19 | 8 |
29 | 41 | 5 | 15 | 13 | 47 |
40 | 1 | 34 | 12 | 43 | 20 |
2 | 31 | 42 | 44 | 17 | 14 |
35 | 37 | 3 | 21 | 9 | 45 |
38 | 7 | 30 | 10 | 49 | 16 |
with a maximum element of 49 and a panmagic sum of 150. This square is pandiagonal and semibimagic, that means that rows, columns, main diagonals and broken diagonals have a sum of 150 and, if we square all the numbers in the square, only the rows and the columns are magic and have a sum of 5150.
For 10th order a similar construction is possible using the equal partitionings of the sum 1+2+3+4+5+9+10+11+12+13 = 70:
1+3+9+10+12 = 2+4+5+11+13 = 35
1+13 = 2+12 = 3+11 = 4+10 = 5+9 = 14
This leads to squares having a maximum element of 169 and a panmagic sum of 850.
(6n±1)×(6n±1) panmagic squares
A (6n±1)×(6n±1) panmagic square can be built by the following algorithm.
- Set up the first column of the square with the first 6n±1 natural numbers.
Example:
1 | ||||||
2 | ||||||
3 | ||||||
4 | ||||||
5 | ||||||
6 | ||||||
7 |
- Copy the first column into the second column but shift it ring-wise by 2 rows.
Example:
1 | 6 | |||||
2 | 7 | |||||
3 | 1 | |||||
4 | 2 | |||||
5 | 3 | |||||
6 | 4 | |||||
7 | 5 |
- Continue copying the current column into the next column with ring-wise shift by 2 rows until the square is filled completely.
Example:
1 | 6 | 4 | 2 | 7 | 5 | 3 |
2 | 7 | 5 | 3 | 1 | 6 | 4 |
3 | 1 | 6 | 4 | 2 | 7 | 5 |
4 | 2 | 7 | 5 | 3 | 1 | 6 |
5 | 3 | 1 | 6 | 4 | 2 | 7 |
6 | 4 | 2 | 7 | 5 | 3 | 1 |
7 | 5 | 3 | 1 | 6 | 4 | 2 |
- Build a second square and copy the first square into it but mirror it diagonal. So you have to exchange rows and columns.
A
|
AT
|
- Build the final square by multiplying the second square by 6n±1, adding the first square and subtract 6n±1 in each cell of the square.
Example: A + (6n±1)×AT - (6n±1)
1 | 13 | 18 | 23 | 35 | 40 | 45 |
37 | 49 | 5 | 10 | 15 | 27 | 32 |
24 | 29 | 41 | 46 | 2 | 14 | 19 |
11 | 16 | 28 | 33 | 38 | 43 | 6 |
47 | 3 | 8 | 20 | 25 | 30 | 42 |
34 | 39 | 44 | 7 | 12 | 17 | 22 |
21 | 26 | 31 | 36 | 48 | 4 | 9 |
4n×4n panmagic squares
A 4n×4n panmagic square can be built by the following algorithm.
- Put the first 2n natural numbers into the first row and the first 2n columns of the square.
Example:
1 | 2 | 3 | 4 | ||||
- Put the next 2n natural numbers beneath the first 2n natural numbers in inverse sequence. Each vertical pair must have the same sum.
Example:
1 | 2 | 3 | 4 | ||||
8 | 7 | 6 | 5 | ||||
- Copy that 2×2n rectangle 2n-1 times beneath the first rectangle.
Example:
1 | 2 | 3 | 4 | ||||
8 | 7 | 6 | 5 | ||||
1 | 2 | 3 | 4 | ||||
8 | 7 | 6 | 5 | ||||
1 | 2 | 3 | 4 | ||||
8 | 7 | 6 | 5 | ||||
1 | 2 | 3 | 4 | ||||
8 | 7 | 6 | 5 |
- Copy the left 4n×2n rectangle into the right 4n×2n rectangle but shift it ring-wise by one row.
Example:
1 | 2 | 3 | 4 | 8 | 7 | 6 | 5 |
8 | 7 | 6 | 5 | 1 | 2 | 3 | 4 |
1 | 2 | 3 | 4 | 8 | 7 | 6 | 5 |
8 | 7 | 6 | 5 | 1 | 2 | 3 | 4 |
1 | 2 | 3 | 4 | 8 | 7 | 6 | 5 |
8 | 7 | 6 | 5 | 1 | 2 | 3 | 4 |
1 | 2 | 3 | 4 | 8 | 7 | 6 | 5 |
8 | 7 | 6 | 5 | 1 | 2 | 3 | 4 |
- Build a second 4n×4n square and copy the first square into it but turn it by 90°.
Square A
|
Square B
|
- Build the final square by multiplying the second square by 4n, adding the first square and subtract 4n in each cell of the square.
Example: A + 4n×B - 4n
33 | 26 | 35 | 28 | 40 | 31 | 38 | 29 |
48 | 23 | 46 | 21 | 41 | 18 | 43 | 20 |
49 | 10 | 51 | 12 | 56 | 15 | 54 | 13 |
64 | 7 | 62 | 5 | 57 | 2 | 59 | 4 |
25 | 34 | 27 | 36 | 32 | 39 | 30 | 37 |
24 | 47 | 22 | 45 | 17 | 42 | 19 | 44 |
9 | 50 | 11 | 52 | 16 | 55 | 14 | 53 |
8 | 63 | 6 | 61 | 1 | 58 | 3 | 60 |
If you build a 4n×4n pandiagonal magic square with this algorithm then every 2×2 square in the 4n×4n square will have the same sum. Therefore many symmetric patterns of 4n cells have the same sum as any row and any column of the 4n×4n square. Especially each 2n×2 and each 2×2n rectangle will have the same sum as any row and any column of the 4n×4n square. The 4n×4n square is also a Most-perfect magic square.
(6n+3)×(6n+3) panmagic squares, n>0
A (6n+3)×(6n+3) panmagic square with n>0 can be built by the following algorithm.
- Create a (2n+1)×3 rectangle with the first 6n+3 natural numbers so that each column has the same sum. You can do this by starting with a 3×3 magic square and set up the rest cells of the rectangle in meander-style. You can also use the pattern shown in the following examples.
Examples:
|
|
|
- Put this rectangle in the left upper corner of the (6n+3)×(6n+3) square and two copies of the rectangle beneath it so that the first 3 columns of the square are filled completely.
Example:
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
- Copy the left 3 columns into the next 3 columns, but shift it ring-wise by 1 row.
Example:
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
|||
|
|
|
|
|
|
- Continue copying the current 3 columns into the next 3 columns, shifted ring-wise by 1 row, until the square is filled completely.
Example:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Build a second square and copy the first square into it but mirror it diagonal. So you have to exchange rows and columns.
Example:
A
|
AT
|
- Build the final square by multiplying the second square by 6n+3, adding the first square and subtract 6n+3 in each cell of the square.
Example: A + (6n+3)×AT – (6n+3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
External links
- Panmagic Square at MathWorld
- http://www.azspcs.net/Contest/PandiagonalMagicSquares
- http://budshaw.ca/Pandiagonal.html
- http://www.magic-squares.info/english.html
References
- W. S. Andrews, Magic Squares and Cubes. New York: Dover, 1960. Originally printed in 1917. See especially Chapter X.