- 1. Journal of Nepal Mathematical Society (JNMS), Vol. *, Issue * (20**); L. de O. Miranda, L.B.B.Miranda Construction of Magic Squares by Swapping Rows 1 and Columns 2 Lohans de Oliveira Miranda1 , Lossian Barbosa Bacelar Miranda2 3 1 UNEATLANTICO, Santander, Spain 4 2 IFPI, Teresina, Brazil 5 Correspondence to: Lossian Barbosa Bacelar Miranda, Email: lossianm@gmail.com 6 Abstract: By jointly swaps the rows and columns of any magic square of order n we construct (n−1 2 )! 7 magic squares. We establish a classification of magic squares for any orders. The classification is based on 8 previous work by Del Hawley. 9 10 Keywords: Swap of rows and columns in magic squares, Del Hawley’s magic squares, Generalizations 11 of Dürer’s magic square, Balanced levers method, Education of young people and children. 12 1 Introduction 13 As students, magic squares were not part of our curriculum. Luckily for us, now, magic squares are part of 14 both the Cambridge NRICH (Del Hawley, 1998; revised 2022, p. 1) and the 6th year curriculum in schools 15 in the State of São Paulo in Brazil (Secretaria de Educação, 2023, p. 21). This article is a testimony to the 16 beauty of mathematical ideas, especially when they develop from the simplicity of the educational process. 17 A magic square of order n is a square matrix formed by the numbers 1, 2, 3, . . . , n2 and such that the sum 18 of the numbers in each row, each column and each of the two diagonals is equal to cn = n+n3 2 . We call cn 19 of constant magic. By the way, let’s look at a short text from NRICH: 20 21 “Some of the properties of magic squares are: 22 1) A magic square will remain magic if any number is added to every number of a magic square. 23 2) ... 24 3) A magic square will remain magic if two rows, or columns, equidistant from the centre are interchan- 25 ged” (Del Hawley, 1998, p. 1). 26 27 The analysis of this text led us to a classification of magic squares. 28 2 Del Hawley’s magic squares 29 Say Del Hawley: “3. A magic square will remain magic if two rows, or columns, equidistant from the centre 30 are interchanged” (Del Hawley, 1998, p. 1). Let us note that the following magic square (1) does not obey 31 the supposed rule 3 mentioned above. 32 M = 3 5 12 14 16 10 7 1 13 11 6 4 2 8 9 15 (1) 33 In fact, 34 35 N = 3 12 5 14 16 7 10 1 13 6 11 4 2 9 8 15 (2) 36 it is not a magic square, because 37 3 + 7 + 11 + 15 = 36 ̸= 32 = 14 + 10 + 6 + 2 1
- 2. Construction of Magic Squares by Swapping Rows and Columns Proposition 1.The double swap of lines and columns that are the same distance from the center of a magic 38 square transforms it into another magic square, this magic square being the same, regardless of whether we 39 swap rows or columns first. For each i ∈ In−1 2 (n, odd) and i ∈ In 2 (n, even) the mapping ρi defined by this 40 double swap is bijective map in the set of magic squares. 41 Demonstration. See (de Oliveira Miranda, 2023). 42 43 Observation 1. By the fundamental principle of counting, for each magic square M of odd order n we can 44 generate 2 n−1 2 magic squares, including M itself. By the same principle, if n is even we can generate 2 n 2 45 magic squares. To verify this, we simply note that the set of magic squares M ∪ Sn k=1;ρi1 <ρi2 <ρi3 <...<ρik ρi1 · 46 ρi2 ·ρi3 ·...·ρik (M) it has 2 n 2 elements if n is even and 2 n−1 2 elements if n is odd. Since ρi is bijective map, M 47 will be magic square if and only if ρi(M) is magic square. Therefore, the double swap constitutes a geometric 48 characterization of the magic squares. The same reasoning applies to magic cubes. In fact, if we swap the 49 three pairs of parallel planes equidistant from the center of a magic cube we will obtain a new magic cube. 50 And the same goes for magic k-hypercubes in general. All, for any order and dimension, are geometrically 51 characterized by the swaps of pairs of (k-1)-hypercubes equidistant from the center of the magic k-hypercube. 52 53 Definition 1 (Del Hawley’s Magic Squares). We will say that a magic square is Del Hawley by columns 54 when the swap of two columns equidistant from the center always transforms it into another magic square. 55 If the same occurs in relation to equidistant lines, we will call Del Hawley by lines. If both conditions are 56 satisfied, we will simply call it a Del Hawley magic square. 57 58 Observation 2. Note that a magic square 59 60 A = a1,1 . . . a1,n ... ... . ai,i ai,n+1−i . . ... . . an+1−i,i an+1−i,n+1−i . ... ... an,1 . . . an,n (3) 61 62 63 is Del Hawley by lines if and only ai,i + an+1−i,n+1−i = ai,n+1−i + an+1−i,i, ∀i ∈ Iw, w = n−1 2 if n is odd 64 or w = n 2 if n is even and Del Hawley by columns if and only if ai,i + an+1−i,n+1−i = ai,n+1−i + an+1−i,i. 65 Therefore, the three definitions are equivalent. Note also that if H is the set of all Del Hawley magic 66 squares, then ρi(H) = H. 67 68 Examples 1 69 a) Luo Shu’s magic square is of Del Hawley; 70 b) Dürer’s magic square is of Del Hawley; 71 c) The magic squares generated by the balanced levers method are of Del Hawley (de Oliveira Miranda, 72 2021, back cover); 73 d) Generalized Dürer magic squares are of Del Hawley (Miranda L., 2020b, pp. 13-15); 74 e) The magic squares of Miranda-Miranda methods 1 and 2 (Holger Danielsson, 2020) are not of Del Haw- 75 ley (Miranda L, 2020a, pp. 31-36). 76 77 Proposition 2. Given any square matrix A, we will denote Ca,b(A) the matrix that is obtained from A 78 by swapping its column of order a with its column of order b. And we will denote by La,b(A) the matrix that 79 is obtained from A by swapping its order lines a and b. So, if M = (ma,b)a,b∈In is a magic square of order 80 n and 1 ⩽ i < r ⩽ n 2 , we will have that Ln+1−r,n+1−i(Cn+1−r,n+1−i(Li,r(Ci,r(M)))) is a magic square. 81 Demonstration. Since swapping rows or columns in semi-magic squares do not change the sums of num- 82 bers in row or column, our attention must be focused on what occurs on the two diagonals. Li,r(Ci,r(M)) 83 is a semi-magic square that has the same main diagonal as M, except for the swap of mi,i with mr,r. 84 Cn+1−r,n+1−i(Li,r(Ci,r(M))) it is a semi-magic square that has the same secondary diagonal as M, ex- 85 2
- 3. Journal of Nepal Mathematical Society (JNMS), Vol. *, Issue * (20**); L. de O. Miranda, L.B.B.Miranda cept for the swap of mi,n+1−i with mr,n+1−r. And finally, Ln+1−r,n+1−i(Cn+1−r,n+1−i(Li,r(Ci,r(M)))) 86 is a semi-magic square that has the same main diagonal as M, except swaps of mi,i with mr,r and of 87 mn+1−r,n+1−r with mn+1−i,n+1−i. Also, this final semi-magic square has the same secondary diagonal as 88 M, except for swaps of mi,n+1−i with mr,n+1−r and of mn+1−i,i with mn+1−r,r. Therefore, it will be magic 89 square. 90 91 Example 2. n = 6, i = 2, r = 3. 92 93 4 30 8 31 3 35 36 5 28 9 32 1 29 34 33 2 7 6 13 12 17 22 21 26 18 14 10 27 23 19 11 16 15 20 25 24 −C2,3 → 4 8 30 31 3 35 36 28 5 9 32 1 29 33 34 2 7 6 13 17 12 22 21 26 18 10 14 27 23 19 11 15 16 20 25 24 −L2,3 → 4 8 30 31 3 35 29 33 34 2 7 6 36 28 5 9 32 1 13 17 12 22 21 26 18 10 14 27 23 19 11 15 16 20 25 24 − 94 C4,5 → 4 8 30 3 31 35 29 33 34 7 2 6 36 28 5 32 9 1 13 17 12 21 22 26 18 10 14 23 27 19 11 15 16 25 20 24 − L4,5 → 4 8 30 3 31 35 29 33 34 7 2 6 36 28 5 32 9 1 18 10 14 23 27 19 13 17 12 21 22 26 11 15 16 25 20 24 (4) 95 96 Observation 3. Any permutation of the elements of the set m1,1, m2,2, m3,3, ..., mn 2 , n 2 can be obtained 97 by swapping pairs of these elements. Therefore, we can make as many different magic squares as there are 98 elements in this set. In other words, we can do n 2 ! magic squares if n is even and n−1 2 ! if n is odd. In 99 the case n 2 ≤ r i ≤ n we can also easily establish new magic squares and the proof is done in a similar 100 way, replacing M with the magic square obtained by reflecting M in relation to the secondary diagonal. 101 3 Conclusion 102 Del Hawley’s classification of magic squares develops, in addition to the teaching of Mathematics, also the 103 theory of magic squares. In fact, very important magic squares like that of Luo Shu, those generated by 104 the balanced lever and those of generalized Dürer, are by Del Hawley. These types of magic squares will 105 become more prominent, also because they do not depend on orders. We find it notable that Del Hawley’s 106 definition of magic squares is linked to the formula Pr k=0 r k = 2r , one of the most intriguing in teaching 107 combinatory in the age group from 14 to 18 years old. Proposition 2, of a very generic nature, in conjunction 108 with Observation 3, points to the construction of many magic squares for all orders, that is, (n 2 )! for order 109 n. 110 References 111 [1] Del Hawley. (Published 1998, revised 2022). Magic Squares II. Available on 112 nrich.maths.org/1338/1338. Access on 11/25/2023. 113 [2] de Oliveira Miranda, L; Barbosa Bacelar Miranda, L e de Oliveira Miranda, O. (2021). Pon- 114 deração Consensual por Arbitragem nas Colisões de Princı́pios na Jurisprudência de Alexy: Teorias 115 Matemáticas e Jusfilosóficas para Evitar o Inferno Eterno – Belo Horizonte, Editora Dialética. ISBN 116 978-65-5956-002-8. Doi doi.org/10.48021/978-65-5956-002-8. 117 [3] de Oliveira Miranda, L; Barbosa Bacelar Miranda, L e de Oliveira Miranda, O. (2023). Del Haw- 118 ley’s Magic Squares. Available on academia.edu/109968072/DelHawleysM agicSquares. Access on 119 02/15/2023. 120 [4] Holger Danielsson, 2020, Magic Squares. Available on https://magic-squares.info/index.html. Access 121 on 02/15/2023. 122 3
- 4. Construction of Magic Squares by Swapping Rows and Columns [5] Miranda L. de O. and Miranda L. B. B., 2020a, Lohans’ Magic Squares and the Gaussian Elim- 123 ination Method, JNMS, 3(1), 31-36. DOI: https://doi.org/10.3126/jnms.v3i1.33001. Available on 124 https://www.nepjol.info/index.php/jnms/article/view/33001. Access on 02/15/2023. 125 [6] Miranda L. de O. and Miranda L. B. B., 2020b, Generalization of Dürer’s 126 Magic Square and New Methods for Doubly Even Magic Squares, JNMS, Vol. 127 3, Nr. 2, pp.13-15. DOI: https://doi.org/10.3126/jnms.v3i2.33955. Available on 128 https://www.nepjol.info/index.php/jnms/article/view/33955. Access on 02/15/2023. 129 [7] Secretaria de Educação. Matemática, 6° ano Material do Professor, Versão Preliminar. Disponı́vel 130 em www.santos.sp.gov.br/static/fileswww/conteudo/SEDUC/EducaSatos/efprmat06vol1 − 131 pt12021versaopreliminar.pdf. Acesso em 25 Nov. 2023. 132 4