Monday 17 May 2021

Prime Semi-Magic Squares

 I've posted about magic squares (and cubes) before, specifically:

Yesterday, I turned 26339 days old and one of the properties of this prime number is that it's a member of OEIS A270865:


 A270865

Smallest primes of 4 X 4 semi-magic squares formed from consecutive primes. 
 

A semi-magic square has all its rows and columns adding to a constant number, but not its diagonals. Up to 26339, the OEIS sequence runs:
5, 19, 29, 31, 37, 47, 53, 79, 397, 409, 599, 787, 1229, 1381, 1439, 1993, 2087, 2767, 4003, 4159, 4931, 5791, 5981, 8117, 9293, 9349, 9833, 10939, 10979, 11213, 12553, 12907, 14557, 16361, 18047, 21089, 21557, 21577, 25903, 26339

In the OEIS comments for the sequence, examples are shown for 5 and 19:$$\begin{array}{|c|c|c|c|}

\hline 5 & 7 & 53 & 59 \\

\hline 29 & 61 & 23 & 11\\

\hline 43 & 37 & 31 & 13\\

\hline 47 & 19 & 17 & 41 \\

\hline

\end{array}$$ $$\begin{array}{|c|c|c|c|}

\hline 19 & 23 & 79 & 83 \\

\hline 53 & 67 & 37 & 47\\

\hline 61 & 41 & 59 & 43 \\

\hline 71 & 73 & 29 & 31 \\

\hline


\end{array}$$In the magic square beginning with 5, the 16 primes (5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61) total 496 and every row and column totals 496 ÷ 4 = 124 which is the magic constant of the square. The sum total of the primes must always be a multiple of 4. We know the next set of primes starts with 19 so what happens if we use a set of primes starting with 7, 11, 13 and 17:

  • 7 gives a total of 558 which is not divisible by 4
  • 11 gives a total of 662 which is not divisible by 4
  • 13 gives a total of 684 which is divisible by 4 to give 171
  • 17 gives a total of 750 which is not divisible by 4
From this we can see that divisibility of the prime sum by 4 is a necessary but not sufficient condition for ensuring that a semi-magic square can be created. 13 serves as a reminder of this. A little thought reveals that for an \(n \times n \) magic square, not only must the sum of the terms be divisible by \(n\), the quotient must be even when \(n\) is even and odd when \(n\) is odd. As can be seen, if we start with 13 as the first consecutive prime, the quotient is odd. The reason is that in the case of a 4 x 4 magic square, each column and row consists of four odd primes that when added together must produce an even total.

In the case of 26339, the primes are:

26339, 26347, 26357, 26371, 26387, 26393, 26399, 26407, 
26417, 26423, 26431, 26437, 26449, 26459, 26479, 26489

These primes total 422584 and thus the magic constant is 105646. The problem is how to arrange these primes into a semi-magic square. As can be seen, the pattern of the placement of primes is different between the semi-magic square beginning with 5 and the one beginning with 19. It seems as if each arrangement of numbers might be unique. I tried using the same pattern as found in Durer's famous 4 x 4 magic square but no luck. There are a staggering 20,922,789,888,000 or over twenty trillion ways to form a 4 x 4 grid of 16 numbers  and even SageMathCell cannot search through all these possibilities. What I'm looking for is a method to populate a 4 x 4 semi-magic square with 16 non-consecutive elements.

The number of groups of primes making up the 4 x 4 semi-magic squares are relatively rare. 26339 marks the first member of the 40th such group. Not surprisingly, the number of groups of primes making up 4 x 4 fully magic squares are ever rarer. The following sequence begins 31, 37, 1229, 4931, 12553, 3259909, 3324329, 9291521, ...


 A260673

Smallest primes of 4 X 4 magic squares formed from consecutive primes.   


Here is the magic square of consecutive primes beginning with 37. It has a magic constant of 258:$$\begin{array}{|c|c|c|c|}\hline 37 & 83 & 97 & 41 \\
\hline 53 & 61 & 71 & 73\\

\hline 89 & 67 & 59 & 43\\

\hline 79 & 47 & 31 & 101 \\

\hline

\end{array}$$This of course doesn't solve my problem of how to arrange the primes in my 4 x 4 semi-magic square with its magic constant of 105646. One thing to consider would be the gaps between the primes. These average of these gaps is 10 and the actual gaps are:

26339 to 26347 is a gap of 08 with total of 008
26347 to 26357 is a gap of 10 with total of 018
26357 to 26371 is a gap of 14 with total of 032
26371 to 26387 is a gap of 16 with total of 048
26387 to 26393 is a gap of 06 with total of 054
26393 to 26399 is a gap of 06 with total of 060
26399 to 26407 is a gap of 08 with total of 068
26407 to 26417 is a gap of 10 with total of 078
26417 to 26423 is a gap of 06 with total of 084
26423 to 26431 is a gap of 08 with total of 092
26431 to 26437 is a gap of 06 with total of 098
26437 to 26449 is a gap of 12 with total of 110
26449 to 26459 is a gap of 10 with total of 120
26459 to 26479 is a gap of 20 with total of 140
26479 to 26489 is a gap of 10 with total of 150

The reason I've listed these gaps between the primes is that a lot of importance seems placed on numbers been in arithmetic progression. At this location on Quora, there is a method shown for filling the traditional 4 x 4 magic square with the numbers from 1 to 16. See Figure 1.

Figure 1: source

I tried this using my prime numbers with 26339 replacing 1, 26347 replacing 2 etc. but it didn't work. So my search continues but along the way I've discovered new types of magic squares. For example, bimagic means a magic square remaining magic after each of its numbers have been squared. The smallest possible 4×4 semi-bimagic square of prime numbers begins with 29 and is shown in Figure 2:
Figure 2: source

For this magic square, the magic constant is 1190 and when the terms are squared, the magic constant becomes 549100. Lots of interesting information on magic squares to be found at the source site listed in Figure 2.

The knight's tour often comes up in the construction of magic squares as can be seen in this initial populating of the squares in Figure 3. A knight's tour is only possible on a board with an even number of squares. However, it is apparently not possible on a 4 x 4 board. In fact, the 5 x 6 and 3 x 10 boards are the smallest rectangular boards that have knight's tours. Source.

Figure 3: source

From the same source as listed in Figure 3, the method shown in Figure 4 is suggested as a way to arrange 16 elements into a 4 x 4 magic square:

Figure 4: source

I'm wondering if this strategy might be successful if used with the gaps that I've listed between the primes. I don't have four of every \(a,b,x,y\) but my magic square only needs to be semi-magic. In Figure 2, the knight moves can be seen in the path between \(a\) and \(a+x\), \(b\) and \(b+x\) etc. So far though no luck. I'll keep trying and add to this post when I succeed.

It can be noted that 26339, the first prime in the set of 16 primes that I'm trying to arrange into a semi-magic square, is a Luhn prime of the first order because 26339 + 93362 = 119701 which is a prime number. This is the property that defines a Luhn prime, namely that the prime number itself when added to its reverse, produces a new prime. I posted about Luhn Primes in a post on my birthday, April 3rd 2021. However, this property of 26339 doesn't seem to help in solving my problem.

One approach is to subtract 26339 from every term so that the sequence starts with zero. This gives: 0, 8, 18, 32, 48, 54, 60, 68, 78, 84, 92, 98, 110, 120, 140, 150 and these terms have a median of 73. If we subtract 73 from each we get:

-73, -65, -55, -41, -25, -19, -13, -5, 5, 11, 19, 25, 37, 47, 67, 77

The magic constant for this set of numbers is -2. If I subtract 72, the magic constant is 2, so a magic constant of zero isn't possible. Perhaps it will be easier to work with these smaller numbers. If I come up with a semi-magic square for these numbers, then I simply need to add 26339 + 73 = 21412 to the numbers above.

No comments:

Post a Comment