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
Magic Squares Invariants
Introducing Magic Squares
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:
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 generates a magic hourglass if it is at the center of the square defined by
E
M
Out[]=
A | B | C |
D | E | F |
G | H | I |
satisfying
Out[]=
A+B+CG+H+IB+E+HA+E+IC+E+G:T
where is the magic constant; visually, the magic hourglass has the form
T
Out[]//MatrixForm=
A | B | C |
- | E | - |
G | H | I |
We say that generates a magic square if, in addition,
E
Out[]=
TD+E+FA+D+GC+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 exists, then so does a magic hourglass generated by . Equivalently, if a magic hourglass generated by does not exist, then a magic square generated by likewise does not exist. However, the existence of a magic hourglass generated by does not necessarily imply the existence of a magic square generated by : For a magic hourglass to produce a magic square depends on whether appropriate values of and 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 plays in “generating” a magic square -- as well as its configuration -- will now be explored.
If a magic square generated by
E
E
E
E
E
E
D
F
The crucial role
E
The Twelve Invariants of Magic Squares
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 , 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 be defined as before and assume that is magical with its magic constant. We know that magic squares are unique up to rotation and reflection by commutativity of addition. Namely, since is a magic square, then so are
15
Let
M
M
T
M
Out[]=
| , |
|
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 is a magic square, then so is the family of magic squares
M
Out[]=
kA | kB | kC |
kD | kE | kF |
kG | kH | kI |
for an integer; here, the magic constant is . 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
k
kT
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 , we have that
M
Out[]=
3T++A+B+C+3E+G+H+I3E++3E+2T
T
5
T
7
T
8
T
1
T
3
so
Out[]=
T3E
This is the First Invariant of magic squares, which can be represented visually as
Out[]=
T3
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[]=
TE+E+E+E+
S
1
S
2
S
3
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 is magical: By the First Invariant,
M
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[]=
4EE+E+E+E+
T
1
T
3
T
4
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[]=
5EE++E++E++E++E++E++
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 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[]=
7EE+++E+++E+++E+++
S
1
S
2
S
3
S
1
S
2
S
4
S
1
S
3
S
4
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[]=
9EE++++
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 T 4 | ⟹ | B+CD+G |
T 1 T 5 | ⟹ | A+CE+H |
T 1 T 6 | ⟹ | A+BF+I |
T 1 T 7 | ⟹ | B+CE+I |
T 1 T 8 | ⟹ | A+BE+G |
T 2 T 4 | ⟹ | E+FA+G |
T 2 T 6 | ⟹ | D+EC+I |
T 3 T 4 | ⟹ | H+IA+D |
T 3 T 5 | ⟹ | G+IB+E |
T 3 T 6 | ⟹ | G+HC+F |
T 3 T 7 | ⟹ | G+HA+E |
T 3 T 8 | ⟹ | H+IC+E |
Visually,
Out[]=
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
|
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
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
Theory of Magic Squares of Squares
The Magic Squares of Squares Problem
The Magic Squares of Squares Problem
Lemma
Lemma
Proof of Lemma
Proof of Lemma
Assume that
Now, assume that
Since
and
then
Therefore, the lemma holds. Q.E.D.
Theorem
Theorem
Let
be a family of distinct values -- preferably integers -- such that
where
Then, if either
or
Proof of Theorem
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
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
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 Search for a Magic Square of Squares
The Computational Approach
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
If we “complete the square” for these generators, we get the following near-miss radical magic squares of squares:
The Geometric Approach
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
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
Conclusion
Conclusion
What’s Next?
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.
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
Further Readings
Keywords
Keywords
◼
Magic hourglasses
◼
Magic squares
◼
Magic squares of squares
◼
Radical magic hourglasses
◼
Radical magic squares of squares
Acknowledgment
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
References
CITE THIS NOTEBOOK
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
by Russell Martinez
Wolfram Community, STAFF PICKS, June 6, 2024
https://community.wolfram.com/groups/-/m/t/3188586