1
$\begingroup$

Question: Why does this pattern of prime numbers appear in the magic sum of pseudo-magic squares of squares, and does this represent an infinite "family" of solutions?

Consider a magic square of square numbers: \begin{array}{ccc} a^2 & b^2 & c^2 \\ d^2 & e^2 & f^2 \\ g^2 & h^2 & i^2 \end{array}

Specifically, a pseudo-magic square (sometimes called semi-magic in the literature), of distinct, perfect square numbers.

All rows: $(a^2 + b^2 + c^2)$, $(d^2 + e^2 + f^2)$, $(g^2 + h^2 + i^2)$

All columns: $(a^2 + d^2 + g^2)$, $(b^2 + e^2 + h^2)$, $(c^2 + f^2 + i^2)$

Either diagonal, primary: $(a^2 + e^2 + i^2)$ or secondary: $(c^2 + e^2 + g^2)$ but not both, must sum to the constant S (the magic sum).

For example, consider this well-known solution found by Lee Swallows in the late 1990s and featured more recently by Matt Parker on the YouTube channel Numberphile:

\begin{array}{ccc} 127^2 & 46^2 & 58^2 \\ 2^2 & 113^2 & 94^2 \\ 74^2 & 82^2 & 97^2 \end{array} $$S = 21609$$

Pattern:

I coded a search program to computationally brute-force all valid solutions for magic sums $S$ up to $10^8$. I noticed a pattern emerging. Often, though not always, $S$ is also a perfect square number. There appears to be a main "family" of solutions where $S$ follows the pattern:

$\sqrt{S}= 3p^2$

$S = (3p^2)^2 = 9p^4$

Where $p$ is a prime number satisfying:

$p \equiv 1 \pmod{6}$

This condition selects primes such as 7, 13, 19, 31, 37, 43, and so on. For the example above: $$S = 21609 \quad 21609/9 = 2401 \quad \sqrt[4]{2401} = 7$$

Question:

Given there are infinitely many primes where $p \equiv 1 \pmod{6}$, does this represent an infinite family of pseudo-magic squares?

I was able to verify that these squares continue beyond $S = 10^8$ and I generated all of them up to prime 811, resulting in very large entries:

\begin{array}{ccc} 167^2 & 1266158^2 & 1513346^2 \\ 1698254^2 & 770617^2 & 644558^2 \\ 1004642^2 & 1302446^2 & 1089817^2 \\ \end{array} $$S = 1973163^2 \quad p = 811$$

If anyone is interested in the full list of squares that I found, please let me know, I was unable to find a full concise list anywhere on the internet.

$\endgroup$
20
  • 1
    $\begingroup$ If your question is really, whether there are infinitely many primes $p\equiv1\bmod6$, then the answer is that this has been known to be true for centuries, and is often left as an exercise in intro Number Theory texts. $\endgroup$ Commented Apr 28 at 12:59
  • $\begingroup$ Are you familiar with the results at multimagie.com/English/SquaresOfSquaresSearch.htm ? $\endgroup$ Commented Apr 28 at 13:08
  • 1
    $\begingroup$ I was just checking exactly that! Taking the GCD of each solution shows that 2 of the 4 are earlier solutions in the 1 (mod 6) sequence, scaled by a common factor. One is indeed the Swallows square, each entry scaled by 169. The second scales to the next in the 1 (mod 6) family: p=13 entries scaled by 49. The 3rd contains no prime entries, which is unusual in my experience, but there is no common factor that divides all elements. The 4th contains a prime as an entry, so cannot be scaled. $\endgroup$ Commented Apr 30 at 15:20
  • 1
    $\begingroup$ Thanks for all your suggestions Gerry. I think ultimately this question is unanswerable without some advances in current mathematics. Ideally, it should be left as an open question. I have hope that one day the more general problem of "magic squares of squares" will be solved in full. This problem is somewhat like a "subset" of "near misses". While they are fascinating to me, it's rather an abstract problem. $\endgroup$ Commented May 1 at 10:34
  • 1
    $\begingroup$ You are correct, there's no direct connection between Eisenstein integers and Magic squares, not sure where that came from. Perhaps Gaussian integers are connected, but I'm unsure. Ultimately, it requires dealing with integer solutions to equations like $a^2 + b^2 + c^2 = 147^2 = (3*7^2)^2$ (for the Gardner / Swallows square). I think others have considered this approach (using complex numbers), but it remains a non-trivial problem to find solutions to these equations, especially combining with the other row, column and single diagonal constraints. $\endgroup$ Commented May 18 at 12:33

1 Answer 1

1
$\begingroup$

Given infinitely many primes $p\equiv1\pmod6$, each corresponds to at least one “3×3 pseudo-magic square of squares” (PMSS), and therefore there are infinitely many such PMSS in this family.

After working through the very lengthy equations, two key observations establish that there are infinitely many 3×3 pseudo‐magic squares of squares in this family (abbreviated as PMSS):

1. Infinitely many primes $p\equiv1\pmod6$

By Dirichlet’s theorem on arithmetic progressions, there are infinitely many primes of the form $6k+1$. Each such prime can potentially generate a PMSS using the construction below.


2. Parametrization of 3×3 PMSS

Fix any prime $p \equiv 1 \pmod 6$. This construction relies on solving a specific quadratic in order to define two integers $m$ and $n$. These will later be used to generate the entries of the square. The roots of the quadratic govern the choice of entries such that the resulting square satisfies the pseudo-magic condition with a constant magic sum.

The quadratic is:

$$ x^2 - (p + v)x + v(2p + v) = 0 $$

This arises from the symmetric relationships we want among the square’s entries, and it has discriminant:

$$ \Delta = (p + v)^2 - 4v(2p + v) = p^2 - 6pv - 3v^2 $$

If this discriminant $\Delta$ is a perfect square, say $\Delta = k^2$, then the quadratic has rational (in fact, integer) roots:

$$ m = \frac{(p+v)-k}{2}, \quad n = \frac{(p+v)+k}{2} $$

These satisfy:

$$ m + n = p + v, \quad mn = v(2p + v) $$

and are positive integers for suitable $v$. With these $m, n$ in hand, the nine square entries are defined as follows:

$$ \begin{aligned} a &= p^2 + n^2, &\quad b &= 2p^2 - v^2, &\quad c &= p^2 + 2pm - m^2,\\ d &= 2p^2 + 4pv + v^2, &\quad e &= p^2 + m^2, &\quad f &= 2pn + n^2 - p^2,\\ g &= 2pm + m^2 - p^2, &\quad h &= p^2 + 2pn - n^2, &\quad i &= (p+v)^2 + p^2. \end{aligned} $$

It can then be verified that the following matrix:

$$ \begin{pmatrix} a^2 & b^2 & c^2\\ d^2 & e^2 & f^2\\ g^2 & h^2 & i^2 \end{pmatrix} $$

has the property that every row, column, and the main diagonal sums to $9p^4$. (Note: the anti-diagonal does not necessarily sum to this value.)

By permuting entries while preserving these sums, one obtains 12 distinct PMSS. Allowing the anti-diagonal $(c,e,g)$ to sum instead of the main diagonal yields 12 additional symmetric arrangements. Thus, each $(p,v)$ pair gives rise to 24 distinct PMSS if we allow the sum to match along either diagonal.


Summary:

  • There are infinitely many primes $p \equiv 1 \pmod 6$.
  • For each such $p$, whenever a suitable $v$ exists such that $\Delta = p^2 - 6pv - 3v^2$ is a square, we obtain a PMSS.
  • Each PMSS yields 12 permutations (or 24 if allowing either diagonal to sum correctly).

Hence, this parametrization produces infinitely many pseudo-magic squares of squares with distinct magic sums $9p^4$, as $p$ ranges over primes congruent to 1 mod 6.


Further information:

It may be possible to refine the bounds on $v$ or identify a deeper structural pattern relating $v$ to $p$, but I wasn't able to derive a universal rule. Interestingly, while the construction works cleanly for all primes $p \equiv 1 \pmod{6}$, the full sequence of valid $p$ values corresponds exactly to OEIS A004611 >1, which includes some composite integers such as $p = 49$ and $p = 91$.

These composite cases are particularly notable:

  • Each still yields at least one valid PMSS using the same construction.
  • Some even admit multiple distinct solutions.
  • In several cases, one of these solutions appears to be a scaled version of an earlier PMSS corresponding to a smaller prime.

In contrast, each prime $p \equiv 1 \pmod{6}$ produces exactly one PMSS (up to symmetry) using this method.

$\endgroup$
3
  • $\begingroup$ Here's a POC using Desmos graphing calculator. If anyone wants to have a play around with solutions: https://www.desmos.com/calculator/snxoj2pvdf $\endgroup$ Commented Jun 14 at 10:07
  • $\begingroup$ I'm curious if this parametrization as been found before? I couldn't find any reference to this in the literature, hoping someone can point me in the right direction if this is novel. $\endgroup$ Commented Jul 4 at 16:19
  • $\begingroup$ I eventually found this has been noticed before, but in a slightly different form: King 2011 King describes these as "Near Magic Squares of Squares" instead of pseudo-magic. $\endgroup$ Commented Jul 24 at 17:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.