Office Applications and Entertainment, Magic Squares Index About the Author

8.2   Magic Squares, Composed of Sub Squares

8.2.1 Analytic Solution, Pan Magic Squares composed of Pan Magic Sub Squares

The following 8th order Pan Magic Square is composed out of four 4th order Pan Magic Sub Squares:

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

This results in following linear equations for the 4 Pan Magic Squares of the 4th order:

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

with s1 = 260 and following additional equations which ensure that all digonals sum to 260:

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

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

The resulting number of equations can be written in the matrix representation as:

A1 * a = s

which can be reduced, by means of row and column manipulations, and results in following set of linear equations:

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

The solutions can be obtained by guessing a(24), a(27), a(30) .. a(32), a(52), a(56), a(58) .. a(60) and a(62) .. a(64) and filling out these guesses in the abovementioned equations.

For distinct integers also following inequalities should be applied:

0 < a(i) =< 64        for i = 1, 2, ... 23, 25, 26, 28, 29, 33 .. 51, 53 ... 55, 57, 61
a(i) ≠ a(j)           for i ≠ j

With the independent variables a(62) ... a(64), a(56), a(58) ... a(60) and a(52) constant, an optimized guessing routine (MgcSqr8b), produced 768 Pan Magic Squares within 80 seconds, which are shown in Attachment 8.2.1.

8.2.2 Analytic Solution, Magic Squares composed of Pan Magic Sub Squares

For Magic Squares of order 8, composed of 4 Pan Magic Squares of the 4th order, only the rows, columns and the main diagonals sum to 260.

Consequently following linear equations for the 4 Pan Magic Squares of the 4th order will do:

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

which can be written in matrix representation as:

A2 * a = s

which can be reduced, by means of row and column manipulations, and results in following set of linear equations:

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

The solutions can only be obtained by guessing a(20), a(26) ... a(28), a(24), a(30) ... a(32), a(52), a(58) ... a(60) and a(56), a(62) ... a(64) and filling out these guesses in the abovementioned equations.

For distinct integers also following inequalities should be applied:

0 < a(i) =< 64        for i = 1, 2, ... 19, 21 ... 23, 25, 29, 33 ... 51, 53 ... 55, 57, 61
a(i) ≠ a(j)           for i ≠ j

With the independent variables a(62) ... a(64), a(56), a(58) ... a(60), a(52) and a(32) ... a(30) constant,
an optimized guessing routine (MgcSqr8c), produced 768 Magic Squares within 63.65 seconds, which are shown
in Attachment 8.2.2.

Resulting Pan Magic Squares (4) are highlighted in red.

8.2.3 Analytic Solution, Magic Squares composed of Magic Sub Squares

For Magic Squares of order 8, composed of 4 Magic Squares of the 4th order, only the rows, columns and the main diagonals sum to 260.

Consequently following linear equations for the 4 Magic Squares of the 4th order will do:

 a(25) =  0.5*s1 - a(26) - a(27) - a(28) a(17) =  0.5*s1 - a(18) - a(19) - a(20) a(11) =           a(12) - a(18) + a(20) - a(25) + a(28) a(10) =  0.5*s1 - a(12) - a(19) - a(20) + a(25) - a(28) a( 9) =         - a(12) + a(18) + a(19) a( 4) =  0.5*s1 - a(11) - a(18) - a(25) a( 3) = -0.5*s1 - a(12) + a(17) + 2*a(18) + 2*a(25) + a(26) a( 2) =           a(12) - a(17) - 2*a(18) + a(27) + 2*a(28) a( 1) =           a(12) + a(20) - a(25) a(29) =  0.5*s1 - a(30) - a(31) - a(32) a(21) =  0.5*s1 - a(22) - a(23) - a(24) a(15) =           a(16) - a(22) + a(24) - a(29) + a(32) a(14) =  0.5*s1 - a(16) - a(23) - a(24) + a(29) - a(32) a(13) =         - a(16) + a(22) + a(23) a( 8) =  0.5*s1 - a(15) - a(22) - a(29) a( 7) = -0.5*s1 - a(16) + a(21) + 2*a(22) + 2*a(29) + a(30) a( 6) =           a(16) - a(21) - 2*a(22) + a(31) + 2*a(32) a( 5) =           a(16) + a(24) - a(29) a(57) =  0.5*s1 - a(58) - a(59) - a(60) a(49) =  0.5*s1 - a(50) - a(51) - a(52) a(43) =           a(44) - a(50) + a(52) - a(57) + a(60) a(42) =  0.5*s1 - a(44) - a(51) - a(52) + a(57) - a(60) a(41) =         - a(44) + a(50) + a(51) a(36) =  0.5*s1 - a(43) - a(50) - a(57) a(35) = -0.5*s1 - a(44) + a(49) + 2*a(50) + 2*a(57) + a(58) a(34) =           a(44) - a(49) - 2*a(50) + a(59) + 2*a(60) a(33) =           a(44) + a(52) - a(57) a(61) =  0.5*s1 - a(62) - a(63) - a(64) a(53) =  0.5*s1 - a(54) - a(55) - a(56) a(47) =           a(48) - a(54) + a(56) - a(61) + a(64) a(46) =  0.5*s1 - a(48) - a(55) - a(56) + a(61) - a(64) a(45) =         - a(48) + a(54) + a(55) a(40) =  0.5*s1 - a(47) - a(54) - a(61) a(39) = -0.5*s1 - a(48) + a(53) + 2*a(54) + 2*a(61) + a(62) a(38) =           a(48) - a(53) - 2*a(54) + a(63) + 2*a(64) a(37) =           a(48) + a(56) - a(61)
 which can be written in matrix representation as:           →   →      A3 * a = s which can be reduced, by means of row and column manipulations, and results in following set of linear equations: a(61) =  0.5 * s1 - a(62) - a(63) - a(64) a(57) =  0.5 * s1 - a(58) - a(59) - a(60) a(53) =  0.5 * s1 - a(54) - a(55) - a(56) a(49) =  0.5 * s1 - a(50) - a(51) - a(52) a(47) =             a(48) - a(54) + a(56) - a(61) + a(64) a(46) =  0.5 * s1 - a(48) - a(55) - a(56) + a(61) - a(64) a(45) =           - a(48) + a(54) + a(55) a(43) =             a(44) - a(50) + a(52) - a(57) + a(60) a(42) =  0.5 * s1 - a(44) - a(51) - a(52) + a(57) - a(60) a(41) =           - a(44) + a(50) + a(51) a(40) =  0.5 * s1 - a(47) - a(54) - a(61) a(39) = -0.5 * s1 - a(48) + a(53) + 2 * a(54) + 2 * a(61) + a(62) a(38) =             a(48) - a(53) - 2 * a(54) + a(63) + 2 * a(64) a(37) =             a(48) + a(56) - a(61) a(36) =  0.5 * s1 - a(43) - a(50) - a(57) a(35) = -0.5 * s1 - a(44) + a(49) + 2 * a(50) + 2 * a(57) + a(58) a(34) =             a(44) - a(49) - 2 * a(50) + a(59) + 2 * a(60) a(33) =             a(44) + a(52) - a(57) a(29) =  0.5 * s1 - a(30) - a(31) - a(32) a(25) =  0.5 * s1 - a(26) - a(27) - a(28) a(21) =  0.5 * s1 - a(22) - a(23) - a(24) a(17) =  0.5 * s1 - a(18) - a(19) - a(20) a(15) =             a(16) - a(22) + a(24) - a(29) + a(32) a(14) =  0.5 * s1 - a(16) - a(23) - a(24) + a(29) - a(32) a(13) =           - a(16) + a(22) + a(23) a(11) =             a(12) - a(18) + a(20) - a(25) + a(28) a(10) =  0.5 * s1 - a(12) - a(19) - a(20) + a(25) - a(28) a( 9) =           - a(12) + a(18) + a(19) a( 8) =  0.5 * s1 - a(16) - a(24) - a(32) a( 7) = -0.5 * s1 - a(16) + a(21) + 2 * a(22) + 2 * a(29) + a(30) a( 6) =             a(16) - a(21) - 2 * a(22) + a(31) + 2 * a(32) a( 5) =             a(16) + a(24) - a(29) a( 4) =  0.5 * s1 - a(12) - a(20) - a(28) a( 3) = -0.5 * s1 - a(12) + a(17) + 2 * a(18) + 2 * a(25) + a(26) a( 2) =             a(12) - a(17) - 2 * a(18) + a(27) + 2 * a(28) a( 1) =             a(12) + a(20) - a(25) The solutions can only be obtained by guessing :    a(12), a(18) ... a(20), a(26) ... a(28), a(16), a(22) ... a(24), a(30) ... a(32) and    a(44), a(50) ... a(52), a(58) ... a(60), a(48), a(54) ... a(56), a(62) ... a(64) and filling out these guesses in the abovementioned equations. For distinct integers also following inequalities should be applied: 0 < a(i) =< 64        for i = 1, 2, ... 11, 13 ... 15, 17, 21, 25, 29, 33 ... 43, 45 ... 47, 49, 53, 57, 61 a(i) ≠ a(j)           for i ≠ j With the variables of 3 of the 4 squares constant, an optimized guessing routine (MgcSqr8d), produced 4736 Magic Squares within 490 seconds, which are shown in Attachment 8.2.3. Resulting Pan Magic Squares (2) and generated Pan Magic Sub Squares are highlighted in red.