Office Applications and Entertainment, Magic Squares  Index About the Author

 8.3   Medjig Solutions (Main Diagonals, Integers 0, 1, 2 and 3) 8.3.1 General As described in section 6.8, for any integer n, a magic square C of order 2n can be constructed from any n x n medjig-square A with each row, column, and main diagonal summing to 3n, and any n x n magic square B, by application of the equations: bi + n2 aj with i = 1, 2, ... n2 and j = 1, 2, ... 4n2. The Medjig method of constructing a Magic Square of order 8 is as follows: Construct a 4 x 4 Medjig-Square A (ignoring the original game's limit on the number of times that a given sequence is used); Construct a 4 x 4 Magic Square B (7040 possibilities); Construct a 8 x 8 Magic Square C by applying the equations mentioned above.

B (4 x 4)

 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16

Medjig Square A (4 x 4)

 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 a60 a61 a62 a63 a64

Magic Square C (8 x 8)

 b1+16*a1 b1+16*a2 b2+16*a3 b2+16*a4 b3+16*a5 b3+16*a6 b4+16*a7 b4+16*a8 b1+16*a9 b1+16*a10 b2+16*a11 b2+16*a12 b3+16*a13 b3+16*a14 b4+16*a15 b4+16*a16 b5+16*a17 b5+16*a18 b6+16*a19 b6+16*a20 b7+16*a21 b7+16*a22 b8+16*a23 b8+16*a24 b5+16*a25 b5+16*a26 b6+16*a27 b6+16*a28 b7+16*a29 b7+16*a30 b8+16*a31 b8+16*a32 b9+16*a33 b9+16*a34 b10+16*a35 b10+16*a36 b11+16*a37 b11+16*a38 b12+16*a39 b12+16*a40 b9+16*a41 b9+16*a42 b10+16*a43 b10+16*a44 b11+16*a45 b11+16*a46 b12+16*a47 b12+16*a48 b13+16*a49 b13+16*a50 b14+16*a51 b14+16*a52 b15+16*a53 b15+16*a54 b16+16*a55 b16+16*a56 b13+16*a57 b13+16*a58 b14+16*a59 b14+16*a60 b15+16*a61 b15+16*a62 b16+16*a63 b16+16*a64
 The rows, columns and main diagonals of Square C sum to 2 times the corresponding sum of Magic Square B plus 16 times the corresponding sum of Medjig square A which results in s1 = 2 * 34 + 16 * 12 = 260. As b(i) ≠ b(j) for i ≠ j with i, j = 1, 2, ... 16 it is obvious that also c(m) ≠ c(n) for n ≠ m with n, m = 1, 2, ... 64. A numerical example is shown below:

B (4 x 4)

 12 13 3 6 7 2 16 9 14 11 5 4 1 8 10 15

Medjig Square A (4 x 4)

 1 3 3 0 0 1 1 3 0 2 2 1 3 2 0 2 0 1 2 3 0 3 3 0 3 2 1 0 2 1 2 1 3 0 1 3 2 1 2 0 2 1 0 2 0 3 3 1 2 0 3 2 2 0 0 3 1 3 0 1 3 1 1 2

Magic Square C (8 x 8)

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

8.3.2 Further Analysis

Medjig Squares are described by the same set of linear equations as shown in section 8.1.1, for Magic Squares, however with magic sum 12 and following additional equations:

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

Resulting in the matrix representation:

A * a = s

which can be reduced, by means of row and column manipulations, to the minimum number of linear equations:

```a(57) = 12 - a(58) - a(59) - a(60) - a(61) - a(62) - a(63) - a(64)
a(55) =  6 - a(56) - a(63) - a(64)
a(53) =  6 - a(54) - a(61) - a(62)
a(51) =  6 - a(52) - a(59) - a(60)
a(49) =  6 - a(50) - a(57) - a(58)
a(41) = 12 - a(42) - a(43) - a(44) - a(45) - a(46) - a(47) - a(48)
a(39) =  6 - a(40) - a(47) - a(48)
a(37) =  6 - a(38) - a(45) - a(46)
a(35) =  6 - a(36) - a(43) - a(44)
a(33) =  6 - a(34) - a(41) - a(42)
a(25) = 12 - a(26) - a(27) - a(28) - a(29) - a(30) - a(31) - a(32)
a(23) =  6 - a(24) - a(31) - a(32)
a(21) =  6 - a(22) - a(29) - a(30)
a(19) =  6 - a(20) - a(27) - a(28)
a(17) =  6 - a(18) - a(25) - a(26)
a(15) = 18 + a(16) - a(22) + a(24) - a(29) + a(32) - a(35) - 2 * a(36) - a(39) - 2 * a(43) - a(44) - a(47) - a(50) +
- a(55) - a(57) - a(63)
a(10) = 12 - (a(11) + a(12) + a(13) + a(14) + a(15) + a(16) + a(18) - a(20) + a(26) - a(27) + a(34) + (37) + a(42) +
+ a(46) + a(50) + a(55) + a(58) + a(64))/2
a(9) =  12 - a(10) - a(11) - a(12) - a(13) - a(14) - a(15) - a(16)
a(8) = -12 - a(16) - a(24) - a(32) + a(35) + a(36) + a(39) + a(43) + a(44) + a(47) + a(51) + a(52) + a(55) + a(59) +
+ a(60) + a(63)
a(7) = -18 - a(16) + a(22) + a(29) + a(35) + 2*a(36) + 2*a(43) + a(44) + a(50) + a(51) + a(52) + a(57) + a(59) + a(60)
a(6) =  12 - a(14) - a(22) - a(30) - a(38) - a(46) - a(54) - a(62)
a(5) = - 6 - a(13) + a(22) + a(30) + a(38) + a(46) + a(54) + a(62)
a(4) =  12 - a(12) - a(20) - a(28) - a(36) - a(44) - a(52) - a(60)
a(3) =   6 - a(11) + a(20) + a(28) - a(35) - a(43) - a(51) - a(59)
a(2) =  12 - a(10) - a(18) - a(26) - a(34) - a(42) - a(50) - a(58)
a(1) = - 6 - a( 9) + a(18) + a(26) + a(34) + a(42) + a(50) + a(58)
```
 The linear equations shown above are ready to be solved, for the magic constant 12. The solutions can be obtained by guessing:      a(11), a(12), a(13), a(14), a(16), a(18), a(20), a(22), a(24), a(26) ... a(32), a(34), a(36), a(38),      a(40), a(42) ....... a(48), a(50), a(52), a(54), a(56) and a(58) ... a(64) and filling out these guesses in the abovementioned equations. To obtain the integers 0, 1, 2 and 3 also following relations should be applied:      0 =< a(i) =< 3        for i = 1, 2, ... 10, 15, 17, 19, 21, 23, 25, 33, 35, 37, 39, 41, 49, 51, 53, 55, 57      Int(a(i)) = a(i)      for i = 10 which can be incorporated in a guessing routine, which can be used to generate a defined number of Medjig Squares within a reasonable time. With the last 9 of the 16 Medjig pieces constant, an optimized guessing routine (MgcSqr8e), produced 1712 Medjig Squares within 72 seconds, which are shown in Attachment 8.3.1. The resulting Magic Squares, based on the 4th order Magic Square shown in the numerical solution above are shown in Attachment 8.3.2. It should be noted that, although much faster, not all Magic Squares of the 8th order can be found by means of the Medjig Solution. The Magic Square shown at the begin of Section 8.2 is a clear example. 8.3.3 Pan Magic Complete Squares The Medjig method of constructing a Pan Magic Complete Square of order 8 is as follows: Construct a   4 x 4 Pan Magic and Complete Medjig-Square A; Construct a   4 x 4 Pan Magic Square B (ref. Attachment 1); Construct the 8 x 8 Pan Magic Complete Square C by applying the equations mentioned in Section 8.3.1 above. A numerical example is shown below:

B (4 x 4)

 12 13 3 6 7 2 16 9 14 11 5 4 1 8 10 15

Medjig Square A (4 x 4)

 3 2 1 0 3 2 1 0 1 0 3 2 1 0 3 2 2 3 0 1 2 3 0 1 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 2 3 0 1 2 3 0 1 1 0 3 2 1 0 3 2 3 2 1 0 3 2 1 0

Magic Square C (8 x 8)

 60 44 29 13 51 35 22 6 28 12 61 45 19 3 54 38 39 55 2 18 48 64 9 25 7 23 34 50 16 32 41 57 14 30 43 59 5 21 36 52 46 62 11 27 37 53 4 20 17 1 56 40 26 10 63 47 49 33 24 8 58 42 31 15
 As mentioned in Section 8.7.5, a collection of 640000 Quaternary Pan Magic Complete Squares could be generated with procedure Quat869, which can be considered as Medjig Squares. All Medjig Squares of this collection are suitable for the construction of (Pan) Magic Squares. This collection contains 1600 Medjig Squares suitable for the construction of Pan Magic Complete Squares, of which 48 are shown in in Attachment 8.3.5. The first occurring square is used in the example above. The Pan Magic Complete Squares resulting from the Medjig Square shown above and the 384 possible 4th order Pan Magic Squares, are shown in Attachment 8.3.3. It should be noted that although the Medjig Square A might be Associated as well, the resulting Square C will be Pan Magic Complete as the 4 x 4 Square B is Pan Magic Complete. 8.3.4 Associated Magic Squares The Medjig method of constructing an Associated Magic Square of order 8 is as follows: Construct a   4 x 4 Associated (Pan Magic) Medjig-Square A; Construct a   4 x 4 Associated Magic Square B (ref. Attachment 2.5); Construct the 8 x 8 Associated Magic Square C by applying the equations mentioned in Section 8.3.1 above. A numerical example is shown below:

B (4 x 4)

 16 9 5 4 3 6 10 15 2 7 11 14 13 12 8 1

Medjig Square A (4 x 4)

 3 2 3 2 1 0 1 0 1 0 1 0 3 2 3 2 0 1 0 1 2 3 2 3 2 3 2 3 0 1 0 1 2 3 2 3 0 1 0 1 0 1 0 1 2 3 2 3 1 0 1 0 3 2 3 2 3 2 3 2 1 0 1 0

Magic Square C (8 x 8)

 64 48 57 41 21 5 20 4 32 16 25 9 53 37 52 36 3 19 6 22 42 58 47 63 35 51 38 54 10 26 15 31 34 50 39 55 11 27 14 30 2 18 7 23 43 59 46 62 29 13 28 12 56 40 49 33 61 45 60 44 24 8 17 1
 As mentioned in Section 8.7.5, a collection of 27752 Quaternary Associated Pan Magic Squares could be generated with procedure Quat867, which can be considered as Medjig Squares. All Medjig Squares of this collection are suitable for the construction of (Associated) Magic Squares. The first occurring square is used in the example above. The Associated Magic Squares resulting from the Medjig Square shown above and the 384 possible 4th order Associated Magic Squares, are shown in Attachment 8.3.4. It should be noted that although the Medjig Square A might be Pan Magic Complete as well, the resulting Square C will be Associated Magic as the 4 x 4 Square B is Associated Magic. 8.3.5 Spreadsheet Solution The linear equations shown in section 8.3.2 above can be applied in an Excel spreadsheet (Ref. CnstrSngl8e). The red figures have to be “guessed” to construct a 4 x 4 Medjig Square (wrong solutions are obvious).