Some old notes, in which I use middle school mathematics to expose a geometric interpretation of the the magic square of squares problem. I don't make any claims about these results being particularly useful, I just find this connection pleasant and surprising — at any rate, it surprised me.
These are very mildly editorialized personal notes; they were not made with sharing in mind and are therefore confusing to follow (I jump between topics quite freely and don't spend much time introducing the problem).
This is a general form for a magic square (all lines, be they horizontal, vertical or diagonal, are built out of three numbers whose sum is 3j).
WLOG, k > l. We want to find a magic square whose entries are all distinct integer squares.
This is one of those easy to express, very hard to solve problems (in fact, it is an open problem). You may ask yourself why it matters; as it turns out, it doesn't (but this won't stop us). Here is an alternative notation for our square.
Note that m² = j.
An alternative framing of the problem is that we need to find an m such that there are four distinct pairs of integers (x, y) which respect the following equation: m² - (m - x)² = (m + y)² - m². Each of these pairs corresponds to one of the line crossing the moddle of the square (refer to the two squares above to see where this comes from). This is a necessary condition but not a sufficient one.
I will call a triple {m - x, m, m + y} for numbers respecting the aforementioned equation a magic triple.
I generate the first 101364 such triples through a simple iterative process (for m up to 65353).
Here are the first 31 magic triples:
If P is a magic triple, then so is n*P for n any natural number. Here is a more structured view of the same triples based on this observation (I grouped multiples):
The simplest triples will be referred to as canonical triples. New canonical triples appear on some prime values of m (e.g. 5 but not 7; we will call these magic primes), as well as whenever a number is a composite of magic primes. Conjecture: they don't appear in any other way.
For m = 5, there is only one triple: a canonical one. For m = 5*5 = 25, there are two triples: a canonical and one related to the previous one. For m = 7, there is only one triple: a canonical one. that for m = 5*13 = 65, there are four triples: two derived ones and two canonical ones.
(Note: this is related to Gaussian factorization)
So, we have pairs such that: m² - (m - x)² = (m + y)² - m².
In particular, we have m² - (m - n)² = (m + u)² - m².
Which implies (m - n)² + (m + u)² = 2m².
And similarly m² - (m - p)² = (m + s)² - m².
Which implies (m - p)² + (m + s)² = 2m².
These correspond to points on the circle C of center (m, -m) and of radius sqrt(2)*m. Feast your eyes on this ASCII illustration of the situation:
In fact, we only need to give values for n and p: we can find u and s by solving
the above equations.
n = a
u = sqrt(2m² - (m - a)²) - m
p = b
s = sqrt(2m² - (m - b)²) - m
We have pairs (n, u) and (p, s). Let's now turn our attention to pairs (t, o) and (r, q).
We have:
m² - (m-a)² = k
m² - (m-b)² = l
And:
m² - (m-t)² = k + l
(m+o)² - m² = k + l
m² - (m-r)² = k - l
(m+q)² - m² = k - l
Therefore:
m² - (m-t)² = m² - (m-a)² + m² - (m-b)²
=> t = m - sqrt(-m² + (m-a)² + (m-b)²)
(m+o)² - m² = m² - (m-a)² + m² - (m-b)²
=> o = sqrt(3m² - (m-a)² - (m-b)²) - m
m² - (m-r)² = m² - (m-a)² - m² + (m-b)²
=> r = m - sqrt(m² + (m-a)² - (m-b)²)
(m+q)² - m² = m² - (m-a)² - m² + (m-b)²
=> q = sqrt(m² - (m-a)² + (m+b)²) - m
Our four pairs are as follow:
(n = a, u = sqrt(2m² - (m - a)²) - m)
(p = b, s = sqrt(2m² - (m - b)²) - m)
(t = m - sqrt(-m² + (m-a)² + (m-b)²), o = sqrt(3m² - (m-a)² - (m-b)²) - m)
(r = m - sqrt(m² + (m-a)² - (m-b)²), q = sqrt(m² - (m-a)² + (m+b)²) - m)
We are back to three degrees of freedom!
A solution is valid if all points have integer coordinates. In fact, we can apply rigid transformations to our circle without loss.
(n' = m - a, u' = sqrt(2m² - (m - a)²))
(p' = m - b, s' = sqrt(2m² - (m - b)²))
(t' = sqrt(-m² + (m-a)² + (m-b)²), o' = sqrt(3m² - (m-a)² - (m-b)²))
(r' = sqrt(m² + (m-a)² - (m-b)²), q' = sqrt(m² - (m-a)² + (m+b)²))
The circle is now centered around (0, 0).
Also, let's introduce A = m - a and B = m - b:
(n'' = A, u'' = sqrt(2m² - A²))
(p'' = B, s'' = sqrt(2m² - B²))
(t'' = sqrt(-m² + A² + B²), o'' = sqrt(3m² - A² - B²))
(r'' = sqrt( m² + A² - B²), q'' = sqrt( m² - A² + B²))
Remember: when m² - (m - x)² = (m + y)² - m², {m - x, m, m + y} is a magic triple. a and b played the role of x in two such equations, therefore A and B correspond to the first component of two distinct magic triples.
In fact, picking A and B from magic triples gives us at least five correct entries.
In fact, if we set m to 1, we can set A and B to any rational values. We are now looking for a set of pairs with only rational components (if we find them, we can expand the circle until these correspond to integer values). Let C = A/m and D = B/m in
(n'' = C, u'' = sqrt(2 - C²))
(p'' = D, s'' = sqrt(2 - D²))
(t'' = sqrt(-1 + C² + D²), o'' = sqrt(3 - C² - D²))
(r'' = sqrt( 1 + C² - D²), q'' = sqrt(1 - C² + D²))
Square roots of rational values output rational values iff they are applied to values which can be written in the form d²/e² for d and e some integers.
If A and B correspond to magic triples with the same central value (co-magic triples or something),
(n'' = A/m, u'' = sqrt(2 - (A/m)²))
(p'' = B/m, s'' = sqrt(2 - (B/m)²))
(t'' = sqrt(-1 + (A/m)² + (B/m)²), o'' = sqrt(3 - (A/m)² - (B/m)²))
(r'' = sqrt( 1 + (A/m)² - (B/m)²), q'' = sqrt(1 - (A/m)² + (B/m)²))
Which can be simplified to:
(n'' = A/m, u'' = sqrt((2m² - A²)/m²))
(p'' = B/m, s'' = sqrt((2m² - B²)/m²))
(t'' = sqrt((-m² + A² + B²)/m²), o'' = sqrt((3m² - A² - B²)/m²))
(r'' = sqrt(( m² + A² - B²)/m²), q'' = sqrt((m² - A² + B²)/m²))
Focusing on the elements which matter:
t'' = sqrt((-m² + A² + B²))/m
o'' = sqrt((3m² - A² - B²))/m
r'' = sqrt(( m² + A² - B²))/m
q'' = sqrt(( m² - A² + B²))/m
X = -m² + A² + B²
Y = 3m² - A² - B²
Z = m² + A² - B²
W = m² - A² + B²
If X, Y, Z and W are squares of rational numbers, we have a correct solution.
Also, note that Z and W are quite similar: m² +/- (A² - B²)
This is another magic triple in disguise.
Same goes for X and Z: A² +/- (m² - B²)
Same goes for X and W: B² +/- (m² - A²)
Are these compatible?
In general:
F + G - H
F - G + H
-F + G + H
Is it possible for all of these expressions to correspond to perfect squares?
Note that Y = Z + W - X.
I checked the first 101364 magic triples (knowing all too well that I wouldn't find a solution directly). Overall, there were 203642 possible pairs to test (remember that we test pairs of magic triples with the same central value).
In total, I found 7046 squares with 6 correct entries, and 0 with more than that. That is, I found squares with a satisfactory value for either X, Y, Z or W, but not two of them at the same time.
Here are the lowest matches I found:
Correct X: {713, 845, 959} and {455, 845, 1105}
Correct Y: {41, 85, 113} and {35, 85, 115}
Correct Z: {383, 485, 569} and {35, 485, 685}
Correct W: {17, 25, 31} and {5, 25, 35}
For some central values, I found more than one matching pair.
The lowest one with matches for X, Y, Z and W is 4225.
X: {3565, 4225, 4795} and {2275, 4225, 5525}
Y: {3565, 4225, 4795} and {637, 4225, 5941}
or {2275, 4225, 5525} and {1649, 4225, 5743}
or {845, 4225, 5915} and {637, 4225, 5941}
Z: {1697, 4225, 5729} and {25, 4225, 5975}
W: {3731, 4225, 4667} and {1495, 4225, 5785}
or {2873, 4225, 5239} and {845, 4225, 5915}
I found:
390 matches for X
1532 matches for Y
530 matches for Z
4594 matches for W
Of course, things would be more even if I didn't count whole scalar families of
pairs.
Check Gaussian factorization