Magic squares have a rich history dating back thousands of years; however, the elusive 3x3 magic square of squares still remains without construction. This project aims to give younger students -- particularly the aspiring mathematician -- an introduction to this open problem in recreational mathematics while providing new insight to how the problem can be approached. The findings described throughout the project are simple enough that they may be used as a basis for the reader to initiate their own search for the hypothetical magic square of squares.

Magic Squares Invariants

Introducing Magic Squares

A magic square is a square matrix of distinct integers in which all the columns, rows, and diagonals sum to the same value, called the magic constant. A typical example of a magic square is the 3x3 square composed of the first nine integers:
Out[]//MatrixForm=
8
1
6
3
5
7
4
9
2
Here, the magic constant of this square is 15. While we will focus on the technical aspects of magic squares throughout the project, an excellent history of magic squares and their construction can be found on Wikipedia.​
​
We now introduce some terminology: Consider the family of distinct values -- preferably integers:
Out[]=
{A,B,C,D,E,F,G,H,I}
We say that
E
generates a magic hourglass if it is at the center of the square
M
defined by
Out[]=
A
B
C
D
E
F
G
H
I
:M
satisfying
Out[]=
A+B+CG+H+IB+E+HA+E+IC+E+G:T
where
T
is the magic constant; visually, the magic hourglass has the form
Out[]//MatrixForm=
A
B
C
-
E
-
G
H
I
We say that
E
generates a magic square if, in addition,
Out[]=
TD+E+FA+D+GC+F+I
While countless magic squares exist for various sizes, called orders, we will only focus on 3x3 magic squares throughout this project. Thus, for the sake of simplicity, we refer to 3x3 magic hourglasses as magic hourglasses and we refer to 3x3 magic squares as magic squares from this point on.
​
If a magic square generated by
E
exists, then so does a magic hourglass generated by
E
. Equivalently, if a magic hourglass generated by
E
does not exist, then a magic square generated by
E
likewise does not exist. However, the existence of a magic hourglass generated by
E
does not necessarily imply the existence of a magic square generated by
E
: For a magic hourglass to produce a magic square depends on whether appropriate values of
D
and
F
exist or not. This will be an important fact for when we later cover magic squares of squares because the existence of a magic hourglass of squares has yet to be shown.
​
The crucial role
E
plays in “generating” a magic square -- as well as its configuration -- will now be explored.

The Twelve Invariants of Magic Squares

An invariant of a magic square is a property that holds regardless of the values of the square. Let us revisit the previous example of a magic square for some motivation of magic square invariants:
Out[]//MatrixForm=
8
1
6
3
5
7
4
9
2
Analyzing the configuration of the numbers in this magic square, notice that the magic constant is
15
, which is three times the center value of 5. Also, the sum of the corner values is 20, which is four times the center value. Can you find anymore interesting patterns? Are these patterns just coincidences? It turns out they are not; in fact, they are invariants. As we will see later, magic square invariants have applications to the magic square of squares problem; the inspiration to focus on magic square invariants comes from here.​
​
Let
M
be defined as before and assume that
M
is magical with
T
its magic constant. We know that magic squares are unique up to rotation and reflection by commutativity of addition. Namely, since
M
is a magic square, then so are
Out[]=
C
F
I
B
E
H
A
D
G
,
I
F
C
H
E
B
G
D
A
and so forth. Also, multiplying all values of a magic square by a constant results in a magic square by distributivity of multiplication. Namely, since
M
is a magic square, then so is the family of magic squares
Out[]=
kA
kB
kC
kD
kE
kF
kG
kH
kI
:kM
for
k
an integer; here, the magic constant is
kT
. These properties are important, but do not necessarily involve any intrinsic patterns in the configuration of the magic square; thus, we refer to them as the Zeroth Invariant of magic squares.
​
Define
Out[]=
A+B+C:
T
1
,
D+E+F:
T
2
,
G+H+I:
T
3
,
A+D+G:
T
4
B+E+H:
T
5
,
C+F+I:
T
6
,
A+E+I:
T
7
,
C+E+G:
T
8
By examining the magic hourglass of
M
, we have that
Out[]=
3T
T
5
+
T
7
+
T
8
A+B+C+3E+G+H+I3E+
T
1
+
T
3
3E+2T
so
Out[]=
T3E
This is the First Invariant of magic squares, which can be represented visually as
Out[]=
T3
A
B
C
D
E
F
G
H
I
Note that when we represent such an equation with a square with blue values, equality holds when summing over all the values in blue. Now, define
Out[]=
D+F:
S
1
,
B+H:
S
2
,
A+I:
S
3
,
C+G:
S
4
Since
Out[]=
TE+
S
1
E+
S
2
E+
S
3
E+
S
4
then by the First Invariant, we obtain the Second Invariant:
Out[]=
2E
S
1

S
2

S
3

S
4
Visually,
Out[]=
2E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Third Invariant follows trivially given that
M
is magical: By the First Invariant,
Out[]=
3E
T
1

T
2

T
3

T
4

T
5

T
6

T
7

T
8
Visually,
Out[]=
3E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Fourth Invariant is as follows: By the Second Invariant,
Out[]=
4E
S
1
+
S
2

S
1
+
S
3

S
1
+
S
4

S
2
+
S
3

S
2
+
S
4

S
3
+
S
4
By the Third Invariant,
Out[]=
4EE+
T
1
E+
T
3
E+
T
4
E+
T
6
Visually,
Out[]=
4E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Fifth Invariant is as follows: By the Second Invariant,
Out[]=
5EE+
S
1
+
S
2
E+
S
1
+
S
3
E+
S
1
+
S
4
E+
S
2
+
S
3
E+
S
2
+
S
4
E+
S
3
+
S
4
By both the Second Invariant and the Third Invariant,
Out[]=
5E
S
1
+
T
1

S
1
+
T
3

S
2
+
T
4

S
2
+
T
6
Visually,
Out[]=
5E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Sixth Invariant is as follows: By the Second Invariant,
Out[]=
6E
S
1
+
S
2
+
S
3

S
1
+
S
2
+
S
4

S
1
+
S
3
+
S
4

S
2
+
S
3
+
S
4
By the Third Invariant,
Out[]=
6E
T
1
+
T
2

T
2
+
T
3

T
4
+
T
5

T
5
+
T
6
Visually,
Out[]=
6E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Seventh Invariant is as follows: By the Second Invariant,
Out[]=
7EE+
S
1
+
S
2
+
S
3
E+
S
1
+
S
2
+
S
4
E+
S
1
+
S
3
+
S
4
E+
S
2
+
S
3
+
S
4
Visually,
Out[]=
7E
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Eight Invariant is as follows: By the Second Invariant,
Out[]=
8E
S
1
+
S
2
+
S
3
+
S
4
Visually,
Out[]=
8E
A
B
C
D
E
F
G
H
I
The Ninth Invariant is as follows: By the Second Invariant,
Out[]=
9EE+
S
1
+
S
2
+
S
3
+
S
4
Visually,
Out[]=
9E
A
B
C
D
E
F
G
H
I
The Tenth Invariant is as follows: By the Third Invariant,
Out[]=
T
1
A+B+CA+D+G
T
4
⟹
B+CD+G
T
1
A+B+CB+E+H
T
5
⟹
A+CE+H
T
1
A+B+CC+F+I
T
6
⟹
A+BF+I
T
1
A+B+CA+E+I
T
7
⟹
B+CE+I
T
1
A+B+CC+E+G
T
8
⟹
A+BE+G
T
2
D+E+FA+D+G
T
4
⟹
E+FA+G
T
2
D+E+FC+F+I
T
6
⟹
D+EC+I
T
3
G+H+IA+D+G
T
4
⟹
H+IA+D
T
3
G+H+IB+E+H
T
5
⟹
G+IB+E
T
3
G+H+IC+F+I
T
6
⟹
G+HC+F
T
3
G+H+IA+E+I
T
7
⟹
G+HA+E
T
3
G+H+IC+E+G
T
8
⟹
H+IC+E
Visually,
Out[]=
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I

A
B
C
D
E
F
G
H
I
The Eleventh Invariant is as follows: By both the Second Invariant and the Third Invariant,
Visually,
We are now ready to state the Twelfth Invariant: Assume that
where
If the values are additionally chosen such that
then
It follows that
Thus,
and we have that
For the sake of notation, define
so the previous inequality becomes
We can see that
To complete the magic square, we rule out the following possibilities again using the above inequality:
This is the Twelfth Invariant.
​
Note that there are certainly more invariants that could be stated, such as
but the main emphasis is that they all follow from the Second Invariant and the Third Invariant (which innately satisfy the First Invariant). While most of the previous invariants are listed to demonstrate this, the Twelfth Invariant is perhaps the most important in addition to the Second Invariant and the Third Invariant, as we will see in the next section.

Theory of Magic Squares of Squares

The Magic Squares of Squares Problem

Lemma

Proof of Lemma

Assume that
Now, assume that
Since
and
then
Therefore, the lemma holds. Q.E.D.

Theorem

Let
be a family of distinct values -- preferably integers -- such that
where
Then, if either
or

Proof of Theorem

Under assumption, observe that
implies
Now, define
By the previous lemma,
where
In the first case,
For this sum to satisfy the Third Invariant, it must follow that
or
In the second case,
For this sum to satisfy the Third Invariant, it must follow that
or
In the both cases,
For this sum to satisfy the Third Invariant, it must follow that
or
Therefore, the theorem holds. Q.E.D.

Generating Magic Squares of Squares

and
We will only consider the first system of equations for now (we will account for the second system of equations at the end of this section). We can rewrite the system of equations in several forms, namely
or
We can also combine the system of equations to a single equation each using the previous forms:
or
Recall from the previous theorem that we have
Intuitively, the form
Substituting values, this becomes
We will now reassign variable labels and restate what has just been shown to add further emphasis to its importance (this will also allow us to account for the second system of equations which we neglected).

Fundamental Form of Magic Squares of Squares

Let
be a family of distinct integers where
If
is such that
is such that

The Search for a Magic Square of Squares

The Computational Approach

Now that we have the fundamental form of magic squares of squares, we can develop an algorithm to search for potential solutions to the problem at hand:
After implementing this algorithm using Wolfram Language, a brute force search was performed through the first 500 million integers. While this is redundant in the sense that these numbers long since been checked, the first condition was relaxed to allow for the search for radical magic hourglasses/squares of squares. No magic hourglass of squares was found -- as expected -- but 173 radical magic hourglasses of squares were found, with 16 unique families. The generators of these radical magic hourglasses of squares are
with the unique generators being
which have prime factorizations
and log-scale distribution
The algorithm that discovered these generators is as follows:
Note that to perform your own search using this algorithm, replace the line
Some inspiration for sequences to check through -- in addition to sweeping through successive integers -- are those found on the OEIS, namely A084648, A097626, A006339, and A007185.
​
The 16 unique generators found produce the following radical magic hourglasses of squares:
If we “complete the square” for these generators, we get the following near-miss radical magic squares of squares:

The Geometric Approach

While it is exciting to see the results produced from the previous brute-force search, the radical magic hourglasses of squares found are unlikely able to help us find a “real” magic hourglass of squares. This is because the generators are irrational, so they are absent solution-wise from a key mathematical technique for dealings with Diophantine equations: projection mapping (see this wonderful paper).
​
We will now expand our search from before to include rational solutions: First, we can rewrite the fundamental form of magic squares of squares as a system of Diophantine equations, namely the solution to the magic square of squares problem lies in the system of equations
Relabeling using Cartesian coordinates,
where
The question remains: Do such values exist?

Conclusion

What’s Next?

The most challenging part of this project was trying to balance it with my rigorous course load and numerous extracurricular activities. In the time I was able to dedicate to this project, most of it was spent with reading, verifying proofs, designing algorithms, and performing computational searches; there is certainly room for improvement in the latter two.
​
What has been presented in this project are the most appreciable results I produced and merely scratches the surface of everything I explored. A paper is currently in the works: I have drafted the material of this project and am beginning to more investigate more algebraic methods.
​
Given the “abundance” of rational magic hourglasses of squares, I believe a rational magic square of squares can exist; of course, this relies on magic squares being able to be composed of eight perfect squares, let alone nine. I hope that the methods developed here may be used in determining an answer.
​
I will continue exploring the magic squares of squares problem as a Wolfram Student Ambassador.

Further Readings

Keywords

◼
  • Magic hourglasses
  • ◼
  • Magic squares
  • ◼
  • Magic squares of squares
  • ◼
  • Radical magic hourglasses
  • ◼
  • Radical magic squares of squares
  • Acknowledgment

    Special thanks to my mentor Peter Barendse for taking the time to guide my project, bounce ideas around, and discuss higher-level mathematics topics. Further thanks to Rory Foulger and Eryn Gillam for running WELP:U and checking-in on my progress. I would finally like to thank my friends at Caltech who gave feedback and support throughout my project.

    References

    ◼
  • Magic Square
  • ◼
  • Magic Square of Squares
  • ◼
  • Some Notes on the Magic Squares of Squares Problem
  • ◼
  • Latest Research on the "3x3 Magic Square of Squares" Problem
  • ◼
  • Special Magic Squares, Squares of Squares
  • ◼
  • Magic Squares of Squares
  • ◼
  • Magic Squares of Squares (are PROBABLY impossible) - Numberphile
  • ◼
  • Compound Lucas Magic Squares
  • ◼
  • A084648
  • ◼
  • A097626
  • ◼
  • A006339
  • ◼
  • A007185
  • ◼
  • On A4 + B4 + C4 = D4
  • ◼
  • The Group of Rational Points on the Unit Circle
  • ◼
  • Gaussian Integers, Rings, Finite Fields, and the Magic Square of Squares
  • ◼
  • A New Transformation of the Magic Square of Squares
  • ◼
  • Introducing n-Magic Groups and Characterizing 3-Magic Finitely Generated Abelian Groups
  • ◼
  • Magic Squares of Squares
  • ◼
  • Results of Computer Search for a Perfect Cuboid
  • CITE THIS NOTEBOOK

    Exploring magic squares of squares​
    by Russell Martinez​
    Wolfram Community, STAFF PICKS, June 6, 2024
    ​https://community.wolfram.com/groups/-/m/t/3188586