Magic Squares
Magic Squares
0.1 Introduction
In this rst chapter we'll study one of the most common mathematical games,
namely the magic square.
A magic square is a nxn-square table, in which we put the rst n2 natural
numbers (beginning form 1), without repetitions, in such a way that the sum of
each row, of each column and of each main diagonal is the same.
In the 3x3 case we have:
8 1 6
3 5 7
4 9 2
But if we take away the limitation imposed by the use of only natural number
and we establish to insert elements of a eld (e.g. R) then we can study this
objects in a better way.
Lemma 0.2.1 The n-order magic squares (i.e. the magic squares that have n
rows and n columns) are a vector space on R.
Proof. Let us consider the n-order magic squares as square matrices with
coecients in R.
- The identically zero matrix is a magic square.
- If we sum two magic squares of characteristic sum respectively S and S 0 we
obtain again a magic square of characteristic sum S + S 0 .
- If we multiply a magic square by a ∈ R (it's the same that we multiply a
matrix by a scalar) we obtain again a magic square of characteristic sum
a times the rst one.
Then, the magic squares are a vector subspace of square matrices; since the
last one is a nite dimensional space, then the rst one has a nite dimension.
The aim of this article is to determine the dimension of these subspaces.
a11 a12 ··· a1n
a21 a12 ··· a1n
.. .. .. ..
. . . .
an1 an2 ··· ann
The matrix's rows are denoted with R1 , ..., Rn , the columns with C1 , ..., Cn
and the main diagonals with D1 , D2 .
This is a very trivial case: in fact, if we x the sum S , we can see that the magic
squares are a 0-dimensional subspace, because the only square is:
S/4 S/4
S/4 S/4
To analize the following cases, we'll formulare the problem in a better way.
Let's consider the linear system with 2n + 2 equation and n2 unknowns that
is obtained imposing the conditions of the n-order magic square with a xed
sum S . An homomorphism is associated to this system:
2
f : Rn → R2n+2
in such a way that the solutions of the system are:
2n+2
X
f −1 (S ei )
i=1
First of all, let's notice that this linear system is not indipendent because
there's at least an equation that is a linear combination of the other one. In
fact, we have:
n
X n
X
Ri (a) = Cj (a)
i=1 j=1
in which X
Ri (a) = aik
1≤k≤n
n
X n
X
Cn (a) − D2 (a) = (ain − ai(n−i+1) ) = −a2(n−1) + a2n + (ain − ai(n−i+1) )
i=1 i=3
1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0
0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 −2 −1 −1 1 0 −1 0 1 0 0 −1
0 0 0 0 0 0 −1 1 0 −1 0 1 −1 0 0 1
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
- The 2n − 1-th column is linearly indipendent (in comparison with all the
preceding ones);
- The columns that have kn + 1 index, with 2 ≤ k ≤ n − 1, are linearly
indipendent form the other ones;
- All the columns that have an index greater than 2n − 1 and not in the form
kn + 1, with 2 ≤ k ≤ n − 1, are linear combinations of the preceding ones.
The system has the greatest rank (2n + 1) and so if we want to describe the
magic squares subspace, we need n2 − 2n − 1 parameter, and then the dimension
of this space is n2 − 2n − 1 (for n > 2).
Notice that a2(n−1) = 0 because it's in the second diagonal, then also
a1(n−1) = 0. The remaining is easily dened: a11 = a12 = 1/2, a21 = a22 =
−1/2, a1i = −1.
After an accurate analysis, we'll see that:
- If a2n = 1 then
1 1 0 ··· 0 −1 −1
−1 −1 0 ··· 0 1 1
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
. . . . . . .
. . . . . . .
. . . . . . .
0 0 0 ··· 0 0 0
- If aj2 = 1 with 3 ≤ j ≤ n − 2 then
−1
1 0 ··· 0 0 0
.. .
.
.
.
.
.
.
.
.
.
.
.
. . . . . . .
0 0 0 ··· 0 0 0
- If a(n−1)2 = 1 then
0 −1 0 ··· 0 1 0
1 0 0 ··· 0 −1 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
. . . . . . .
.. .
.
.
.
.
.
.
.
.
.
.
.
1
−1 0 ··· 0 0 0
0 0 0 ··· 0 0 0
- If an2 = 1 then
1 0 0 ··· 0 −1 0
0 −1 0 ··· 0 1 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
. . . . . . .
. . . . . . .
. . . . . . .
0 0 0 ··· 0 0 0
−1 1 0 ··· 0 0 0
Magic Squares by Massimiliano Patassini
1/2 1/2 0 ··· −1 ··· 0 0
1/2 −1/2 0 ··· 0 ··· 0 0
0
0 0 ··· 0 ··· 0 0
0
0 0 ··· 0 ··· 0 0
. . . . . . . .
. . . .
.
. . . .
. . . . . . .
−1
0 0 ··· 1 ··· 0 0
.. .
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . .
0 0 0 ··· 0 ··· 0 0
1 1 0 ··· −1 ··· −1 0
0 −1 0 ··· 0 ··· 1 0
0 0 0 ··· 0 ··· 0 0
0 0 0 ··· 0 ··· 0 0
0 0 0 ··· 0 ··· 0 0
. . . . . . . .
.. .
.
.
.
.
.
.
.
.
.
.
.
.
.
−1 0 0 ··· 1 ··· 0 0
- If an(n−1) = 1 then
1 1 0 ··· 0 −2 0
0 −1 0 ··· 0 1 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
. . . . . . .
. . . . . . .
. . . . . . .
−1 0 0 ··· 0 1 0
- If ann = 1 then
1 2 0 ··· 0 −2 −1
0 −2 0 ··· 0 2 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
0 0 0 ··· 0 0 0
. . . . . . .
. . . . . . .
. . . . . . .
−1 0 0 ··· 0 0 1
- If aii = 1 with 3 ≤ i ≤ n − 1, i 6= n − i + 1 then
0 1 0 ··· −1 ··· 0 0
1
−1 0 ··· 0 ··· 0 0
0
0 0 ··· 0 ··· 0 0
. . . . . . . .
. . . .
.
. . . .
. . . . . . .
−1
0 0 ··· 1 ··· 0 0
.. .
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . .
0 0 0 ··· 0 ··· 0 0
0 0 0 ··· 0 ··· 0 0
Magic Squares by Massimiliano Patassini
0 0 0 ··· −1 ··· 1 0
1
0 0 ··· 0 ··· −1 0
. . . . . . . .
. . . .
.
. .
.
. .
. . . . . .
−1 0 0
··· 1 ··· 0 0
.. .
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . .
0
0 0 ··· 0 ··· 0 0
0 0 0 ··· 0 ··· 0 0
0 0 0 ··· 0 ··· 0 0
−1
0 ··· 1 ··· 0 0
. . . . . . .
. . . . . . .
. . . . . . .
0 0 ··· 0 ··· 0 0
0 0 ··· 0 ··· 0 0
In the case n = 3, the dimension is 2 and then the matrices that constitute
a basis are 2. For example, they are:
0 −1 1
1 0 −1
−1 1 0
−1 0 1
2 0 −2
−1 0 0