The La Plata Mountains as seen from above the author’s
            home.


Durango Bill's

 

Magic Squares


   Magic Squares exist for many different sizes and may have various qualifications on the numbers they contain. We will look at simple 3x3 Magic Squares and take a brief look at the “3x3 Magic Square of Squares” problem.


                 -------------------------------
                 |         |         |         |
                 |         |         |         |
                 |    8    |    1    |    6    |
                 |         |         |         |
                 |         |         |         |
                 -------------------------------
                 |         |         |         |
                 |         |         |         |
                 |    3    |    5    |    7    |
                 |         |         |         |
                 |         |         |         |
                 -------------------------------
                 |         |         |         |
                 |         |         |         |
                 |    4    |    9    |    2    |
                 |         |         |         |
                 |         |         |         |
                 -------------------------------

   The Magic Square above illustrates the properties of a Magic Square. Each cell contains a unique integer number greater than 0. For this example, the numbers used are consecutive integers, but this does not have to hold true for all Magic Squares.

   Each row, column, and diagonal in a Magic Square will sum to the same result (in this case “15”). In any 3x3 Magic Square this “Magic Sum” will be 3 times whatever the value is in the center cell.

   The example above uses a center value of “5”. It is the only Magic Square solution if we require the center number to be 5. The lowest possible value in the center cell for a 3x3 Magic Square is 5.

   We might ask the question: “What happens if the center number can be something larger – for example “6”?


-------------------    -------------------    -------------------
|     |     |     |    |     |     |     |    |     |     |     |
| 10  |  1  |  7  |    |  9  |  1  |  8  |    |  9  |  2  |  7  |
|     |     |     |    |     |     |     |    |     |     |     |
-------------------    -------------------    -------------------
|     |     |     |    |     |     |     |    |     |     |     |
|  3  |  6  |  9  |    |  5  |  6  |  7  |    |  4  |  6  |  8  |
|     |     |     |    |     |     |     |    |     |     |     |
-------------------    -------------------    -------------------
|     |     |     |    |     |     |     |    |     |     |     |
|  5  | 11  |  2  |    |  4  | 11  |  3  |    |  5  | 10  |  3  |
|     |     |     |    |     |     |     |    |     |     |     |
-------------------    -------------------    -------------------

   The 3 diagrams above show the 3 possible solutions if the value of the center cell is increased to 6. The “Magic Sum” for each row, col. and diagonal has increased to 3 x 6 = 18.

   If you have a solution for a 3x3 Magic Square and the center cell has some value “N”, you can always generate a solution for a center value of “N + 1” by simply adding “1” to the value in all 9 cells. For that matter, you can always add any arbitrary constant to all 9 cells and get a solution with larger values.

   The 2 sections above show the solutions for center cell values of 5 and 6. What happens if we try “7” for the value in the center cell?


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

   If the center cell is 7, then there are 4 Magic Square solutions. In each of these solutions, the “Magic Sum” is 3 x 7 = 21.



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


12   3   9      11   3  10      11   4   9
 5   8  11       7   8   9       6   8  10
 7  13   4       6  13   5       7  12   5


   If the center cell is equal to 8, we get the 7 solutions shown above. In all of the examples given above and in the table below, we are only counting “primitive” solutions. You can swap the outside rows and/or columns, rotate the Magic Square, generate mirror images using the diagonals, etc. to generate trivial variations of these; but the examples given above show all the “primitive” solutions.


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


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


12   4  11      12   5  10
 8   9  10       7   9  11
 7  14   6       8  13   6

   If we extend the process again we get the 10 solutions shown above that have a center value of “9”. It can be noted that the number of solutions that have a center value of “N+1” is equal to the number of solutions that have a center value of “N” plus the number of new solutions that have a single digit of “1” in the middle of the top row.


   Computer programs can generate solutions much easier than humans can. The following table shows the number of primitive solutions that exist given the value in the center cell.

         Center            Magic                   Number of
          Cell              Sum                    Solutions
  -----------------------------------------------------------
              5               15                           1
              6               18                           3
              7               21                           4
              8               24                           7
              9               27                          10
             10               30                          13
             11               33                          17
             12               36                          22
             13               39                          26
             14               42                          32
             15               45                          38
             16               48                          44
             17               51                          51
             18               54                          59
             19               57                          66
             20               60                          75
             25               75                         124
             30               90                         187
             40              120                         348
             50              150                         560
             75              225                       1,308
            100              300                       2,368
            200              600                       9,735
            500            1,500                      61,835
          1,000            3,000                     248,668
          2,000            6,000                     997,335
          5,000           15,000                   6,243,335
         10,000           30,000                  24,986,668
         20,000           60,000                  99,973,335
         50,000          150,000                 624,933,335
        100,000          300,000               2,499,866,668
        200,000          600,000               9,999,733,335
        500,000        1,500,000              62,499,333,335
      1,000,000        3,000,000             249,998,666,668
     10,000,000       30,000,000          24,999,986,666,668
    100,000,000      300,000,000       2,499,999,866,666,668
  1,000,000,000    3,000,000,000     249,999,998,666,666,668

  3,999,999,999   11,999,999,997   3,999,999,992,666,666,670
  4,000,000,000,  12,000,000,000   3,999,999,994,666,666,668


   By the time you get to 1,000,000, there are recognizable patterns in the number of solutions. If you are only interested in how many Magic Squares exist for a given center cell value, and not interested in generating the actual Magic Squares; then the following recursive equation will get you there.

  Center           Number of Magic
Cell Value         Squares “F[N}”
      5                  1
      6                  3
    N+1            = 2 * F[N] – F[N-1]  +  G[MOD(N, 6)]

where G[MOD(N,6)] is from the following table:

             -------------------------------------
             |     |     |     |     |     |     |
MOD(N,6)     |  0  |  1  |  2  |  3  |  4  |  5  |
             |     |     |     |     |     |     |
             -------------------------------------
             |     |     |     |     |     |     |
G[MOD(N,6)]  | -1  |  2  |  0  |  0  |  1  |  1  |
             |     |     |     |     |     |     |
             -------------------------------------

   For example, if you know how many Magic Squares exist for center cell values of “5” and “6”, then the number of Magic Squares for the next center cell value (in this case: N + 1 = 7) can be calculated as follows:

1) N              =  6     Last center cell value where we have known information
2) F[N]           =  3     Known (Number of solutions with center cell value of 6)
3) F[N-1]         =  1     Known (Number of solutions with center cell value of 5)
4) G[MOD(N,6)]    = -1     MOD(N,6) is zero.
                           Find “0” in the MOD(N,6) table above and use the “-1”
                           underneath it.


F[N+1] = 2 * F[N] – F[N-1] + G[MOD(N,6)]
F[7]   = 2 * 3    - 1      + (-1)
F[7]   = 4


Repeat the above as needed for F[8], F[9], etc.



Here is a solution with the value in the center cell equal to 1,000,000.

            -------------------------------------
            |           |           |           |
            |           |           |           |
            | 1,999,998 |         1 | 1,000,001 |
            |           |           |           |
            |           |           |           |
            -------------------------------------
            |           |           |           |
            |           |           |           |
            |         3 | 1,000,000 | 1,999,997 |
            |           |           |           |
            |           |           |           |
            -------------------------------------
            |           |           |           |
            |           |           |           |
            |   999,999 | 1,999,999 |         2 |
            |           |           |           |
            |           |           |           |
            -------------------------------------




Magic Squares Using Prime Numbers

   There are many variations of magic squares that impose restrictions on the numbers that are used in the individual cells. One variation is to restrict entrees to just prime numbers. There appear to be an infinite number of 3x3 magic squares that use just prime numbers.

 67    1   43           101    5   71         101   29   83
 13   37   61            29   59   89          53   71   89
 31   73    7            47  113   17          59  113   41


109    7  103           149   11  107
 67   73   79            47   89  131
 43  139   37            71  167   29

   The 5 diagrams above show the 5 possible magic squares composed of prime numbers with the value in center square less than 100. As the value in the center square is allowed to increase, many more prime-number magic squares are possible. If the value in the center square can be any prime number under 1,000, there are 474 possible solutions.

   If the value in the center square can be any prime number under 1,000,000, then there are 1,044,538,640 possible solutions. The last prime number under 1,000,000 is 999,983. There are 33,542 possible 3x3 prime-number magic squares with a value of 999,983 in the center square. Here’s one of them.

               1,009,373    982,343  1,008,233
                 998,843    999,983  1,001,123
                 991,733  1,017,623    990,593

   As can be seen above, it’s also possible to restrict prime number solutions to a specific last digit. Here are a few examples.

 491   41  311              883    13   673
 101  281  461              313   523   733
 251  521   71              373  1033   163


 577    7  337              569    59   449
  67  307  547              239   359   479
 277  607   37              269   659   149


Or even the last several digits:

 77,011,111    6,511,111   53,911,111        61,033,333   10,333,333   41,533,333
 22,711,111   45,811,111   68,911,111        18,133,333   37,633,333   57,133,333
 37,711,111   85,111,111   14,611,111        33,733,333   64,933,333   14,233,333


109,477,777   75,277,777  104,077,777       116,099,999   58,499,999  110,699,999
 90,877,777   96,277,777  101,677,777        89,699,999   95,099,999  100,499,999
 88,477,777  117,277,777   83,077,777        79,499,999  131,699,999   74,099,999







Magic Square of Squares


   While the above magic squares use simple integers to fill the cells, a much more difficult variation is to fill the cells with perfect squares.  Thus integers (A, B, C, D, E, F, G, H, I) have to be found such that the following becomes a Magic Square.

                -------------------------------
                |         |         |         |
                |         |         |         |
                |   A^2   |   B^2   |   C^2   |
                |         |         |         |
                |         |         |         |
                -------------------------------
                |         |         |         |
                |         |         |         |
                |   D^2   |   E^2   |   F^2   |
                |         |         |         |
                |         |         |         |
                -------------------------------
                |         |         |         |
                |         |         |         |
                |   G^2   |   H^2   |   I^2   |
                |         |         |         |
                |         |         |         |
                -------------------------------


1)  A^2 + B^2 + C^2 = Sum
2)  D^2 + E^2 + F^2 = Sum
3)  G^2 + H^2 + I^2 = Sum
4)  A^2 + D^2 + G^2 = Sum
5)  B^2 + E^2 + H^2 = Sum
6)  C^2 + F^2 + I^2 = Sum
7)  A^2 + E^2 + I^2 = Sum
8)  C^2 + E^2 + G^2 = Sum

Sum = 3(E^2)
(Add equations 5,  7, and 8 and then subtract equations 1 and 3).

For more information, please see the following article in Scientific American Magazine.
“Can You Solve a Puzzle Unsolved Since 1996?”
“A challenge that the famous puzzler Martin Gardner put forward long ago remains open” http://www.scientificamerican.com/article/can-you-solve-a-puzzle-unsolved-since-1996/

Alternately, please see Christian Boyer’s web page about the “Magic Square of Squares” problem.
http://www.multimagie.com/English/SquaresOfSquares.htm


This is an unsolved problem in mathematics as no one has found a solution, but no one has proved that a solution is not possible.

   The author gave this one a crack, but the only result that I got was that if a solution exists, then E2 has to be greater than 3,600,000,000,000,000. (3.60E15)

   A solution at this range (or greater) does not look very promising. If we check equations 1 - 8 above, we note that there are 4 equations that have a term of E2. Thus there have to be 4 triplets where the sum of their squares is equal to some single number – the “Magic Sum” - which is equal to 3(E2).

   If E = 60,000,000, then 3(E2) is equal to 1.08E16. If we check how many ways that numbers near 1.08E16 can be split into the sum of 3 squares, where the middle term is E2, we find that a significant number don’t have the required 4 triplets. For example, for the 10,000 values of E from E = 59,990,001 to E = 60,000,000, only 3,314 values for E have at least 4 qualifying triplets, and 2,373 of these had just the minimum of 4. Sample runs for other large E values showed similar ratios. (For that matter, if there aren’t at least 5 triplets, there cannot be a solution. http://mathpages.com/home/kmath417.htm )

   Of the candidates that do have 5 or more triplets (about 9% of the candidates for “E”), they then face astronomical odds of matching up the row and column sums. It appears highly unlikely that a solution exists for the Magic Square of Squares problem.





Magic squares – all possible powers >= 2


Another variation that was tried was to try to form a magic square allowing all possible powers >= 2.

                       -------------------------------
                       |         |         |         |
                       |         |         |         |
                       |   A^R   |   B^S   |   C^T   |
                       |         |         |         |
                       |         |         |         |
                       -------------------------------
                       |         |         |         |
                       |         |         |         |
                       |   D^U   |   E^V   |   F^W   |
                       |         |         |         |
                       |         |         |         |
                       -------------------------------
                       |         |         |         |
                       |         |         |         |
                       |   G^X   |   H^Y   |   I^Z   |
                       |         |         |         |
                       |         |         |         |
                       -------------------------------

   In the diagram above, the letters A thru I can be any positive integer >= 1. The associated powers (letters R thru Z) can be any integer power >= 2. In practice, R thru Z can be restricted to just prime numbers which is a great help for computer run time.

   A search was made using all center cell values ( E^V ) up to 1.0E14. No solutions were found.





Return to Durango Bill's Home Page


Web page generated via Sea Monkey's Composer HTML editor
within  a Linux Cinnamon Mint 18 operating system.
(Goodbye Microsoft)