3x3 Magic Square of 7 Squares
Study 2

The Magic Hourglass Puzzle
A necessary condition for a 3x3 magic square of distinct squares
is a solution to any of its 7-square subsets.
This paper is concerned with the following 7-square subset
where a,b,c > 0 and thus, c-(a+b) is the smallest entry.

     c+a  c-(a+b)  c+b
     ---     c     ---
     c-b  c+(a+b)  c-a


Results of the Study
In a Magic Hourglass or a 3x3 magic square of distinct squares,
the center entry cannot be
the square of any power of a single prime or
the square of the product of two different primes.

In the Pythagorean Triangle formulation, the scale factors for the
triangles having a common hypotenuse must be pairwise coprime.


Arithmetic Progression Formulation
The Magic Hourglass configuration contains three arithmetic progressions
having the same middle value:

         c-a,  c,  c+a     with step value a;
         c-b,  c,  c+b     with step value b;
     c-(a+b),  c,  c+(a+b) with step value a+b.

Turning the hourglass on its side seems to produce another version,
but not really.

         c+a  ---  c+b
     c+(b-a)   c   c-(b-a)
         c-b  ---  c-a

This configuration contains three arithmetic progressions having the
same middle value:

     c-(b-a),  c,  c+(b-a) with step value b-a;
         c-a,  c,  c+a     with step value a;
         c-b,  c,  c+b     with step value b.

In both cases, the sum of the step values of the first two
progressions equals the step value of the third.  This means that a
solution for this configuration can be used for the first one by
rearranging the entries as follows.

     c+(b-a)  c-b  c+a
        ---    c   ---
        c-a   c+b  c-(b-a)

The Magic Hourglass Puzzle is to find three 3-square arithmetic
progressions having the same middle square and with step values a, b, a+b.


Pythagorean Triangle Formulation
A 3-square arithmetic progression with step value A
is equivalent to a Pythagorean Triangle with area A/4.

Let P2, Q2, R2 be the 3-square arithmetic progression with step value
     A = R2 - Q2 = Q2 - P2.
Let P = X-Y, R = X+Y, Q = Z, then
     (X+Y)2 - Z2 = Z2 - (X-Y)2
or
     (X+Y)2 + (X-Y)2 = 2Z2,
which reduces to
     X2 + Y2 = Z2,
the equation of a Pythagorean Triangle.

Note that the middle value of the arithmetic progression
is equal to the hypotenuse of the triangle.

Also,
     A = Z2 - (X-Y)2
which expands to
     A = Z2 - X2 - Y2 + 2XY.
Since Z2 - X2 - Y2 = 0, we have
     A/4 = XY/2,
which is the area of the Pythagorean Triangle.

The Magic Hourglass Puzzle is to find three Pythagorean Triangles having
the same hypotenuse and areas A1, A2, A3, such that A1 + A2 = A3.


Key Number Formulation
The general formula for a Pythagorean Triangle
     X2 + Y2 = Z2
is
     X = 2mnt
     Y = (m2 - n2)t
     Z = (m2 + n2)t
where
     m > n, gcd(m,n)=1, m and n not both odd,
     and t is an unrestricted scale factor.

The above formula non-redundantly produces all possible solutions.

The area of the triangle, XY/2, is
     mn(m2 - n2)t2.

Example
How many ways can 65 be the hypotenuse of a Pythagorean Triangle?
You may think that there are only two ways.

     (m,n,t) = (8,1,1), (7,4,1)
which produces
     (X,Y,Z) = (16,63,65), (56,33,65).

But we need three triangles in order to make a Magic Hourglass.
Fortunately, there are two more ways.

     (m,n,t) = (2,1,13), (3,2,5)
which produces
     (X,Y,Z) = (52,39,65), (60,25,65).

Note that the last two ways are not expressible as Z = m2 + n2,
even if m and n are unrestricted.  They require the scale factor, t.

Converting to the arithmetic progression form, they become
     472, 652, 792 with step 24x84;
     232, 652, 892 with step 24x154;
     132, 652, 912 with step 24x169;
     352, 652, 852 with step 24x125.

Sorting the step values we have, after dividing by 24,
      84, 125, 154, 169.

We sort so that a systematic check for a solution can be performed.
If the list has L entries, then the number of combinations to check
is equal to the sum of the first L-2 triangular numbers,
     1 + 3 + 6 + 10 + 15 + ....
We have four combinations to check.
      84 + 125 = 154 ?
      84 + 125 = 169 ?
      84 + 154 = 169 ?
     125 + 154 = 169 ?


Pairwise Coprime Scaling Theorem
Suppose we have three Pythagorean Triangles with the same hypotenuse
     Xj2 + Yj2 = Z2, for j = 1,2,3,
in which we require, from the area relationship,
     X1Y1 + X2Y2 = X3Y3.

If
     gcd(Xj,Yj) = tj, for j = 1,2,3,
then we can express
     Xj = xjtj, for j = 1,2,3,
     Yj = yjtj, for j = 1,2,3,
where
     gcd(xj,yj) = 1, for j = 1,2,3.

The three triangles are now
     (xjtj)2 + (yjtj)2 = Z2, for j = 1,2,3.

Since tj is a factor of the first two terms,
tj must also be a factor of Z, thus we can factor Z so that
     Z = z1t1 = z2t2 = z3t3.

Note that zj is coprime to xj and yj, since, if it wasn't,
then all three terms would have a common factor and
gcd(xj,yj) = 1 would not be true.

We now have the more detailed description,
(1)  (xjtj)2 + (yjtj)2 = (zjtj)2, for j = 1,2,3,
with
(2)  z1t1 = z2t2 = z3t3
and
(3)  x1y1t12 + x2y2t22 = x3y3t32
where
(4)  xj, yj, zj are pairwise coprime for j = 1,2,3.

Suppose that t1 and t2 have a common factor, f.
Then from (2), f is a factor of z3t3,
and from (3), f2 is a factor of x3y3t32.
But from (4), x3, y3, z3 are pairwise coprime,
thus f must be a factor of t3.

Similarly, if any two of the tj have a common factor, then all three
of them have the same factor.  It can then be divided out of all terms above,
producing a smaller solution.  So we can add to the required formulation.

(5)  t1, t2, t3 are pairwise coprime.

The conclusion is that not all Pythagorean Triangles can go together
to satisfy the area relationship.  When expressed in terms of the
key numbers (m,n,t), the three t values must be pairwise coprime.

Example
There are seven ways that 325 can be a hypotenuse,
two primitive
     (m,n,t) = (1,18,1), (6,17,1),
and five scaled
     (m,n,t) = (3,2,25), (2,1,65), (7,4,5), (8,1,5), (4,3,13).

But four of the scaled triangles have 5 as a common factor in their scaling,
so at most one of those can be chosen for a three-triangle combination.
Also, (2,1,65) and (4,3,13) have a common factor of 13 in their scaling.
So instead of 35 combinations of 7 step values to check, we only have 11.


Center Entry Prime Power Theorem
The Magic Hourglass Puzzle is not satisfiable if the central entry is a
power of a single prime.

Proof
There is only one primitive triangle possible when the hypotenuse is
a power of a prime;  all the other triangles will have a power of
that prime as the scale factor in its (m,n,t) formulation.
So at least two of the triangles of any selection of three
will have a common factor in their scaling.
This contradicts condition (5) above.


The 9-Square Problem
A 3x3 magic square of distinct squares is equivalent to
   four Pythagorean Triangles having the same hypotenuse
      with areas A1, A2, A3, A4 such that
   A1 + A2 = A3,
   A2 + A3 = A4.

By reasoning similar to the above arguments, all four scale factors must be
pairwise coprime.



Center Entry Two Prime Theorem
The center entry cannot be the square of a product of two primes.

Proof
We can produce all Pythagorean Triangles having the same hypotenuse if we
know the prime factorization of the hypotenuse.  We use scaling and
composition formulas.  Suppose p and q different are primes.
Then they each have a unique representation as the sum of two squares.

     p = e2 + f2;  e > f > 0;  gcd(e,f) = 1
     q = g2 + h2;  g > h > 0;  gcd(g,h) = 1

They also form their own primitive triangles.
     {Xp, Yp} = {2ef,  e2 - f2}
     {Xq, Yq} = {2gh,  g2 - h2}
assigned so that Xp > Yp  and  Xq > Yq.

Xp2 + Yp2 = p2 and Xq2 + Yq2 = q2
with gcd(Xp,Yp) = gcd(Xq,Yq) = 1.
Note that Xp, Yp, Xq, Yq are all positive.

If the common hypotenuse, pq, then there are four triangles.
Two are scaled and two are primitive.

The (m,n,t) representations are:
     (g, h, p)
     (e, f, q)
     (eh + fg, eg - fh, 1)
     (eg + fh, eh - fg, 1)

The legs of the triangles are:
     X1 = (2gh)p;  Y1 = (g2-h2)p
     X2 = (2ef)q;  Y2 = (e2-f2)q
     X3 = 2(eh + fg)(eg - fh) = (2gh)(e2-f2) + (2ef)(g2-h2)
     Y3 = (eh + fg)2 - (eg - fh)2 = (2ef)(2gh) - (e2-f2)(g2-h2)
     X4 = 2(eg + fh)(eh - fg) = (2gh)(e2-f2) - (2ef)(g2-h2)
     Y4 = (eg + fh)2 - (eh - fg)2 = (2ef)(2gh) + (e2-f2)(g2-h2)

If we assign Xp = (2ef), Yp = (e2-f2), Xq = (2gh), Yq = (g2-h2),
then twice the areas of the triangles are:
     X1Y1 = XqYqp2
     X2Y2 = XpYpq2
     X3Y3 = (YpXq + XpYq)(XpXq - YpYq)
     X4Y4 = (XpXq + YpYq)(YpXq - XpYq)
or
     X1Y1 =                   XqYq(Xp2 + Yp2)
     X2Y2 = XpYp(Xq2 + Yq2)
     X3Y3 = XpYp(Xq2 - Yq2) + XqYq(Xp2 - Yp2)
     X4Y4 = XpYp(Xq2 - Yq2) - XqYq(Xp2 - Yp2)

If we need to change the assignment of  Xp, Yp, Xq, Yq so that
Xp > Yp  and  Xq > Yq, note that X1Y1 and X2Y2 are unaffected.
Swapping Xp,Yp is equivalent to swapping X3Y3 with X4Y4 and
swapping Xq,Yq is equivalent to swapping and negating X3Y3 and X4Y4.

So for all assignments, all possibilities are still represented as long as
we recognize that X3Y3 and X4Y4 may be negative.


Can a Magic Hourglass be made from three of these triangles?
We need to find a solution to XiYi + XjYj = XkYk for some i,j,k.
We also need to include combinations where X3Y3 and/or X4Y4 are negated.
There are 36 combinations, however some cases are duplicates.  For example,
X1Y1 + X3Y3 = X4Y4 is the same as
X1Y1 - X4Y4 = -X3Y3  and  X4Y4 - X3Y3 = X1Y1.
This reduces the number to 16 combinations.

Case Group 1
X1Y1 + X2Y2 >  X3Y3
X1Y1 + X2Y2 > -X3Y3
X1Y1 + X2Y2 >  X4Y4
X1Y1 + X2Y2 > -X4Y4
X1Y1 + X3Y3 > -X4Y4
X2Y2 + X3Y3 >  X4Y4
X1Y1 + X3Y3 >  X4Y4
X2Y2 + X3Y3 > -X4Y4

Case Group 2
X1Y1 + X4Y4 = X3Y3  ==>  XqYq(3Yp2 - Xp2) = 0
X3Y3 + X4Y4 = X2Y2  ==>  XpYp(3Yq2 - Xq2) = 0

These cases cannot be satisfied because 3 times a square can't be a square
using positive numbers.

Case Group 3
X1Y1 + X4Y4 = X2Y2  ==>  YpYq(XqYp - XpYq) = 0
X2Y2 + X4Y4 = X1Y1  ==>  XpXq(XqYp - XpYq) = 0

These cases imply that Xq/Yq = Xp/Yp.  Each fraction consists of coprime pairs,
thus they are each reduced to lowest terms and Xq = Xp and Yq = Yp.
They represent the same triangle, thus p = q, contradicting the premise.

Case Group 4
X1Y1 + X3Y3 = X2Y2  ==>  XpYq(XpXq - YpYq) = 0
X2Y2 + X3Y3 = X1Y1  ==>  XqYp(XpXq - YpYq) = 0

These cases imply that Xp/Yp = Yq/Xq.  Each fraction consists of coprime pairs,
thus they are each reduced to lowest terms and Xp = Yq and Yp = Xq.
They represent the same triangle with the legs swapped, thus p = q,
contradicting the premise.

Case Group 5
X3Y3 + X4Y4 = X1Y1  ==>  XqYq(Xp2 + Yp2) = 2XpYp(Xq2 - Yq2)
X2Y2 + X4Y4 = X3Y3  ==>  XpYp(Xq2 + Yq2) = 2XqYq(Xp2 - Yp2)

Both instances have the same form and are impossible using positive numbers.
A proof for the first instance will suffice for both.

Dividing both sides by 2XpYpXqYq, we have
     Xp2 + Yp2   Xq2 - Yq2
     -------- = ---------
       2XpYp       XqYq

With coprime pairs of numbers, one odd and one even, the two fractions
are each reduced to lowest terms.
Therefore,
     Xp2 + Yp2 = Xq2 - Yq2.

Remembering that Xp2 + Yp2 = p2  and  Xq2 + Yq2 = q2,
we have
     Xq2 - Yq2 = p2  and  Xq2 + Yq2 = q2.

Multiplying the two equations yields
     Xq4 - Yq4 = (pq)2
which is impossible using positive numbers.


Center Entry Three Prime CONJECTURE
The center entry cannot be the square of a product of three primes.

Proof
Suppose p, q, r are different primes.  They each have a unique
representation as the sum of two squares.

     p = e2 + f2;  e > f > 0;  gcd(e,f) = 1
     q = g2 + h2;  g > h > 0;  gcd(g,h) = 1
     r = u2 + v2;  u > v > 0;  gcd(u,v) = 1

They also form their own primitive triangles.
     {Xp, Yp} = {2ef, e2 - f2}
     {Xq, Yq} = {2gh, g2 - h2}
     {Xr, Y4} = {2uv, u2 - v2}
assigned so that Xp > Yp, Xq > Yq, Xr > Yr.

Xp2 + Yp2 = p2, Xq2 + Yq2 = q2, Xr2 + Yr2 = r2
with gcd(Xp,Yp) = gcd(Xq,Yq) = gcd(Xr,Yr) = 1.
Note that the Xj and Yj are all positive.

The (m,n,t) representations are:

     (g, h, pr)
     (e, f, qr)
     (u, v, pq)
     (eh+fg, eg-fh, r)
     (eg+fh, eh-fg, r)
     (uh+vg, ug-vh, p)
     (ug+vh, uh-vg, p)
     (uf+ve, ue-vf, q)
     (ue+vf, uf-ve, q)
     (u(eg-fh)+v(eh+fg), u(eh+fg)-v(eg-fh), 1)
     (u(eh+fg)+v(eg-fh), u(eg-fh)-v(eh+fg), 1)
     (u(eg+fh)+v(eh-fg), u(eh-fg)-v(eg+fh), 1)
     (u(eh-fg)+v(eg+fh), u(eg+fh)-v(eh-fg), 1)

The legs of the triangles follow the general formula.

X5 = (2gh)pr = Xqpr
Y5 = (g2 - h2)pr = Yqpr

X6 = (2ef)qr = Xpqr
Y6 = (e2 - f2)pr = Ypqr

X7 = (2uv)pq = Xrpq
Y7 = (u2 - v2)pq = Yrpq

X8 = 2(eh+fg)(eg-fh)r = (XqYp + XpYq)r
Y8 = [(eh+fg)2 - (eg-fh)2]r = (XpXq - YpYq)r

X9 = 2(eg+fh)(eh-fg)r = (XqYp - XpYq)r
Y9 = [(eg+fh)2 - (eh-fg)2]r = (XpXq + YpYq)r

X10 = 2(uh+vg)(ug-vh)p = (XqYr + XrYq)p
Y10 = [(uh+vg)2 - (ug-vh)2]p = (XqXr - YqYr)p

X11 = 2(ug+vh)(uh-vg)p = (XqYr - XrYq)p
Y11 = [(ug+vh)2 - (uh-vg)2]p = (XqXr + YqYr)p

X12 = 2(uf+ve)(ue-vf)q = (XpYr + XrYp)q
Y12 = [(uf+ve)2 - (ue-vf)2]p = (XpXr - YpYr)q

X13 = 2(ue+vf)(uf-ve)q = (XpYr - XrYp)q
Y13 = [(ue+vf)2 - (uf-ve)2]p = (XpXr + YpYr)q

X14 = 2[u(eg-fh)+v(eh+fg)][u(eh+fg)-v(eg-fh)] = (YpXq + XpYq)Yr + (XpXq - YpYq)Xr
Y14 = [u(eg-fh)+v(eh+fg)]2 - [u(eh+fg)-v(eg-fh)]2 = (YpXq + XpYq)Xr - (XpXq - YpYq)Yr

X15 = 2[u(eh+fg)+v(eg-fh)][u(eg-fh)-v(eh+fg)] = (YpXq + XpYq)Yr - (XpXq - YpYq)Xr
Y15 = [u(eh+fg)+v(eg-fh)]2 - [u(eg-fh)-v(eh+fg)]2 = (YpXq + XpYq)Xr + (XpXq - YpYq)Yr

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Yr2) + XqYq(Xp2-Yp2)(Xr2-Yr2) - XrYr(Xp2-Yp2)(Xq2-Yq2) - 4XrYrXpYpXqYq
X17Y17 =  XpYp(Xq2-Yq2)(Xr2-Yr2) - XqYq(Xp2-Yp2)(Xr2-Yr2) - XrYr(Xp2-Yp2)(Xq2-Yq2) - 4XrYrXpYpXqYq

If we have to swap one or more Xj,Yj so that that Xj > Yj for all j,
note the following.

Swapping Xp with Yp is equivalent to
swapping and negating X8Y8 and X9Y9,
swapping and negating X12Y12 and X13Y13,
swapping and negating X14Y14 and X16Y16, and
swapping and negating X15Y15 and X17Y17.

Swapping Xq with Yq is equivalent to
swapping and negating X8Y8 and X9Y9.
swapping and negating X10Y10 and X11Y11,
swapping and negating X14Y14 and X17Y17, and
swapping and negating X15Y15 and X16Y16.

Swapping Xr with Yr is equivalent to
swapping X10Y10 and X11Y11,
swapping X12Y12 and X13Y13,
swapping X14Y14 and X15Y15. and
swapping X16Y16 and X17Y17.

So for all assignments, all possibilities are still represented as long as
we recognize that many of the terms may be negative.

Combinations can be eliminated when two or more terms have a common factor
in their scaling.  We can use at most one from the group
X5Y5, X6Y6, X8Y8, X9Y9 because they are scaled by r;
X5Y5, X7Y7, X10Y10, X11Y11 because they are scaled by p; and
X6Y6, X7Y7, X12Y12, X13Y13 because they are scaled by q.

X5Y5, X6Y6, X7Y7 are positive, but each of the others might be negative.