Orders 4n




An order 4n (4,8,12, etc) pandiagonal magic square follows a much clearer algorithm. The algorithm for an order 4n magic square has four steps and to demonstrate it, an order 8 magic square will be used to show this.

a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8)
a(9) a(10) a(11) a(12) a(13) a(14) a(15) a(16)
a(17) a(18) a(19) a(20) a(21) a(22) a(23) a(24)
a(25) a(26) a(27) a(28) a(29) a(30) a(31) a(32)
a(33) a(34) a(35) a(36) a(37) a(38) a(39) a(40)
a(41) a(42) a(43) a(44) a(45) a(46) a(47) a(48)
a(49) a(50) a(51) a(52) a(53) a(54) a(55) a(56)
a(57) a(58) a(59) a(60) a(61) a(62) a(63) a(64)
table 6: 8 by 8 square with 64 imaginary numbers

All columns, rows and diagonals in a pandiagonal magic square of order 4n must equal to the same magic constant. To show this, the following linear equations were written.

Rows
a( 1) + a( 2) + a( 3) + a( 4) + a( 5) + a( 6) + a( 7) + a( 8) = s1
a( 9) + a(10) + a(11) + a(12) + a(13) + a(14) + a(15) + a(16) = s1
a(17) + a(18) + a(19) + a(20) + a(21) + a(22) + a(23) + a(24) = s1
a(25) + a(26) + a(27) + a(28) + a(29) + a(30) + a(31) + a(32) = s1
a(33) + a(34) + a(35) + a(36) + a(37) + a(38) + a(39) + a(40) = s1
a(41) + a(42) + a(43) + a(44) + a(45) + a(46) + a(47) + a(48) = s1
a(49) + a(50) + a(51) + a(52) + a(53) + a(54) + a(55) + a(56) = s1
a(57) + a(58) + a(59) + a(60) + a(61) + a(62) + a(63) + a(64) = s1

Columns
a( 1) + a( 9) + a(17) + a(25) + a(33) + a(41) + a(49) + a(57) = s1
a( 2) + a(10) + a(18) + a(26) + a(34) + a(42) + a(50) + a(58) = s1
a( 3) + a(11) + a(19) + a(27) + a(35) + a(43) + a(51) + a(59) = s1
a( 4) + a(12) + a(20) + a(28) + a(36) + a(44) + a(52) + a(60) = s1
a( 5) + a(13) + a(21) + a(29) + a(37) + a(45) + a(53) + a(61) = s1
a( 6) + a(14) + a(22) + a(30) + a(38) + a(46) + a(54) + a(62) = s1
a( 7) + a(15) + a(23) + a(31) + a(39) + a(47) + a(55) + a(63) = s1
a( 8) + a(16) + a(24) + a(32) + a(40) + a(48) + a(56) + a(64) = s1

(broken) diagonals top-left to bottom-right
a( 1) + a(10) + a(19) + a(28) + a(37) + a(46) + a(55) + a(64) = s1
a( 2) + a(11) + a(20) + a(29) + a(38) + a(47) + a(56) + a(57) = s1
a( 3) + a(12) + a(21) + a(30) + a(39) + a(48) + a(49) + a(58) = s1
a( 4) + a(13) + a(22) + a(31) + a(40) + a(41) + a(50) + a(59) = s1
a( 5) + a(14) + a(23) + a(32) + a(33) + a(42) + a(51) + a(60) = s1
a( 6) + a(15) + a(24) + a(25) + a(34) + a(43) + a(52) + a(61) = s1
a( 7) + a(16) + a(17) + a(26) + a(35) + a(44) + a(53) + a(62) = s1
a( 8) + a( 9) + a(18) + a(27) + a(36) + a(45) + a(54) + a(63) = s1

(broken) diagonals top-right to bottom-left
a( 8) + a(15) + a(22) + a(29) + a(36) + a(43) + a(50) + a(57) = s1
a( 7) + a(14) + a(21) + a(28) + a(35) + a(42) + a(49) + a(64) = s1
a( 6) + a(13) + a(20) + a(27) + a(34) + a(41) + a(56) + a(63) = s1
a( 5) + a(12) + a(19) + a(26) + a(33) + a(48) + a(55) + a(62) = s1
a( 4) + a(11) + a(18) + a(25) + a(40) + a(47) + a(54) + a(61) = s1
a( 3) + a(10) + a(17) + a(32) + a(39) + a(46) + a(53) + a(60) = s1
a( 2) + a( 9) + a(24) + a(31) + a(38) + a(45) + a(52) + a(59) = s1
a( 1) + a(16) + a(23) + a(30) + a(37) + a(44) + a(51) + a(58) = s1

Through manipulation of these equations, they can be expressed in each other resulting in the following equations.

a(57) = s1 - a(58) - a(59) - a(60) - a(61) - a(62) - a(63) - a(64)
a(49) = s1 - a(50) - a(51) - a(52) - a(53) - a(54) - a(55) - a(56)
a(41) = s1 - a(42) - a(43) - a(44) - a(45) - a(46) - a(47) - a(48)
a(33) = s1 - a(34) - a(35) - a(36) - a(37) - a(38) - a(39) - a(40)
a(25) = s1 - a(26) - a(27) - a(28) - a(29) - a(30) - a(31) - a(32)
a(23) = 3 * s1 - a(24) - a(25) - a(30) - 2 * a(31) - 2 * a(32) - a(33) + a(35) + a(36) - a(38) - 2 * a(39) + - 2 * a(40) - a(41) + a(43) + a(44) - a(46) - 2 * a(47) - 2 * a(48) - a(49) - a(54) - 2 * a(55) + - 2 * a(56) - a(63) - a(64)
a(22) = 2 * s1 + a(24) + a(25) - a(29) - a(30) + a(32) - a(35) - 2 * a(36) - 2 * a(37) - 2 * a(38) - a(39) + - a(43) - 2 * a(44) - 2 * a(45) - 2 * a(46) - a(47) + a(49) - a(53) - a(54) + a(56) - a(62) + a(64)
a(21) = s1 - a(24) + a(26) + a(27) - a(37) - a(38) - a(39) - a(40) - a(45) - a(46) - a(47) - a(48) + + a(50) + a(51) - a(61) - a(64)
a(20) = a(21) - a(23) + a(24) + a(25) - a(27) - a(36) + a(40) - a(44) + a(48) + a(49) - a(51) + - a(60) + a(61) - a(63) + a(64)
a(19) = s1 - a(24) + a(29) + a(30) - a(33) - a(34) - a(35) - a(40) - a(41) - a(42) - a(43) - a(48) + + a(53) + a(54) - a(59) - a(64)
a(18) = s1 - a(21) + a(31) + a(32) - a(34) - a(35) - a(36) - a(37) - a(42) - a(43) - a(44) - a(45) + + a(55) + a(56) - a(58) - a(61)
a(17) = s1 - a(18) - a(19) - a(20) - a(21) - a(22) - a(23) - a(24)
a(16) = - s1/2 - a(23) - a(24) - a(30) - a(31) - a(32) + a(33) + a(34) + a(35) + a(36) + a(41) + a(42) + + a(43) + a(49) + a(50) + a(57)
a(15) = a(16) - a(22) + a(24) - a(29) + a(32) - a(36) + a(40) - a(43) + a(48) - a(50) + a(56) + - a(57) + a(64)
a(14) = a(16) + a(17) - a(21) + a(26) - a(28) - a(42) + a(44) - a(49) + a(53) + a(62) - a(64)
a(13) = a(15) - a(20) + a(24) + a(25) - a(27) - a(41) + a(43) + a(52) - a(56) + a(61) - a(63)
a(12) = a(14) - a(19) + a(23) - a(26) + a(32) + a(42) - a(48) + a(51) - a(55) + a(60) - a(62)
a(11) = a(13) - a(18) + a(22) - a(25) + a(31) + a(41) - a(47) + a(50) - a(54) + a(59) - a(61)
a(10) = a(12) - a(17) + a(21) + a(30) - a(32) - a(46) + a(48) + a(49) - a(53) + a(58) - a(60)
a( 9) = s1 - a(10) - a(11) - a(12) - a(13) - a(14) - a(15) - a(16)
a( 8) = s1 - a(16) - a(24) - a(32) - a(40) - a(48) - a(56) - a(64)
a( 7) = s1 - a(15) - a(23) - a(31) - a(39) - a(47) - a(55) - a(63)
a( 6) = s1 - a(14) - a(22) - a(30) - a(38) - a(46) - a(54) - a(62)
a( 5) = s1 - a(13) - a(21) - a(29) - a(37) - a(45) - a(53) - a(61)
a( 4) = s1 - a(12) - a(20) - a(28) - a(36) - a(44) - a(52) - a(60)
a( 3) = s1 - a(11) - a(19) - a(27) - a(35) - a(43) - a(51) - a(59)
a( 2) = s1 - a(10) - a(18) - a(26) - a(34) - a(42) - a(50) - a(58)
a( 1) = s1 - a( 2) - a( 3) - a( 4) - a( 5) - a( 6) - a( 7) - a( 8)

For more information on this proof visit entertainmentmathematics.nl

The magic constant for an order 8 magic square with consecutive integers is 260, which is an even number. The only fraction in these linear equations is ½ (noted in bold). 260*½ =130, which is still an integer. This proves that consecutive numbers can be used to create a pandiagonal magic square of order 4n (and 8) ({1,2,3,4,5,6,7,8}).

For the magic square of order 4n the formula for the algorithm is the formula A + 4nB - 4nC. A is a sqaure filled in with the consecutive integers {1,2,3,4,5,6,7,8} and B is a rotated form of square A. C is a square completely filled in with ones. The 4n portion of the equation functions as a way to regulate the numbers that will be filled in, it will never allow a number above $$n^2$$, as this is the last number in the consecutive series, and thus, the largest number in the magic square. If n=2 the resulting magic square would be of order 8. In the squares A and B, no number larger than 8 appears, therefore, the largest number that could result from the multiplication of 4nB is 64, which is also the largest number in the consecutive series of an order 8 magic square.

Step 1
In the first step the left half (length 2n, with n=2 in this case) of the 8 by 8 square will be filled (separated with a bold line in table 7 below). This is done by placing 2n numbers in the first 2n columns/the first row. For an 8 by 8 square this mean 2*2=4 so numbers {1,2,3,4}, because to get an order 8 magic square you need n=2 (4*2=8). In the next row below the row that was just filled in, place the next 2n numbers in reverse order {8,7,6,5}. On the following 6 rows beneath the two that were already filled in, continuously switch between the two arrays/sequence of numbers till all rows of length 2n (4) are filled in.

1 2 3 4 0 0 0 0
8 7 6 5 0 0 0 0
1 2 3 4 0 0 0 0
8 7 6 5 0 0 0 0
1 2 3 4 0 0 0 0
8 7 6 5 0 0 0 0
1 2 3 4 0 0 0 0
8 7 6 5 0 0 0 0
table 7: Step 1 constructing an order 4n (with n=2) square

Step 2
In step 2 the right half of the 8 by 8 square will be filled in. This half is almost the exact same as step 1, however, instead of starting at the top with {1,2,3,4} it starts with {8,7,6,5}. It will still switch between both series of numbers every next row. The fully filled in square will be called square A.

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
table 8: Step 2 constructing an order 4n (with n=2) square A

Step 3
In step 3 a second square B will be constructed. This is done by rotating square A (table 9) 90 degrees to the left. The following square B will emerge.

5 4 5 4 5 4 5 4
6 3 6 3 6 3 6 3
7 2 7 2 7 2 7 2
8 1 8 1 8 1 8 1
4 5 4 5 4 5 4 5
3 6 3 6 3 6 3 6
2 7 2 7 2 7 2 7
1 8 1 8 1 8 1 8
table 9: Step 3 constructing an order 4n (n=2) square B

Step 4
To finally create a pandiagonal magic square of order 4n, the formula A + 4nB - 4nC must be used. Square C is an order 4n square filled with the number one just like in table 4 (different size). For an order 8 magic square the formula would be A + 8B - 8C. For the top left square the value would be 1+8*5-8*1=33 and the full pandiagonal magic square of order 4n would be the following square.

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
table 10: Step 4 order 4n (n=2) pandiagonal magic square

Besides 4n magic squares being pandiagonal with the use of this specific algorithm, when summing up all 4 numbers inside a 2 by 2 square inside an order 4n pandiagonal magic square, it will also add up to the same number, 130. This number is always exactly half of the magic constant of an order 4n magic square, because only half of the numbers are used when comparing rows, columns and diagonals. In addition, on a diagonal line two numbers spaced n/2 (8/2=4) apart from each other with wrapping around, equates to the same number (65, ¼ of magic constant, as only 2 numbers are being added up). Because this is an order 4n magic square, with this algorithm not only a pandiagonal magic square is created, but also, a most-perfect magic square.