# How to prove that a $3 \times 3$ Magic Square must have $5$ in its middle cell?

A Magic Square of order $n$ is an arrangement of $n^2$ numbers, usually distinct integers, in a square, such that the $n$ numbers in all rows, all columns, and both diagonals sum to the same constant.

How to prove that a normal $3\times 3$ magic square must have $5$ in its middle cell?

I have tried taking $a,b,c,d,e,f,g,h,i$ and solving equations to calculate $e$ but there are so many equations that I could not manage to solve them.

• It's also worth pointing out that this question only applies to normal magic squares (i.e. 1...n). The general magic square might not have a 5 in it at all, let alone in the center. Jan 13, 2014 at 14:46
• @ArchismanPanigrahi I don´t think so. This comment will self destruct. Jan 13, 2014 at 15:43
• That is wrong. Add 1 to each number, then you have still a magic square but the value of the middle cell also increased by one Apr 22 at 7:36

The row, column, diagonal sum must be $15$, e.g. because three disjoint rows must add up to $1+\ldots +9=45$. The sum of all four lines through the middle is therefore $60$ and is also $1+\ldots +9=45$ plus three times the middle number.

• How so for the diagonal sums? Jan 13, 2014 at 10:31
• @alexis: The diagonal sums have to be equal to the row sums, which have to be equal to 15. Jan 13, 2014 at 11:03
• Oh, by the problem statement you mean... got it. Jan 13, 2014 at 11:06

A normal magic square of order $3$ can be represented by a $3 \times 3$ matrix

$$\begin{bmatrix} x_{11} & x_{12} & x_{13}\\ x_{21} & x_{22} & x_{23}\\ x_{31} & x_{32} & x_{33}\end{bmatrix}$$

where $x_{ij} \in \{1, 2,\dots, 9\}$. Since $1 + 2 + \dots + 9 = 45$, the sum of the elements in each column, row and diagonal must be $15$, as mentioned in the other answers. Vectorizing the matrix, these $8$ equality constraints can be written in matrix form as follows

$$\begin{bmatrix} 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 1 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 1& 1 & 1\\ 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0\\ 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0\\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1\\ 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0\end{bmatrix} \begin{bmatrix} x_{11}\\ x_{21}\\ x_{31}\\ x_{12}\\ x_{22}\\ x_{32}\\ x_{13}\\ x_{23}\\ x_{33}\end{bmatrix} = \begin{bmatrix} 15\\ 15\\ 15\\ 15\\ 15\\ 15\\ 15\\ 15\end{bmatrix}$$

Note that each row of the matrix above has $3$ ones and $6$ zeros. We can guess a particular solution by visual inspection of the matrix. This particular solution is $(5,5,\dots,5)$, the $9$-dimensional vector whose nine entries are all equal to $5$. To find a homogeneous solution, we compute the RREF

$$\begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & -1 & -1\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & -1 & -2\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 2\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{bmatrix}$$

Thus, the general solution is of the form

$$\begin{bmatrix} 5\\ 5\\ 5\\ 5\\ 5\\ 5\\ 5\\ 5\\ 5\end{bmatrix} + \begin{bmatrix} 0 & -1\\ -1 & 0\\ 1 & 1\\ 1 & 2\\ 0 & 0\\ -1 & -2\\ -1 & -1\\ 1 & 0\\ 0 & 1\end{bmatrix} \eta$$

where $\eta \in \mathbb{R}^2$. Un-vectorizing, we obtain the solution set

$$\left\{ \begin{bmatrix} 5 & 5 & 5\\ 5 & 5 & 5\\ 5 & 5 & 5\end{bmatrix} + \eta_1 \begin{bmatrix} 0 & 1 & -1\\ -1 & 0 & 1\\ 1 & -1 & 0\end{bmatrix} + \eta_2 \begin{bmatrix} -1 & 2 & -1\\ 0 & 0 & 0\\ 1 & -2 & 1\end{bmatrix} : (\eta_1, \eta_2) \in \mathbb{R}^2 \right\}$$

which is a $2$-dimensional affine matrix space in $\mathbb{R}^{3 \times 3}$. For example, the magic square illustrated in the question can be decomposed as follows

$$\begin{bmatrix} 2 & 9 & 4\\ 7 & 5 & 3\\ 6 & 1 & 8\end{bmatrix} = \begin{bmatrix} 5 & 5 & 5\\ 5 & 5 & 5\\ 5 & 5 & 5\end{bmatrix} - 2 \begin{bmatrix} 0 & 1 & -1\\ -1 & 0 & 1\\ 1 & -1 & 0\end{bmatrix} + 3 \begin{bmatrix} -1 & 2 & -1\\ 0 & 0 & 0\\ 1 & -2 & 1\end{bmatrix}$$

Note that the sum of the elements in each column, row and diagonal of each of the two basis matrices is equal to $0$. Note also that the $(2,2)$-th entry of each of the two basis matrices is $0$. Hence, no matter what parameters $\eta_1, \eta_2$ we choose, the $(2,2)$-th entry of the normal magic square of order $3$ will be equal to $5$.

The common sum must be $15$, because the sum of numbers from $1$ to $9$ is $45$. How can we write $15$ as sum of three distinct numbers between $1$ and $9$ (included)?

\begin{gather} 1+5+9 \\ 1+6+8 \\ 2+4+9 \\ 2+5+8 \\ 2+6+7 \\ 3+5+7 \\ 3+4+8 \\ 4+5+6 \end{gather}

We have just eight ways and we can try accommodating them in the square. The central place belongs to one row, one column and the two diagonals, so the number we put in it must appear four times in the above sums: the only one is $5$.

Similarly, in the four corners we have to place numbers that appear three times, that is: $2$, $4$, $6$ and $8$.

This also shows that basically only one $3\times3$ magic square is possible, up to symmetries of the square.

How to compose the magic square? First note how many rows, columns and diagonals each cell belongs to:

Now we know that $5$ must be in the center; choose arbitrarily an even number, say $2$ and place it in a corner. It could go in any corner, let's choose the upper left one; in the opposite corner we have to write $8$:

Now $4$ must go in one of the other corners and $6$ in the opposite one:

At this point, the other cells can be filled in a unique way:

We have four choices for placing $2$ and, for any choice we can choose two places for $4$. In total we have eight magic squares, but just one if we consider two of them identical after applying a symmetry of the square (there are eight of them).

If we subtract $5$ to each cell, we can better see the symmetry:

Let:

$$\begin{array}{|c|c|c|} \hline A & B & C \\\hline D & E & F \\\hline G & H & I\\\hline \end{array}$$ be a magic square. We have the equations:

\begin{align} A+E+I&=15 \tag{1}\\ B+E+H&=15 \tag{2}\\ C+E+G&=15 \tag{3}\\ D+E+F&=15 \tag{4}\\ \end{align} Now, if we sum the equations $(1),(2),(3),(4)$, we get that: $$A+B+C+D+4E+F+G+H+I=60 \tag{5}$$ The following are more conditions from it being a magic square: \begin{align} A+B+C&=15 \tag{6}\\ D+E+F&=15 \tag{7}\\ G+H+I&=15 \tag{8} \end{align} Now subtitute equations (6), (7) and (8) into equation (5) to get that: $$45+3E=60$$ From this, it follows that: $$E=5$$

• Why the repeat, 2+ years later?
– Did
May 17, 2016 at 18:59
• idk i worked it out for my math homework and was bored so i typed it out
– TDMB
May 18, 2016 at 0:51

Let \begin{array}{|c|c|c|} \hline a & b & c\\ \hline d & e & f \\ \hline g & h & i \\ \hline \end{array}

be a magic square of order three with sum row, column, and diagonal sums equal to S. then

\begin{align} a+e+i &= S\\ b+e+h &= S\\ c+e+g &= S\\ d+e+f &= S \\ \hline (a+b+c)+(d+e+f)+(g+h+i) + 3e &= 4S\\ 3S + 3e = 4S\\ e = \dfrac 13 S \end{align}

So, if the top row is $a,b,c$, then $e = \dfrac{a+b+c}{3}$.

We end up with

\begin{array}{|c|c|c|} \hline a & b & c\\ \hline \dfrac{-2a+b+4c}{3} & \dfrac{a+b+c}{3} & \dfrac{4a+b-2c}{3} \\ \hline \dfrac{2a+2b-c}{3} & \dfrac{2a-b+2c}{3} & \dfrac{-a+2b+2c}{3} \\ \hline \end{array}

This is OK, but it would be nice to have a representation that doesn't use fractions. This works.

\begin{array}{|c|c|c|} \hline a & b & -a-b+3e\\ \hline -2a-b+4e & e & 2a+b-e \\ \hline a+b-e & -b+2e & -a+2e \\ \hline \end{array}

There are other representations.

## For programmers

Every order-3 magic square can be rotated and reflected so that the smallest element is in the center of the left column and the next-smallest element in the bottom of the right column. Having made this transformation, and ordered the elements from 1 to 9, there are two possible outcomes for the 'arrays of orders'.

$$\text{Type 1: } \; \begin{bmatrix} 8 & 3 & 4\\ 1 & 5 & 9 \\ 6 & 7 & 2 \\ \end{bmatrix} \qquad \text{Type 0: } \; \begin{bmatrix} 8 & 4 & 3\\ 1 & 5 & 9 \\ 7 & 6 & 2 \\ \end{bmatrix}$$

Note that the first array of orders is in fact also a magic square while the second isn't. An example of a magic square of type $0$ is $$\begin{bmatrix} 8 & 4 & 3\\ 0 & 5 & 10 \\ 7 & 6 & 2 \\ \end{bmatrix}$$

Using $\quad \begin{bmatrix} a & b & c\\ d & e & f \\ g & h & i \\ \end{bmatrix} \quad$ to reference the elements of a magic square, it would be tempting, noticing the locations of the elements of orders $1,2$ and $3$ to hope that elements $\{d,i,b\}$ or elements $\{d,i,c\}$ could be used to generate the other six elements of the magic square. Unfortunately, elements $\{d,i,b\}$ do not since, for all magic squares $b+d = 2i$. But, choosing elements $\{d,i,c\}$, we get \begin{array}{|c|c|c|} \hline 2c-2d+i & -d+2i & c\\ \hline d & c-d+i & 2c-3d+2i \\ \hline c-2d+2i & 2c-d & i \\ \hline \end{array}

So, to generate positive integer magic squares with distinct elements, choose integer $0 < d < i < c$, with $2i-d > 0$ and use the above formula to fill in the rest.

Once 15 is established as the magic number the easiest way to see this is to reason as follows. If a row/column/diagonal is 8,6,1, we say that 8 is opposite 1.

If a number smaller than five is in the centre consider the number opposite the remaining smallest number. It will have to be greater than 10.

Similarly a number greater than five will not do.

The proof are in the rules (or conditions) about how a magic square is built...

In this case a 3x3 grid, you need a sequence of nine integer and positive numbers to make a magic square. You must order that numbers by size... the number that goes in the center of the grid is always the middle number of that group you ordered.

For example, you have this group of nine numbers to make a $3\times 3$ MS: $15, 33, 12, 45, 18, 48, 27, 30$ and $42$. After you ordered them by size: $12,15,18,27,30,33,42,45,48$.

The one in the middle of this ordered group of nine numbers is $30$.

30 will be the number that goes to the center of the $3\times 3$ grid.

No need of any formulas, just follow the MS (Magic Square) rules.