Office Applications and Entertainment, Magic Squares  Index About the Author

14.0    Special Magic Squares, Prime Numbers

14.18   Magic Squares of Twin Primes

Twin Primes are paired prime numbers {ai, bi} with the property {bi} = {ai} + d for i = 1 ... n and d >= 2. This section will consider Twin Primes for d = 2.

Magic Squares of order 4 * n (n = 1, 2, 3 ...) can be constructed based on (4 * n)2 / 2 Twin Pairs {ai, bi}.

14.18.1 Pan Magic Squares (4 x 4)

Possible conditions, which will result in Pan Magic Squares composed of Twin Pairs, are defined below:

 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(1) = a(12) - 2
a(2) = a(11) - 2
a(3) = a(10) + 2
a(4) = a( 9) + 2

a(5) = a(16) + 2
a(6) = a(15) + 2
a(7) = a(14) - 2
a(8) = a(13) - 2

The selected conditions have to be added to the defining equations of a Pan Magic Square (ref. Section 14.2.2), which results in following set of linear equations:

```a(15) = 0.5 * s1 - a(16) + a(17)
a(13) = 0.5 * s1 - a(14) - a(17)
a(11) = 0.5 * s1 - a(12) - a(17)
a(10) =            a(12) - a(14) + a(16)
a( 9) = 0.5 * s1 - a(12) + a(14) - a(16) + a(17)
a( 8) = 0.5 * s1 - a(14)
a( 7) =            a(14) + a(17)
a( 6) = 0.5 * s1 - a(16)
a( 5) =            a(16) - a(17)
a( 4) = 0.5 * s1 - a(12) + a(14) - a(16)
a( 3) =            a(12) - a(14) + a(16) - a(17)
a( 2) = 0.5 * s1 - a(12)
a( 1) =            a(12) + a(17)
```

with a(17) = 2 and a(16), a(14) and a(12) the independent variables.

Based on the equations shown above a routine can be written to generate 4 x 4 Pan Magic Squares composed of Twin Pairs (ref. Priem4b1).

Attachment 14.18.1 shows for miscellaneous Magic Sums one Pan Magic Square composed of Twin Pairs. The first square is an aspect of the (minimum) square previously published by Natalia Makarova (2013).

Each square shown corresponds with 384 Pan Magic Squares with the same Magic Sum and variable values {ai}.

Attachment 14.18.2 shows for MC4 = 420 the 96 squares corresponding with the Twin Pair definition provided above.

14.18.2 Simple Magic Squares (4 x 4)

For Simple Magic Squares composed of Twin Pairs the conditions as defined in Section 14.18.1 above can be applied.

The selected conditions have to be added to the defining equations of a Simple Magic Square (ref. Section 14.2.1), which results in following set of linear equations:

```a(13) = s1 - a(14) - a(15) - a(16)
a(11) = s1 - a(12) - a(15) - a(16)
a(10) =      a(12) - a(14) + a(16)
a( 9) =    - a(12) + a(14) + a(15)
a( 8) = s1 - a(14) - a(15) - a(16) + a(17)
a( 7) =      a(14) + a(17)
a( 6) =      a(15) - a(17)
a( 5) =      a(16) - a(17)
a( 4) =    - a(12) + a(14) + a(15) - a(17)
a( 3) =      a(12) - a(14) + a(16) - a(17)
a( 2) = s1 - a(12) - a(15) - a(16) + a(17)
a( 1) =      a(12) + a(17)
```

with a(17) = 2 and a(16), a(15), a(14), and a(12) the independent variables.

Based on the equations shown above a routine can be written to generate 4 x 4 Simple Magic Squares composed of Twin Pairs (ref. Priem4d).

Attachment 14.18.3 shows for miscellaneous Magic Sums one Simple Magic Square composed of Twin Pairs.

Each square shown corresponds with numerous Simple Magic Squares with the same Magic Sum and variable values {ai}.

14.18.3 Associated Magic Squares (4 x 4)

Possible conditions, which will result in Associated Magic Squares composed of Twin Pairs, are defined below:

 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(1) = a(12) + 2
a(2) = a(11) - 2
a(3) = a(10) - 2
a(4) = a( 9) + 2

a(5) = a(16) + 2
a(6) = a(15) - 2
a(7) = a(14) - 2
a(8) = a(13) + 2

The selected conditions have to be added to the defining equations of an Associated Magic Square (ref. Section 14.2.3), which results in following set of linear equations:

```a(13) =        s1 - a(14) - a(15) - a(16)
a(12) =  0.5 * s1 - a(16) - a(17)
a(11) =  0.5 * s1 - a(15) + a(17)
a(10) =  0.5 * s1 - a(14) + a(17)
a( 9) = -0.5 * s1 + a(14) + a(15) + a(16) - a(17)
a( 8) =  0.5 * s1 - a( 9)
a( 7) =  0.5 * s1 - a(10)
a( 6) =  0.5 * s1 - a(11)
a( 5) =  0.5 * s1 - a(12)
a( 4) =  0.5 * s1 - a(13)
a( 3) =  0.5 * s1 - a(14)
a( 2) =  0.5 * s1 - a(15)
a( 1) =  0.5 * s1 - a(16)
```

with a(17) = 2 and a(16), a(15) and a(14) the independent variables.

Based on the equations shown above a routine can be written to generate 4 x 4 Associated Magic Squares composed of Twin Pairs (ref. Priem4c).

Attachment 14.18.4 shows for miscellaneous Magic Sums one Associated Magic Square composed of Twin Pairs.

Each square shown corresponds with 384 Associated Magic Squares with the same Magic Sum and variable values {ai}, of which 96 correspond with the Twin Pair definition provided above.

14.18.4 Composed Magic Squares (8 x 8)

In Section 14.6.1 was discussed how Prime Number Magic Squares of order 8 - with Magic Sum 2 * s1 - can be composed out of 4th order Prime Number Magic Squares with Magic Sum s1.

An example of a Magic Sum for which a set of 4 Pan Magic Squares composed of Twin Pairs can be found is s1 = 7140:

MC8 = 14280
 199 3373 179 3389 1489 2083 1427 2141 11 3557 31 3541 41 3527 103 3469 3391 181 3371 197 2143 1429 2081 1487 3539 29 3559 13 3467 101 3529 43 1021 2551 857 2711 1303 2269 1229 2339 107 3461 271 3301 239 3329 313 3259 2713 859 2549 1019 2341 1231 2267 1301 3299 269 3463 109 3257 311 3331 241

Attachment 14.18.5 contains a few more sets of Pan Magic Squares composed of Twin Pairs, which can be used to construct order 8 Twin Pair based Magic Squares - composed of order 4 Pan Magic Sub Squares - (ref. Priem4b2).

Attachment 14.18.6 shows for prime number range (11 ... 5023) the first occurring order 8 Twin Pair based Magic Squares - composed of order 4 Pan Magic Sub Squares - for a few Magic Sums.

Attachment 14.18.9 shows for prime number range (11 ... 5023) the first occurring order 8 Twin Pair based Magic Squares - composed of order 4 Assoiated Magic Sub Squares - for a few Magic Sums.

Each square shown corresponds with numerous Composed Magic Squares with the same Magic Sums and variable values {ai}, (Order of magnitude 4! * 3844 = 5.22 * 1011).

14.18.5 Associated Magic Squares (8 x 8)

Associated Magic Squares of order 8 - with Magic Sum 2 * s1 - can be composed out of 4th order Semi Magic Squares with Magic Sum s1.

For order 4 Semi Magic Squares composed of Twin Pairs the conditions as defined in Section 14.18.1 above can be applied.

The selected conditions have to be added to the defining equations of a Semi Magic Square, which results in following set of linear equations:

```a(13) = s1 - a(14) - a(15) - a(16)
a(10) = s1 - a(11) - a(14) - a(15)
a( 9) =    - a(12) + a(14) + a(15)
a( 8) = s1 - a(14) - a(15) - a(16) + a(17)
a( 7) =      a(14) + a(17)
a( 6) =      a(15) - a(17)
a( 5) =      a(16) - a(17)
a( 4) =    - a(12) + a(14) + a(15) - a(17)
a( 3) = s1 - a(11) - a(14) - a(15) - a(17)
a( 2) =      a(11) + a(17)
a( 1) =      a(12) + a(17)
```

with a(17) = 2 and a(16), a(15), a(14), a(12) and a(11) the independent variables.

Based on the equations shown above a routine can be written to generate sets of Anti Symmetric 4 x 4 Semi Magic Squares composed of Twin Pairs (ref. Priem4a), which result in order 8 Twin Pair based Associated Magic Squares.

Attachment 14.18.7 shows for prime number range (11 ... 7561) the first occurring order 8 Twin Pair based Associated Magic Squares for a few Magic Sums.

Each square shown corresponds with numerous Associated Magic Squares with the same Magic Sums and variable values {ai}, (Order of magnitude 4!/2 * (4!)2 * (4!)2 = 3981312).

14.18.6 Pan Magic Squares (8 x 8)

The order 8 Twin Pair based Associated Magic Squares obtained in Section 14.18.5 above can be transformed into order 8 Twin Pair based Pan Magic Squares as shown below (Eulers Transformation):

Associated (MC8 = 14280)
 859 1231 2081 2969 1021 1483 1949 2687 11 569 3259 3301 41 239 3469 3391 2971 2083 1229 857 2689 1951 1481 1019 3299 3257 571 13 3389 3467 241 43 3527 3329 103 181 3557 2999 313 271 2551 2089 1619 881 2713 2341 1487 599 179 101 3331 3529 269 311 3001 3559 883 1621 2087 2549 601 1489 2339 2711
Pan Magic (MC8 = 14280)
 859 1231 2081 2969 2687 1949 1483 1021 11 569 3259 3301 3391 3469 239 41 2971 2083 1229 857 1019 1481 1951 2689 3299 3257 571 13 43 241 3467 3389 883 1621 2087 2549 2711 2339 1489 601 179 101 3331 3529 3559 3001 311 269 2551 2089 1619 881 599 1487 2341 2713 3527 3329 103 181 271 313 2999 3557

Attachment 14.18.8 shows for prime number range (11 ... 7561) the first occurring order 8 Twin Pair based Pan Magic Squares for a few Magic Sums.

Alternatively order 8 Twin Pair based Pan Magic Squares can be obtained by transforming the order 8 Twin Pair based Composed Magic Squares obtained in Section 14.18.4 above, as illustrated below:

Composed (MC8 = 14280)
 199 3373 179 3389 1489 2083 1427 2141 11 3557 31 3541 41 3527 103 3469 3391 181 3371 197 2143 1429 2081 1487 3539 29 3559 13 3467 101 3529 43 1021 2551 857 2711 1303 2269 1229 2339 107 3461 271 3301 239 3329 313 3259 2713 859 2549 1019 2341 1231 2267 1301 3299 269 3463 109 3257 311 3331 241
Pan Magic (MC8 = 14280)
 199 1489 3373 2083 179 1427 3389 2141 1021 1303 2551 2269 857 1229 2711 2339 11 41 3557 3527 31 103 3541 3469 107 239 3461 3329 271 313 3301 3259 3391 2143 181 1429 3371 2081 197 1487 2713 2341 859 1231 2549 2267 1019 1301 3539 3467 29 101 3559 3529 13 43 3299 3257 269 311 3463 3331 109 241

The resulting Pan Magic Square is Complete, 4 x 4 Compact and Four Way V type Zig Zag (ref. Section 14.15.5) and has following additional properties:

1. The corner points of all 3 x 3 sub squares (64 ea) sum to half the Magic Sum;
2. The corner points of all 5 x 5 sub squares (16 ea) sum to half the Magic Sum.

Attachment 14.18.12 shows the Twin Pair based Pan Magic Squares, which can be obtained by transformation of the Composed Magic Squares as shown in Attachment 14.18.6.

Each square shown corresponds with numerous Pan Magic Squares with the same Magic Sums and variable values {ai},

14.18.7 Composed Magic Squares (12 x 12)

Prime Number Magic Squares of order 12 - with Magic Sum 3 * s1 - can be composed out of 4th order Prime Number Magic Squares with Magic Sum s1.

Attachment 14.18.10 shows for prime number range (11 ... 18289) the first occurring order 12 Twin Pair based Magic Squares - composed of order 4 Pan Magic Sub Squares - for a few Magic Sums.

Attachment 14.18.11 shows for prime number range (11 ... 18289) the first occurring order 12 Twin Pair based Magic Squares - composed of order 4 Assoiated Magic Sub Squares - for a few Magic Sums.

14.18.8 Associated Magic Squares (12 x 12)

Order 12 Twin Pair based Associated Magic Squares might be composed of:

• One order 4 Associated Magic Center Square composed of Twin Pairs and
• Four Complementary Pairs of order 4 Anti Symmetric Simple Magic Squares composed of Twin Pairs

as illustrated in the example below:

MC12 = 99540
 3673 6871 9629 13007 3373 2269 12251 15287 9043 6553 7127 10457 137 1319 15361 16363 521 2687 15973 13999 857 8999 10501 12823 13009 9631 6869 3671 15289 12253 2267 3371 10459 7129 6551 9041 16361 15359 1321 139 13997 15971 2689 523 12821 10499 9001 859 5419 4549 9281 13931 15139 10139 4649 3253 14867 11489 2341 4483 1721 5099 14251 12109 1453 6449 11939 13339 11173 12043 7307 2657 13933 9283 4547 5417 3251 4651 10141 15137 4481 2339 11491 14869 12107 14249 5101 1723 13337 11941 6451 1451 2659 7309 12041 11171 15731 7589 6091 3769 16067 13901 619 2593 16451 15269 1231 229 7549 10039 9461 6131 13219 14323 4337 1301 12919 9721 6959 3581 3767 6089 7591 15733 2591 617 13903 16069 227 1229 15271 16453 6133 9463 10037 7547 1303 4339 14321 13217 3583 6961 9719 12917

Subject square corresponds with numerous Associated Magic Squares with the same Magic Sums and variable values {ai}.

14.18.9 Summary

The obtained results regarding the miscellaneous types of Prime Number Magic Squares composed of Twin Pairs, as deducted and discussed in previous sections are summarized in following table:

 Order Main Characteristics Subroutine Results 4 Pan Magic Simple Magic Associated 8 Composed of Pan Magic Squares Composed of Associated Magic Squares Associated Pan Magic (1) Euler Pan Magic (2) Alternative 12 Composed of Pan Magic Squares Composed of Associated Magic Squares - - - -
 Following sections will explain the concept of Prime Number Magic Twin Squares and illustrate how Magic Twin Squares can be generated with comparable routines as described in previous sections.