3x3 Magic Square of Squares
Formulations

Three-Term Formulation

Duplicate Entries

Properties of the Entries
All Zero or All Non-Zero Theorem
All Odd Or All Even Theorem
All Triples or All Non-Triples Theorem
Multiple of 24 Theorem
Central Entry Theorem
Non-Central Entry Theorem
No 8k+3 Entry Theorem
Middle Side Entry Theorem
Corner Entry Theorem

Pythagorean Triangle Formulation

Magic Square Formulations
Row Formulation
Center Formulation

Supporting General Formulas
Pythagorean Triangle General Formula
Arithmetic Progression General Formula

Studies and Curiosities
3x3 Magic Square of 7 Squares - Study 1
3x3 Magic Square of 7 Squares - Study 2
3x3 Magic Square of 7 Squares - Study 3
3x3 Magic Square of 8 Squares Construction Formula
Euler's 3x3 Magic Square of 7 Squares

Three-Term Formulation
Suppose we have a 3x3 magic square.
E11 E12 E13
E21 E22 E23
E31 E32 E33

Any 3x3 magic square can be expressed using the three terms,
a = (E23-E31),
b = (E21-E33), and
c = E22.

Proof
E21+E22+E23 = E11+E21+E31 ==> E11 = E22+(E23-E31) = c+a.
E13+E23+E33 = E13+E22+E31 ==> E33 = E22-(E23-E31) = c-a.
E21+E22+E23 = E13+E23+E33 ==> E13 = E22+(E21-E33) = c+b.
E11+E21+E31 = E11+E22+E33 ==> E31 = E22-(E21-E33) = c-b.
E11+E12+E13 = 3E22 ==> (E22+a)+E12+(E22+b) = 3E22 ==> E12 = c-(a+b).
E31+E32+E33 = 3E22 ==> (E22-b)+E32+(E22-a) = 3E22 ==> E32 = c+(a+b).
E11+E21+E31 = 3E22 ==> (E22+a)+E21+(E22-b) = 3E22 ==> E21 = c-(a-b).
E13+E23+E33 = 3E22 ==> (E22+b)+E23+(E22-a) = 3E22 ==> E23 = c+(a-b).

Substituting a,b,c for the E's:

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

Any values for a,b,c make a 3x3 magic square.
The sum of each row, column, and diagonal is 3c.

Note that there are eight 3-term arithmetic progressions.
Four of them run through the center.
c-(a-b),  c,  c+(a-b), with step value (a-b);
c-(a+b),  c,  c+(a+b), with step value (a+b);
c-a,      c,  c+a,     with step value a;
c-b,      c,  c+b,     with step value b.
The other four are
c-(a+b),  c-b,  c+(a-b), with step value a;
c-(a-b),  c+b,  c+(a+b), with step value a;
c-(a+b),  c-a,  c-(a-b), with step value b;
c+(a-b),  c+a,  c+(a+b), with step value b.

If we rearrange the terms as follows,
c-(a+b)  c-b   c+(a-b)
c-a      c     c+a
c-(a-b)  c+b   c+(a+b)
all rows and columns are 3-term arithmetic progressions.
Each row step value is a.
Each column step value is b.

Duplicate Entries
The above formulation allows duplicate entries.  A general 3x3 magic square
can have duplicate entries in several different ways, but if all entries
are squares, the situation is very different.

A 3x3 magic square of squares will have duplicate entries exactly when ab = 0.
This is important both for efficient searching and for a goal to show that
there exists no 3x3 magic square of distinct squares.

Proof
There are 36 pairs of entries that could be duplicated.
Using the Three-Term Formulation, equating each pair of entries, and solving
for a and b, produces the following result.
A duplication will exist in a general magic square if
(a = 0) or (b = 0) or (a = ±b) or (a = ±2b) or (b = ±2a).

By symmetry, a and b are interchangeable.
Also, negating a or b produces a mirror image solution with the same values.
So symmetry reduces the number of duplication patterns to three cases.
(1) a = b > 0,
(2) a = 2b > 0,
(3) a > 0, b = 0.

Duplicate Case (1) a = b > 0.
Substituting into the a,b,c formulation,

c+a   c-2a  c+a
c     c     c
c-a   c+2a  c-a

c-2a, c-a, c, c+a, c+2a represent 5 squares in arithmetic progression
with step value a.  It has been proved impossible for 4 or more squares to be
in arithmetic progression, so this case has no solution.

Duplicate Case (2) a = 2b > 0.
Substituting into the a,b,c formulation,

c+2b  c-3b  c+b
c-b   c     c+b
c-b   c+3b  c-2b

c-3b, c-2b, c-b, c, c+b, c+2b, c+3b represent 7 squares in arithmetic
progression with step value b.  For the same reason as the previous case,
there is no solution.

Duplicate Case (3) a > 0, b = 0.
Substituting into the a,b,c formulation,

c+a  c-a  c
c-a  c    c+a
c    c+a  c-a

c-a, c, c+a represent 3 squares in arithmetic progression with step value a.
The smallest solution is c-a = 1, c = 52, c+a = 72, a = 24 producing

72  12  52
12  52  72
52  72  12

Only duplication case (3) can produce solutions, so a 3x3 magic square
of squares will have duplicate entries if and only if a=0, b=0, or both.

Properties of the Entries

All Zero or All Non-Zero Theorem
In a 3x3 magic square of squares, either all entries are zero or all entries
are non-zero.

Proof
Suppose p2, q2, r2 are three squares in arithmetic progression.
and 0 < p < q < r.  We then have p2 + r2 = 2q2.
If q = 0 or r = 0, then 0 < p < 0, thus p = 0.
If p = 0, then r2 = 2q2, but a square can't be 2 times another square
unless they are both 0.
Therefore, if any one entry is 0, then all three entries are 0.

As shown above in the rearrangement of the Three-Term Formulation,
each row and column forms a 3-square arithmetic progression.
If one entry is 0, then its row and column are all 0's.
Each 0 in the column is part of a row which is in an arithmetic progression,
so all rows are 0.  Therefore, if one entry is 0, they're all 0.

All Odd Or All Even Theorem
In a 3x3 magic square of squares containing non-zero entries,
either all entries are odd or all entries are even.

Proof
The square of an even number is 0 (mod 4).
The square of an odd number is 1 (mod 4).
The magic sum of a 3x3 magic square is 3 times the central entry.
Each row is the sum of three 0,1 values (mod 4) which equals the magic sum.

If the central entry is 0 (mod 4), then the magic sum is 0 (mod 4).
The only way to add three 0,1 values to get 0 as a sum is if all values are 0.
So if the central entry is even, then all values are even.

If the central entry is 1 (mod 4), then the magic sum is 3 (mod 4).
The only way to add three 0,1 values to get 3 as a sum is if all values are 1.
So if the central entry is odd, then all values are odd.

All Triples or All Non-Triples Theorem
In a 3x3 magic square of squares containing non-zero entries, either
all entries are multiples of 3 or all entries are non-multiples of 3.

Proof
The square of a multiple of 3 is congruent to 0 (mod 3).
The square of a non-multiple of 3 is congruent to 1 (mod 3).
The magic sum of a 3x3 magic square is 3 times the central entry.
Each row is the sum of three 0,1 values (mod 3) which equals the magic sum.

If the central entry is 0 (mod 3), then the magic sum is 0 (mod 3).
If the central entry is 1 (mod 3), then the magic sum is 0 (mod 3).
The only way to add three 0,1 values to get 0 as a sum is if all values are
all 0's or all 1's.

Multiple of 24 Theorem
In the a,b,c formulation, the step values a and b are multiples of 24.

Proof
The squares must be all odd or all even.
If all even, then dividing by the biggest power of 2 makes a smaller solution
of odd squares.  An odd square is congruent to 1 (mod 8).
The difference between two squares congruent to 1 (mod 8) is a multiple of 8.
This also means that the original undivided solution has step values which
are multiples of 8.
The squares must all be 0 (mod 3) or all 1 (mod 3).
The difference between any two of the squares is 0 (mod 3), so the step
values must also be a multiple of 3.
Therefore, the step values are multiples of 8 x 3 or 24.

Central Entry Theorem
If the central entry has a prime factor of the form 4k+3,
then all entries have that factor.

Non-Central Entry Theorem
If a non-central entry has a prime factor of the form 8k+3 or 8k+5,
then all entries have that factor.

No 8k+3 Entry Theorem
If any entry has a prime factor of the form 8k+3,
then all entries have that factor.

Middle Side Entry Theorem
If a middle side entry has a prime factor of the form 8k+5,
then all entries have that factor.

Corner Entry Theorem
If a corner entry has a prime factor of the form 4k+3,
then the two middle side entries not adjacent to this corner
also have that factor.

Pythagorean Triangle Formulation
As the Three-Term Formulation shows, a 3x3 magic square of squares contains
eight 3-square arithmetic progressions.  Each progression can be formulated
as a Pythagorean Triangle.

Suppose P2, Q2, R2 are three squares in arithmetic progression with step value D.
Then
D = R2 - Q2 = Q2 - P2.

Setting P = X - Y, Q = Z, R = X + Y, we have
D = (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.

So a 3-square arithmetic progression, (P,Q,R), is equivalent to a
Pythagorean Triangle where Q is the hypotenuse, P is the difference of legs,
and R is the sum of legs.

Also,
D = Z2 - (X - Y)2
which expands to
D = Z2 - X2 - Y2 + 2XY.
Since Z2 - X2 - Y2 = 0, we have
D = 2XY,
thus the step value is 4 times the area of the triangle.

Magic Square Formulations

Row Formulation
The rearrangement of entries in the Three-Term Formulation shows that
the rows are 3-square arithmetic progressions with the same step value.
All columns are also 3-square arithmetic progressions.  Note that if
the row requirements are satisfied and one column is in arithmetic
progression, then the other two columns will follow.

If Pj2, Qj2, Rj2, j = 1,2,3, are the row arithmetic progressions
with step value D, then the formulation is
D = Rj2 - Qj2 = Qj2 - Pj2, for j=1,2,3
Q12 + Q32 = 2Q22

A 3-square arithmetic progression can be formulated as a Pythagorean Triangle.
Using this method, we are looking for three Pythagorean Triangles having
the same area with the squares of the three hypotenuses in arithmetic
progression.

If Xj2, Yj2, Zj2, j=1,2,3, are the Pythagorean Triangles,
then the formulation is
Xj2 + Yj2 = Zj2, for j=1,2,3
X1Y1 = X2Y2 = X3Y3
Z12 + Z32 = 2Z22

Center Formulation
The Three-Term Formulation shows that there are four 3-square arithmetic
progressions that run through the center entry.  The step values are
a, b, a+b, a-b.  Note that a-b, a, a+b is an arithmetic progression with
step value b.

If Pj2, Qj2, Rj2, j = 1,2,3,4 are the arithmetic progressions,
then the formulation is
a = R12 - Q12 = Q12 - P12
b = R22 - Q22 = Q22 - P22
a-b = R32 - Q32 = Q32 - P32
a+b = R42 - Q42 = Q42 - P42

A 3-square arithmetic progression can be formulated as a Pythagorean Triangle.
Using this method, we are looking for four Pythagorean Triangles having
the same hypotenuse with areas given by a, b, a-b, a+b.

If Xj2, Yj2, Zj2, j=1,2,3, are the Pythagorean Triangles,
then the formulation is
Xj2 + Yj2 = Zj2, for j=1,2,3,4
X4Y4 = X3Y3 - X2Y2 = X2Y2 - X1Y1

Supporting General Formulas

Pythagorean Triangle General Formula
Suppose we have a Pythagorean Triangle given by
X2 + Y2 = Z2.

If t = gcd(X,Y), then we can write
X = xt, Y = yt
and
t2x2 + t2y2 = Z2
or
t2(x2 + y2) = Z2
which means t must also be a factor of Z.

Therefore, Z = zt and factoring out t produces
x2 + y2 = z2
where gcd(x,y) = gcd(x,z) = gcd(y,z) = 1.

Rearranging terms,
x2 = z2 - y2 = (z + y)(z - y).

A square is congruent to 0 or 1 (mod 4), so the sum of two odd squares
cannot be a square.  Therefore, at least one of x and y is even.
But gcd(x,y)=1, so one of x and y is even and the other is odd.

Suppose x is even.  Then y and z are odd.  Thus z+y and z-y are even
and x2 is a multiple of 4.

Dividing both sides by 4,
x2/4 = [(z + y)/2][(z - y)/2].

Since gcd(y,z) = 1, gcd((z+y)/2,(z-y)/2) = 1.
If the product of two terms with no common factor is a square,
then both terms are squares.
So there must be
m2 = (z + y)/2, n2 = (z - y)/2
with
gcd(m,n) = 1
and then
x = 2mn, y = m2 - n2, z = m2 + n2.

Since y and z are odd, m and n cannot both be odd.
Since gcd(m,n)=1, m and n cannot both be even.
So one of m and n is odd and the other even.

Multiplying these equations by t restores the original triangle,
X = 2mnt, Y = (m2 - n2)t, Z = (m2 + n2)t.

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

Arithmetic Progression General Formula
Since an arithmetic progression of three squares can be represented by a
Pythagorean Triangle, which has a general formula, arithmetic progressions
must also have a general formula.

The Pythagorean Triangle Formulation for P2, Q2, R2, D
converted to the Pythagorean Triangle general formula yields
P = (m2 - n2 - 2mn)t
Q = (m2 + n2)t
R = (m2 - n2 + 2mn)t
D = 4mn(m2 - n2)t2
where m > n, gcd(m,n)=1, m and n are not both odd, t is unrestricted.