Ways To Get Magic Squares 5x5
Ways To Get Magic Squares 5x5
Ways To Get Magic Squares 5x5
1 Abstract
Using an algorithm from the paper “Creating Semi-Magic, Magic and
Extra Magic n x n Squares when n is Odd”, we define 28,800 extra
magic (or panmagic) 5 x 5 squares. We show that these 5 x 5 extra
magic squares are also extremely magic. This means that all of these
50
Mathematics Competitions Vol 27 No 2 2014
28,800 extra magic 5 x 5 squares have the same 120 magic 5 element
subsets whose sum is 65. Of course, these subsets include the 5 rows and
5 columns and the 10 generalized diagonals. We also discuss additional
magic properties. We also define 28,800 similarity mappings on these
5 x 5 extremely magic squares that map these 120 magic 5 element
subsets onto each other. As always, these 28,800 similarity mappings
form a group. If we use any one of the 5 x 5 extremely magic squares
as the domain and use any other as the range then the function that
we create will be one of these 28,800 similarity mappings. Thus, we
can loosely say that the 28,800 magic squares themselves form a group.
However, the graph of a group is a more accurate term.
At the end, we state a variation of Hall’s Marriage Theorem that can
greatly enhance this paper. Much of this paper can be generalized, but
the 5 x 5 magic squares have properties that are unique.
2 In tr o d u ctio n
Using an algorithm developed in the paper “Creating Semi-Magic, Magic
and Extra Magic n x n Squares when n is Odd”, we define the following
5 x 5 Matrix. All the results of this paper are derived from this matrix.
Throughout this paper, we use the term line to mean any of the 20 rows,
columns, and generalized diagonals.
Figure 1: A 5 x 5 Matrix
Note that this matrix contains all the ordered pairs (aj,A 7), i =
0 ,1 ,2 ,..., 4, j = 0 ,1 ,2 ,..., 4. We can also define the dual 5 x 5 matrix
where we change each (a i,A j) in Fig. 1 to (a^A;). Thus, the second
row of the dual matrix would read (a2, A3), (a3, A4), (a4, A0), (a0, A x),
(ai,A 2). In Fig. 1 we agree that a0, a4, a2, a3, a4 is any arbitrary but
fixed permutation of the integers 0,1,2,3,4. Also, A0, A u A2, A3, A 4 is
any arbitrary but fixed permutation of 0,1,2,3,4.
51
Mathematics Competitions Vol 27 No 2 2014
In Fig. 1, if we permute ao, ax, 02,03, 0 ,4 in all possible ways and permute
A0, A i, A2, A3, A4 in all possible ways we can define 5! • 5! = 14,400
different 5 x 5 matrices.
For each ordered pair (a*, A,) in Fig. 1, let us assign the number
(a , i , A j = a* + 5 (Aj — 1) where a*, Aj are the numerical values that
have been assigned to at,Aj.
Now 1 < ai < (Oj, A j )# = at + 5 (Aj —1) < 5 + 5 (5 —1) = 52. That is,
1 < (Oi,Aj)* < 25.
since the matrix contains all the ordered pairs (a*, A,), i = 0 ,1 ,2 ,..., 4,
j = 0 ,1 ,2 ,. .. , 4. Thus, we can place 1,2,3, • • • ,25 in the 5 x 5 matrix.
Let us now observe the following about Fig. 1, namely that each row
contains each of an, a%, a2, a3, <14 and contains each of An Aj, A 2, A n A 4 .
Also, each column contains each of an, ai, a2, a3, 04 and contains each
of A), Ai, A2, A3, A4. Also, each of the two main diagonals and each of
the 8 generalized diagonals contains each of ao, ai, 02,03 , 0 4 and contains
each of A0, Aj, A 2, A3, A4.
Note that there axe 10 generalized diagonals in Fig. 1 when we count
the two main diagonals. One example of a generalized diagonal is the
52
M athem atics C om petitions Vol 27 N o 2 2014
set {(ai, A-]) , (a0, A4) , (a4, A 2) , (a3, A0) , (a2,A 3)}. Another example
is {(oi, A \ ) , (a3, A 2) , (a0, A3) , (a2, A 4) , (<24, A0)}. If we use the code
n
(a,, A j ) w = a, + 5 (Aj - 1) we now show th a t the sum of the 5 numbers
in each row, in each column and in each generalized diagonal equals to
| (1 + 2 4-------1-25) = | | (26) = 65. This means th a t the 5 x 5 M atrix
of Fig. 1 becomes an extram agic (or panmagic) 5 x 5 square.
For example, the sum of the 5 numbers in the 1st main diagonal equals
= ^ 2 ai + 5 ^ 2 Ai — 5-5
2=0 i—0
5 4
= ^ 2 ^ + -5-5
i=i i= 0
= 15 + 5 - 1 5 - 2 5
= 65,
3 A S p ecific E x a m p le
In Fig. 1, we now let (00,04,0:2,03,04) = (3 ,5 ,1 ,2 ,4 ) and (A0,A i,
A2, A3, A4) = (2 ,1 ,5 ,4 ,3 ). Using the code (a*, A j ) * = o* + 5 (Aj - 1)
we have the extra magic 5 x 5 square of Fig. 2.
8 5 21 17 14
22 19 13 10 1
15 6 2 24 18
4 23 20 11 7
16 12 9 3 25
53
Mathematics Competitions Vol 27 No 2 2014
The magic 5x5 square of Fig. 2 is actually extremely magic and we show
later how to use this extremely magic 5 x 5 square to generate 28,800
different, extremely magic 5 x 5 squares.
Note 1. Suppose that instead of using the integers 1 though 25, we are
interested in putting any numbers a\, a?, . . . , 025 in the 25 positions of
the 5 x 5 matrix so that the sum of the 5 numbers in each row, column,
and generalized diagonal is the same. This leads to a system of linear
equations in the variables ax, 02, , a 25- Professor Ben Klein has shown
that the rank of this system of linear equations is 16. Thus, it is possible
to find a subset of nine letters a ^ , aj2, . . . , aj9, and arbitrarily specify the
values of these nine letters. Then we can compute the unique values of
the other 16 letters in terms of the 9 given letters. In the 5 x 5 matrix of
Fig. 1, let us now use the code = a, + Aj and then place these
values (a,i,Aj)& in the 5 x 5 matrix. We note from Fig. 1 that the sum
of the 5 numbers on each line is always the same value
4 4
y a‘+y
2— 0 2— 0
A*-
In the rest of this paper, we assume that (a0, ai, a2, 03, o4) and (A0, A\,
A2,A 3,A 4) have been arbitrarily fixed by Fig. 2. In Fig. 1, let us
now permute A0, A\, A 2, A3, A4 in all possible ways to create 120 dif
ferent 5 element sets of ordered pairs {(a0, Ai0) , (ai, A n ) , (a2, A i2) ,
(<23, Ai3) , (a4, An)}.
Thus, one example would be the 5 element set {(a0, A i) , (ai, A2) ,
(a2, A4) , (a3, A0) , (a4, A3)}. These 120 5-element sets of ordered pairs
will define 120 different 5 element subsets of the Fig. 1 matrix. When
we use the code (a,, A j)w = ai + 5 (Aj - 1), each of these 120 differ
ent 5 element subsets of the Fig. 1 matrix will be a magic 5 element
subset of the Fig. 1 matrix since the sum of the 5 elements in the set
will be equal to 65. This follows since each of these 120 different 5 el
ement subsets of Fig. 1 will contain each of the letters ag, a4, a2, 0.3, a4
and contain each of the letters A0, A\, A2, A3, A4 and since the code is
(<2i, Aj)* = ai + 5 (Aj —1 ) .
Also, of course, {a0, a4, a2, a3, a4} = {0,1,2,3,4} and {A0, A 1,A 2,A 3,
A 4 } = (0 ,1 ,2 ,3 ,4 } .
After we go through all of the 120 sets {(a0, Ai0) , (a4, AiX) , (a2, Ai2) ,
(a3, A i3) , (a4, Ai4)} we have the classification of the 120 magic 5 element
subsets of Fig. 1 that is shown below. In these drawings, we also state
the number of times that each magic 5 element configuration appears in
Fig. 1. We note that there are 16 different configurations th at are listed
below and most of these 16 configurations can appear many times in the
5 x 5 matrix of Fig. 1. For example, the configuration of drawing G can
appear 16 times in the 5 x 5 matrix of Fig. 1.
55
Mathematics Competitions Vol 27 No 2 2014
56
Mathematics Competitions Vol 27 No 2 2014
We note that the sum of the numbers in these 16 drawings equals 120
which means that these configurations appear 120 times in Figs. 1, 2.
We also note that every time that one of the 16 configurations appears
in Fig. 1 this set of 5 elements will contain all of ao, ai, a2, a3, a4 and
contain all of A0, A \, A2, As, A4. These 120 subsets of Fig. 1 are also the
only 5 elements subsets of Fig. 1 that contain all of ao, ai, a2, a3 , a4 and
contain all of Ao, Ai, A2, A3, A4. Also, these 120 subsets of Fig. 1 are
the only five-element subsets of Fig. 1 such that each pair of points in
the set lie on a line.
We note that drawing A represents the horizontal rows and vertical
columns for a total of 10. Also, drawing N represents the two main
diagonals for a total of 2. Also, drawings O, P together represent the 8
generalized diagonals for a total of 8.
Let us now focus our attention on drawing E. This configuration appears
4 times in Figs. 1, 2. These are
{(ao, A0) , (ai, A i), (a3, A2) , (a4, A4) , (a2, A3)} = {8,5,22,14,16} ,
{(a2, A3) , (a4, A i), (a3, A4) , (a0, A0) , (a4, A2)j = {16,4,12,8, 25} ,
{(°i> A2) , (ao, A i), (a3, A0) , (a2, A3) , (a4, A4)} = {25,3,7,16,14} ,
{(a4, A4) , (a2, A i), (a3, A3) , (aj, A2) , (ao, Ao)} = {14,1,17,25,8} .
Note 1. Each of these four 5 element subsets contain all of ao, a 4, a2, a3,
a4 and contain all of Ao, A4, A2, A3, A4 and the sum of the 5 numbers
in each of these four 5 element subsets is always 65. The sum of the 5
elements in each of the 120 magic subsets will always equal 65.
In Section 10, we state that a variation of Hall’s Marriage Theorem can
be used to show that these 5 x 5 extremely magic squares are actually
much more magic than what we have studied in this section. However,
we consider Hall’s Marriage Theorem to be outside of the scope of this
paper. So in Section 10 we state these results without proof. In Section
11, we state a variation of Hall’s Marriage Theorem.
57
Mathematics Competitions Vol 27 No 2 2014
5 S im ila rity M a p p in g s on th e F ig . 1 M a tr ix
Remember that 00,01,02,03,04 and A),A , A2, An Ai can be any ar
bitrary permutations of the integers 0,1,2,3,4. In this paper we have
agreed that 00,01,02,03,04 and A0,Ai , A2,A 3,A 4 have been fixed by
Fig. 2.
We observe that the arrangement of the five (a*, A'Vs in the t°P row of
Fig. 1 will completely determine the arrangement (or permutation) of
all 25 (oi, AjYs in Fig. 1. For example, if the top row of Fig. 1 reads
( a i, A0) , (a3, A t) , (ao, A ) , («4, A ) , (a2, A ) we know that we are using
the permutations and A0,A, A, A, A
These
^ A0, A4, A3, A i , A2
15 ^3 5 CLO 5 ^4 > ^2
permutations determine all 25 entries in the Fig. 1 matrix and these 25
entries are shown in Fig. 3.
58
Mathematics Competitions Vol 27 No 2 2014
In Fig. 4 we have num bered the squares of Fig. 1 1,2,3, • • • , 25. Thus,
1 = (a0,A 0) ,2 = ( a i,A i ) ,3 = (o2,A 2), etc.
59
Mathematics Competitions Vol 27 No 2 2014
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
60
M athem atics C om petitions Vol 27 No 2 2014
9 24 3 4 5 1 10 25 4 5
6 7 11 1 10 6 7 8 12 2
8 12 13 14 18 19 9 13 14 15
16 25 15 19 20 16 17 21 11 20
21 22 23 2 17 18 22 23 24 3
/oil O.Q — di / i 2 i a i —a 2
1 2 6 21 5 1 2 3 7 22
3 7 8 9 13 14 4 8 9 10
11 20 10 14 15 11 12 16 6 15
16 17 18 22 12 13 17 18 19 23
4 19 23 24 25 21 5 20 24 25
24 9 3 4 5 1 25 10 4 5
6 7 8 2 12 13 7 8 9 3
11 10 20 14 15 11 12 6 16 15
23 17 18 19 13 14 24 18 19 20
21 22 16 1 25 21 22 23 17 2
goi, Ao - A\ 912, — A2
1 2 21 6 5 1 2 3 22 7
4 14 8 9 10 6 5 15 9 10
11 12 13 7 17 18 12 13 14 8
16 15 25 19 20 16 17 11 21 20
3 22 23 24 18 19 4 23 24 25
9 2 3 , A-2 — A 3 934, A3 — A4
1 2 3 4 5
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
61
M athem atics C om petitions Vol 27 No 2 2014
62
Mathematics Competitions Vol 27 No 2 2014
matrix will have the same 120 magic 5 element subsets as the origi
nal matrix. Also, the 14,400 similarity mappings of Section 5 for the
original magic squares will be exactly the same as the 14,400 similarity
mappings for the dual magic squares. Therefore, we can use the same
basis /oi,/i2>/23,/34,5oi,512,523,534 for the similarity mappings of the
dual magic squares. By direct computation, it is very easy to show that
/*,»+1 ° h = ho gi<i+1 and 5i,i+i o h = ho / M+1 for i = 0, 1, 2,3.
f i , i - f-1 O ft — h O 1
4- 5 i,i+ i °h = ho / i>i+1.
Since g (/oi, / 12, /23, /34) — S5 and 5 (501, 512, 523, 534) — S5 where
S5 is the symmetric group on {0,1, 2,3,4}, we see from law 2 that
5 (/oi,/i2,/23,/34,501,512,523,534) — S5 x S5. This fact was also ob
served in Section 5. When we add h to /oi, / 12, / 23, / 34, 5oi, 512, 523,534
we see that we generate a dihedral type group that has 28,800 permu
tations.
7 A P u zz le
Suppose we start with the 5 x 5 extremely magic square of Fig. 2.
However, suppose that we are not aware that Fig. 2 is extremely
magic, but we only know that Fig. 2 is extra magic (or panmagic).
That is, we are only aware of the fact that the sums of the 5 num
bers in each of the 5 rows, 5 columns and 10 generalized diagonals
equal 65. Also, suppose that we are given the 8 basic permutations
/oi,/i2,/23,/34,501,512,523,534 of Section 6 . If we operate on the
Fig. 2 magic square in any arbitrary way by using these permutations
/oi, / 12, • • • , 534, we will always have an extra magic 5 x 5 square, and we
63
Mathematics Competitions Vol 27 No 2 2014
in any arbitrary way in the 5x5 matrix. As always, we let ao, a i, 02, 03, <24
and A0, Ai, A2, A3, A be any arbitrary permutation of 0 , 1,2,3,4. As
4
always, we use the code (a*, Aj')* = Oj + 5 (Aj —1) to place the numbers
1,2,3,4, • • • , 25 in the 5x5 matrix. Analogous to this paper, we can deal
with all permutations of ao, ai, a2, a3, and Ao, A \ , A 2, A3, A4 which we
0 ,4
ao ai a a 3 04
2 Ao Ai A2 A3 A4
call and
1 Qj,i 2 i4 Aj 0Aj 1Aj 2Aj 3Aj 4
As in this paper, we can find 120 magic 5 element subsets whose sum is
always 65 and all 14,400 5 x 5 matrixes will have these same 120 magic
5 element subsets. We can also define the dual matrix and we leave it
to the reader to study whether the entire theory in this paper holds in
general for the dual matrix.
9 A P r o je c t for th e R ead er
We invite the reader to use the permutations
a o a ia 2 0 3 a 4 A0A1A2A3A 4
0004030204 A0A3A1A4A2
and observe that the permutation / that we define maps rows and
columns of the Fig. 1 matrix onto generalized diagonals and maps gen
eralized diagonals onto rows and columns. We then invite the reader to
find other such permutations / of the Fig. 1 matrix that map the 20
rows, columns and generalized diagonals onto the 20 rows, columns and
generalized diagonals in various ways.
64
Mathematics Competitions Vol 27 No 2 2014
11 A U se fu l M arriage T h eo rem
Suppose dots are placed in the squares of an n x n checkerboard arbi
trarily but so that each row and each column has exactly k dots. We
65
Mathematics Competitions Vol 27 No 2 2014
We are grateful to Prof. Ben Klein of Davidson College for his very
useful comments and for computing the rank of the matrix of Note 1.
R eferen ces
[1] http://en.Wikipedia.org/wiki/Hall
[2] http://www.cut-the-knot.org/arithmetic/elegant.shtml
[3] http://en.Wikipedia.org/wiki/Pandiagonal_magic_square
66
Copyright of Mathematics Competitions is the property of AMTT Limited, trading as
Australian Mathematics Trust and its content may not be copied or emailed to multiple sites
or posted to a listserv without the copyright holder's express written permission. However,
users may print, download, or email articles for individual use.