Office Applications and Entertainment, Magic Squares

Vorige Pagina Volgende Pagina Index About the Author

9.0 Magic Squares (9 x 9)

9.1 Analytic Solution, Pan Magic Squares

Pan Magic Squares of order 9 can be represented as follows:

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) a(65) a(66) a(67) a(68) a(69) a(70) a(71) a(72)
a(73) a(74) a(75) a(76) a(77) a(78) a(79) a(80) a(81)

As the numbers a(i), i = 1 ... 81, in all rows, columns and diagonals sum to the same constant this results in following linear equations:

a( 1)+a( 2)+a( 3)+a( 4)+a( 5)+a( 6)+a( 7)+a( 8)+a( 9) = s1
a(10)+a(11)+a(12)+a(13)+a(14)+a(15)+a(16)+a(17)+a(18) = s1
a(19)+a(20)+a(21)+a(22)+a(23)+a(24)+a(25)+a(26)+a(27) = s1
a(28)+a(29)+a(30)+a(31)+a(32)+a(33)+a(34)+a(35)+a(36) = s1
a(37)+a(38)+a(39)+a(40)+a(41)+a(42)+a(43)+a(44)+a(45) = s1
a(46)+a(47)+a(48)+a(49)+a(50)+a(51)+a(52)+a(53)+a(54) = s1
a(55)+a(56)+a(57)+a(58)+a(59)+a(60)+a(61)+a(62)+a(63) = s1
a(64)+a(65)+a(66)+a(67)+a(68)+a(69)+a(70)+a(71)+a(72) = s1
a(73)+a(74)+a(75)+a(76)+a(77)+a(78)+a(79)+a(80)+a(81) = s1

a(1)+a(10)+a(19)+a(28)+a(37)+a(46)+a(55)+a(64)+a(73) = s1
a(2)+a(11)+a(20)+a(29)+a(38)+a(47)+a(56)+a(65)+a(74) = s1
a(3)+a(12)+a(21)+a(30)+a(39)+a(48)+a(57)+a(66)+a(75) = s1
a(4)+a(13)+a(22)+a(31)+a(40)+a(49)+a(58)+a(67)+a(76) = s1
a(5)+a(14)+a(23)+a(32)+a(41)+a(50)+a(59)+a(68)+a(77) = s1
a(6)+a(15)+a(24)+a(33)+a(42)+a(51)+a(60)+a(69)+a(78) = s1
a(7)+a(16)+a(25)+a(34)+a(43)+a(52)+a(61)+a(70)+a(79) = s1
a(8)+a(17)+a(26)+a(35)+a(44)+a(53)+a(62)+a(71)+a(80) = s1
a(9)+a(18)+a(27)+a(36)+a(45)+a(54)+a(63)+a(72)+a(81) = s1

a(1)+a(11)+a(21)+a(31)+a(41)+a(51)+a(61)+a(71)+a(81) = s1
a(2)+a(12)+a(22)+a(32)+a(42)+a(52)+a(62)+a(72)+a(73) = s1
a(3)+a(13)+a(23)+a(33)+a(43)+a(53)+a(63)+a(64)+a(74) = s1
a(4)+a(14)+a(24)+a(34)+a(44)+a(54)+a(55)+a(65)+a(75) = s1
a(5)+a(15)+a(25)+a(35)+a(45)+a(46)+a(56)+a(66)+a(76) = s1
a(6)+a(16)+a(26)+a(36)+a(37)+a(47)+a(57)+a(67)+a(77) = s1
a(7)+a(17)+a(27)+a(28)+a(38)+a(48)+a(58)+a(68)+a(78) = s1
a(8)+a(18)+a(19)+a(29)+a(39)+a(49)+a(59)+a(69)+a(79) = s1
a(9)+a(10)+a(20)+a(30)+a(40)+a(50)+a(60)+a(70)+a(80) = s1

a(1)+a(18)+a(26)+a(34)+a(42)+a(50)+a(58)+a(66)+a(74) = s1
a(2)+a(10)+a(27)+a(35)+a(43)+a(51)+a(59)+a(67)+a(75) = s1
a(3)+a(11)+a(19)+a(36)+a(44)+a(52)+a(60)+a(68)+a(76) = s1
a(4)+a(12)+a(20)+a(28)+a(45)+a(53)+a(61)+a(69)+a(77) = s1
a(5)+a(13)+a(21)+a(29)+a(37)+a(54)+a(62)+a(70)+a(78) = s1
a(6)+a(14)+a(22)+a(30)+a(38)+a(46)+a(63)+a(71)+a(79) = s1
a(7)+a(15)+a(23)+a(31)+a(39)+a(47)+a(55)+a(72)+a(80) = s1
a(8)+a(16)+a(24)+a(32)+a(40)+a(48)+a(56)+a(64)+a(81) = s1
a(9)+a(17)+a(25)+a(33)+a(41)+a(49)+a(57)+a(65)+a(73) = s1

Or in matrix representation:

            
     A * a = s1

Which can be reduced, by means of row and column manipulations, to:

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

The linear equations shown above, are ready to be solved, for the magic constant 369.

However the solutions can only be obtained by guessing

   a(29) ... a(36), a(38) ... a(45), a(47) ... a(54), a(56) ... a(63), a(65) ... a(72) and a(74) ... a(81)

and filling out these guesses in the abovementioned equations.

For distinct integers also following equations should be applied:

0 < a(i) =< 81        for i = 1, 2, ... 28, 37, 46, 55, 64 and 73
Int(a(i)) = a(i)      for i = 27
a(i) ≠ a(j)           for i ≠ j

which can be incorporated in a guessing routine, which might be used to generate - if not all - at least collections of 9th order squares with distinct integers within a reasonable time.

For 9th order Pan Magic Squares, collections {Aijk} of 648 elements can be found by means of rotation, reflection, column and/or row shifts (ref. Attachment 9.3).

9.2 Further Analysis, Matrix Operation

Rather than trying to find solutions based on the equations deducted in section 9.1 above, the construction method described in section 13.2 will be used as a starting point for the generation of 9th order Pan Magic Squares.

As illustrated in section 13.2 an individual Pan Magic Square of order 9 can be constructed by means of following method:

  1. Create a 3 x 3 rectangle with the first 9 natural numbers so that each column has the same sum.
  2. Copy this rectangle three times into square A so that the first 3 columns of the square are filled completely;
  3. Copy the left 3 columns into the next 3 columns, but shift it ring-wise by 1 row.
  4. Continue copying the current 3 columns into the next 3 columns, shifted ring-wise by 1 row, until square A is filled completely
  5. Construct the transposed square T (exchange rows and columns).
  6. Construct the final square B by means of the matrix operation B = 9 * T + A - 9.

Which can be realized by means of an Excel spreadsheet as shown below:

The 2592 possible solutions, generated with routine MgcSqr9b within 171 seconds, are shown in Attachment 9.3.1 and further referred to as Collection {B}.

However not all elements of Collection {B} will result in a unique Class {Aijk}.

If the first square of Collection {B} is used as a base square, the resulting Class (ref. Attachment 9.3.2) will contain 17 other elements of {B} (highlighted in red), due to the method the squares of {B} have been constructed.

These 17 squares should be excluded from the collection of possible base squares. Continuing like this, a collection of 144 (= 2592/18) possible base squares will remain (ref. Attachment 9.3.3).

Consequently, based on the method described above, 144 * 648 = 93312 Pan Magic Squares of the 9th order can be constructed.

The resulting 9 × 9 Pan Magic Squares have following additional properties:

  1. Compact for 3 x 3 sub squares, meaning all 3 x 3 sub squares sum to the magic constant
  2. Every third-row and third-column sum to one third of the magic constant.

Other interesting sub collections of order 9 (Pan) Magic Squares will be discussed in following section(s).

9.4 Further Analysis, Compact and Symmetric Squares

A Magic Square, being a multiple of 2, 3, 5, ... , is compact when subject 2 x 2, 3 x 3, 5 x 5, ... sub squares sum to a proportional part of the magic sum. A Magic Square can be double compact (e.g. 15 x 15 for 3 x 3 and 5 x 5 sub squares).

We can define following sub collections of Compact Pan Magic Squares:

  1. Compact and Associated (ref. Section 9.4.2)
  2. Compact with every third-row and third-column summing to one third of the magic constant (ref. Section 9.2)
  3. Combination of properties 1 and 2 mentioned above.

For the last category the 3 x 3 sub squares sum to 369 (Compact), the symmetrical pairs sum to 82 (Symmetric) and the
third-rows and third-columns sum to 123.

Examples of Compact Associated Pan Magic Squares are shown in Attachment 9.4.1.

Examples of Compact Pan Magic Squares with every third-row and third-column summing to one third of the magic constant are shown in Attachment 9.4.2.

Examples of Compact Associated Pan Magic Squares with every third-row and third-column summing to one third of the magic constant, are shown in Attachment 9.4.3.

The examples shown in the attachments mentioned above, are filtered from the 144 Classes defined by Collection {B} as described in Section 9.3 above, by means of an automatic filter (MgcSqr9c).

9.4.1 Further Analysis, Compact, Symmetric Diagonals

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) a(65) a(66) a(67) a(68) a(69) a(70) a(71) a(72)
a(73) a(74) a(75) a(76) a(77) a(78) a(79) a(80) a(81)

The equations describing a Pan Magic Square of the 9th order (Section 9.1) can be combined with the following linear equations resulting from the described properties.

Compact:

       Σ   a(i + j) = 369 with 1 =< i =< 61 and i ≠ 9 * n and i ≠ (9 * n - 1) for n = 1 ... 7
j = 0, 1, 2
    9,10,11
   18,19,20

       Σ   a(i + j) = 369 with i = (9 * n - 1) for n = 1 ... 7
j = 0, 1, 2
    9,10,11
   18,19,-7

       Σ   a(i + j) = 369 with i = 9 * n       for n = 1 ... 7
j = 0, 1, 2
    9,10,11
   18,-8,-7

       Σ   a(i + j) = 369 with i = 1 ... 7
j = 0, 1, 2
   63,64,65
   72,73,74

       Σ   a(i + j) = 369 with i = 1 ... 7
j = 0, 1, 2
    9,10,11
   72,73,74

a(71) + a(72) + a(64) + a(80) + a(81) + a(73) + a( 8) + a( 9) + a( 1) = 369
a(72) + a(64) + a(65) + a(81) + a(73) + a(74) + a( 9) + a( 1) + a( 2) = 369
a(80) + a(81) + a(73) + a( 8) + a( 9) + a( 1) + a(17) + a(18) + a(10) = 369
a(81) + a(73) + a(74) + a( 9) + a( 1) + a( 2) + a(18) + a(10) + a(11) = 369

Symmetric Diagonals:

a( 1) + a(81) = 82
a(11) + a(71) = 82

a(21) + a(61) = 82
a(31) + a(51) = 82

a( 9) + a(73) = 82
a(17) + a(65) = 82

a(25) + a(57) = 82
a(33) + a(49) = 82

Every third-row and third-column sum to 123:

       Σ   a(i + j) = 123 with i = (1 + 9 * n), (4 + 9 * n), (7 + 9 * n) for n = 0 ... 8
j = 0, 1, 2


       Σ   a(i + j) = 123 with i = (1 + n), (28 + n), (55 + n)           for n = 0 ... 8
j = 0, 9, 18

Or in matrix representation:

            
     A * a = s

Which can be reduced, by means of row and column manipulations, to:

a(79) =  123 - a(80) - a(81)
a(76) =  123 - a(77) - a(78)
a(73) =  123 - a(74) - a(75)
a(70) =  123 - a(71) - a(72)
a(67) =  123 - a(68) - a(69)
a(64) =  123 - a(65) - a(66)
a(63) =  123 - a(72) - a(81)
a(62) =  123 - a(71) - a(80)
a(61) = -123 + a(71) + a(72) + a(80) + a(81)
a(60) =  123 - a(69) - a(78)
a(59) =  123 - a(68) - a(77)
a(58) = -123 + a(68) + a(69) + a(77) + a(78)
a(57) =  123 - a(66) - a(75)
a(56) =  123 - a(65) - a(74)
a(55) = -123 + a(65) + a(66) + a(74) + a(75)
a(54) = - 82 + a(71) + a(72) - a(78) + a(80) + a(81)
a(53) =  164 + a(66) - a(71) - a(72) - a(74) - a(77)
a(52) =   41 - a(66) + a(74) + a(77) + a(78) - a(80) - a(81)
a(51) = - 82 + a(71) + a(72) + a(80)
a(50) =  164 + a(66) - a(71) - a(72) - a(74) - a(80)
a(49) =   41 - a(66) + a(74)
a(48) = - 82 + a(71) + a(72) + a(75) - a(78) + a(80)
a(47) =  164 + a(66) - a(71) - a(72) - a(77) - a(80)
a(46) =   41 - a(66) - a(75) + a(77) + a(78)
a(45) =  164 - a(66) - a(69) - a(71) + a(74) - a(80)
a(44) =   41 - a(68) + a(71)
a(43) = - 82 + a(66) + a(68) + a(69) - a(74) + a(80)
a(42) =  164 - a(66) - a(71) - a(72) + a(74) - a(80)
a(41) =   41
a(40) = - 82 + a(66) + a(71) + a(72) - a(74) + a(80)
a(39) =  164 - a(69) - a(71) - a(72) + a(74) - a(80)
a(38) =   41 + a(65) - a(68)
a(37) = - 82 - a(65) + a(68) + a(69) + a(71) + a(72) - a(74) + a(80)
a(36) =   41 + a(66) + a(69) - a(72) - a(74) + a(78) - a(81)
a(35) = - 82 - a(66) + a(68) + a(72) + a(74) + a(77)
a(34) =  164 - a(68) - a(69) - a(77) - a(78) + a(81)
a(33) =   41 + a(66) - a(74)
a(32) = - 82 - a(66) + a(71) + a(72) + a(74) + a(80)
a(31) =  164 - a(71) - a(72) - a(80)
a(30) =   41 + a(69) - a(74) - a(75) + a(78)
a(29) = - 82 - a(65) - a(66) + a(68) + a(71) + a(72) + a(77) + a(80)
a(28) =  164 + a(65) + a(66) - a(68) - a(69) - a(71) - a(72) + a(74) + a(75) - a(77) - a(78) - a(80)
a(27) =  205 - a(71) - a(72) - a(75) - a(80)
a(26) = - 41 - a(66) + a(71) + a(72) + a(80)
a(25) = - 41 + a(66) + a(75)
a(24) =  205 - a(71) - a(72) - a(75) + a(78) - a(80) - a(81)
a(23) = - 41 - a(66) + a(71) + a(72) + a(77)
a(22) = - 41 + a(66) + a(75) - a(77) - a(78) + a(80) + a(81)
a(21) =  205 - a(71) - a(72) - a(80) - a(81)
a(20) = - 41 - a(66) + a(71) + a(72) + a(74)
a(19) = - 41 + a(66) - a(74) + a(80) + a(81)
a(18) = - 41 + a(71) + a(72) - a(74) + a(80)
a(17) =   82 - a(65)
a(16) =   82 + a(65) - a(71) - a(72) + a(74) - a(80)
a(15) = - 41 + a(69) + a(71) - a(74) + a(80)
a(14) =   82 - a(65) + a(68) - a(71)
a(13) =   82 + a(65) - a(68) - a(69) + a(74) - a(80)
a(12) = - 41 + a(66) + a(71) - a(74) + a(80)
a(11) =   82 - a(71)
a(10) =   82 - a(66) + a(74) - a(80)
a( 9) = - 41 + a(74) + a(75)
a( 8) =   82 + a(65) + a(66) - a(71) - a(72) - a(80)
a( 7) =   82 - a(65) - a(66) + a(71) + a(72) - a(74) - a(75) + a(80)
a( 6) = - 41 - a(69) + a(72) + a(74) + a(75) - a(78) + a(81)
a( 5) =   82 + a(65) + a(66) - a(68) - a(72) - a(77)
a( 4) =   82 - a(65) - a(66) + a(68) + a(69) - a(74) - a(75) + a(77) + a(78) - a(81)
a( 3) = - 41 - a(66) + a(72) + a(74) + a(81)
a( 2) =   82 + a(66) - a(72) - a(74)
a( 1) =   82 - a(81)

which can be applied in an Excel spreadsheet (Ref. CnstrSngl9b) and an appropriate guessing routine.

For the consecutive integers {1 ... 81}, Compact Pan Magic Squares with Symmetric Diagonals - as defined above - appear to be Compact Associated Pan Magic as shown in Attachment 9.4.3.


Vorige Pagina Volgende Pagina Index About the Author