0

I am a student interested in numbers. One day I was playing with magic squares (the sum of the numbers in each row, each column and each diagonal is the same) when I tried to find a general form of a $3 \times 3$ magic square.

At first I found that the simplest form was like

$$ \begin{array}{|c|c|c|} \hline \phantom{X} 1 \phantom{X} & \phantom{X} 8 \phantom{X} & \phantom{X} 3 \phantom{X} \\ \hline \phantom{X} 6 \phantom{X} & \phantom{X} 4 \phantom{X} & \phantom{X} 2 \phantom{X} \\ \hline \phantom{X} 5 \phantom{X} & \phantom{X} 0 \phantom{X} & \phantom{X} 7 \phantom{X} \\ \hline \end{array} $$

Then experimenting further, I found some properties:

  1. Adding any natural number to all of the elements gives a new magic square.

  2. Multiplying all elements with a natural number also gives a new magic square.

  3. Rotating a magic square still gives a magic square (perhaps it's too obvious to mention).

  4. A combination of the above mentioned methods still gives a magic square.

Thus the 3×3 magic square has the general form

$$ \begin{array}{|c|c|c|} \hline \phantom{X} k(n+1) \phantom{X} & \phantom{X} k(n+8) \phantom{X} & \phantom{X} k(n+3) \phantom{X} \\ \hline \phantom{X} k(n+6) \phantom{X} & \phantom{X} k(n+4) \phantom{X} & \phantom{X} k(n+2) \phantom{X} \\ \hline \phantom{X} k(n+5) \phantom{X} & \phantom{X} k(n+0) \phantom{X} & \phantom{X} k(n+7) \phantom{X} \\ \hline \end{array} $$

Where $n, k \in {\Bbb N}$. So, I was thinking, do all $m \times m$ (not just $3 \times 3$) have a simplest form like the first table and/or obey the $4$ rules? Or in other words, do they also have a general form like the second table?

Vikram
  • 103
  • 1
    Not all 3×3 magic squares have every element in a single arithmetic progression. So even with 3×3 it's not that simple. – Oscar Lanzi Mar 06 '25 at 15:46
  • 1
    As the squares get larger there are many patterns, even if you insist on using $1$ to $n^2$. – Ross Millikan Mar 06 '25 at 15:54
  • 1
    Of course, given one $m \times m$ magic square, you can add $n$ to each element and get another magic square. But there are lots of possible magic squares to start with: for $6 \times 6$ squares with elements $1$ to $6^2$, $17753889197660635632$ counted up to rotations and reflections, according to OEIS sequence A006052 – Robert Israel Mar 06 '25 at 16:17
  • The usual definition of magic square requires the diagonals have the same sum as rthe rows and columns. Your definition does not require this, but your example has this property. If you don't require this property, then you can get a new magic square from an old one by swapping any two rows, or any two columns. Whether you have the diagonal property or not, you can get a new square by applying any of the symmetries of a square; any rotation, or a flip in any axis of symmetry. Squares without the diagonal property are generally called semi-magic rather than magic. – Gerry Myerson Mar 08 '25 at 11:52
  • Up to the symmetries noted in my previous comment, there is only one magic square using the numbers one through nine, once each. You'll find that the sum of any two magic (or semi-magic) squares is magic (resp., semi-magic), provided you allow repeated entries. More generally, linear combinations of (semi-)magic squares are (semi-)magic. – Gerry Myerson Mar 08 '25 at 11:55
  • I'd recommend doing a search for "magic square" on this site, as there are probably already answers on this site to a lot of questions you may have. – Gerry Myerson Mar 08 '25 at 11:57
  • I'm not convinced that your "general form" accounts for all $3\times3$ magic squares, e.g., $$\matrix{5&0&7\cr6&4&2\cr1&8&3\cr}$$ – Gerry Myerson Mar 09 '25 at 08:39
  • If you limit the numbers in the range $[[1,n^2]]$, you have $n^2$ unknowns, and 2n+2 constraints. When $n=3$, number of constraints and number of unknowns is (almost) the same, so very few solutions. When $n=4$ or $n=5$... , number of unknownw grows very fast, and number of constraints grows slowly. So number of solutions increases. – Lourrran Mar 09 '25 at 09:38
  • @GerryMyerson Of course, sir. That is why I mentioned the properties. The 3rd property accounts for this. Your example is the 180° rotation of my 1st table. I had previously mentioned that all 3×3 magic squares have those properties so didn't think it was necessary to say the "general form" also has the 3rd property. Thanks tho. – Vikram Mar 09 '25 at 10:14
  • @Lourrran I am sorry but I didn't understand what you meant by "unknowns" and "constraints". Would you elaborate? – Vikram Mar 09 '25 at 10:16
  • I think I see the problem. When discussing the symmetries of a square, one usually reserves the word "rotation" for a rotation in the plane, clockwise or counterclockwise. What you are calling a rotation is usually called a "flip", it's a rotation out of the plane. Or it could be called a reflection. – Gerry Myerson Mar 09 '25 at 11:00
  • You have $n \times n$ cells, where you have to put a number, so you have $n \times n$ unknowns. and you have for each column , each row and each diagonal a relation (a constraint) : $x_{i,1} +x_{i,2} +x_{i,3} = 12$ for any $i$, $x_{1,j} +x_{2,j} +x_{3,j} = 12$ for any $j$, and same for both diagonals. So $3+3+2=8$ constraints when $n=3$. – Lourrran Mar 09 '25 at 12:15
  • 2
    @Lourrran, the constraints aren't all independent. If five of the six rows and columns add up to $12$, then the sixth one must also add up to $12$. So, really, seven constraints, not eight. – Gerry Myerson Mar 10 '25 at 01:39
  • @RodrigodeAzevedo thanks a lot. But isn't it too complicated if we want to apply it for any $n × n$ magic square in general? – Vikram Mar 10 '25 at 11:40
  • @Vikram If you fix $n$ and compute the parametrization, then increase $n$ by $1$, you might start to notice interesting patterns, which might lead to a conjecture. – Rodrigo de Azevedo Mar 10 '25 at 11:57
  • One parametrization that gives all $3\times3$ magic squares (but without any restrictions on the entries) is $$\matrix{e+b&e-a-2b&e+a+b\cr e+a&e&e-a\cr e-a-b&e+a+2b&e-b\cr}$$ This can be written as $eE+aA+bB$ with $E=\matrix{1&1&1\cr1&1&1\cr1&1&1\cr}$, $A=\matrix{0&-1&1\cr1&0&-1\cr-1&1&0\cr}$, $B=\matrix{1&-2&1\cr0&0&0\cr-1&2&-1\cr}$. – Gerry Myerson Mar 11 '25 at 05:53
  • 1
    @GerryMyerson another parametrization of $3\times3$ magic squares is at https://math.stackexchange.com/a/5034311/6460 – Henry Mar 14 '25 at 00:48
  • Parity arguments? – Roddy MacPhee Apr 01 '25 at 18:16

0 Answers0