# Find all $3 \times 3$ magic square matrices $M$ such that $M^2$ is also magic

A magic square matrix $$M$$ is a square matrix with real entries such that the sum of the entries in each column, each row, and each main diagonal is the same.

The problem is to characterize all $$3 \times 3$$ magic square matrices $$M$$ such that $$M^2$$ is also a magic square matrix.

Supposedly, there is an elegant way to do this besides writing out variables and bashing out the multiplication, but I haven't yet found such a solution.

• I am not sure if it will work but maybe if you check if there is a relation between magic matrices and their eigenvalue decomposition and that way you could easily find your solution Apr 8, 2017 at 18:37
• Real entries?!? Jul 14, 2020 at 12:43

It can be shown that a generic $$3\times 3$$ magic matrix is of the form: $$\left[\begin{array}{ccc}a&b&c\\d&e&f\\g&h&i\end{array}\right]=\left[\begin{array}{ccc}e+h-c&2e-h&c\\2c-h&e&2e-2c+h\\2e-c&h&e-h+c\end{array}\right].$$ Therefore, the square of a magic matrix can be expressed as: $$\left[ \begin{array}{ccc} e^2+2 h^2+4 c e-4ch & 4 e^2-h^2-2 c e+2 c h & 4 e^2-h^2-2 c e+2 c h \\ 4 e^2-h^2-2 c e+2 c h & e^2+2 h^2+4 c e-4ch & 4 e^2-h^2-2 c e+2 c h \\ 4 e^2-h^2-2 c e+2 c h & 4 e^2-h^2-2 c e+2 c h & e^2+2 h^2+4 c e-4ch \\ \end{array} \right].$$ We want this to be of the upper form, which gives only one equation: $$(2 c - e - h) (e - h)=0.$$ Thus, $$h=e$$ or $$h=2c-e$$ are our solutions. The requested matrices are: $$\left[\begin{array}{ccc}2e-c&e&c\\2c-e&e&3e-2c\\2e-c&e&c\end{array}\right],\left[\begin{array}{ccc}c&3e-2c&c\\e&e&e\\2e-c&2c-e&2e-c\end{array}\right],$$ for any $$c,e\in\mathbb{R}$$.

• These are identical up to rotation, aren't they? +1 though. Apr 19 at 16:33

First we look at the properties of the matrix and its eigenvalues. Now since the matrix $M$ has rows that add up to the same number, lets say $s$, then we know that $$\begin{pmatrix} 1\\1\\1 \end{pmatrix}$$ is an eigenvector with eigenvalue $s$.

If we take the transpose of the matrix $M^T$ we can then apply the same principle and find that $s$ is a repeated eigenvalue.

Now for the third eigenvalue we notice that the sum of the trace is equal to the sum of the eigenvalues. However we know the sum of the trace to be $s$ so doing this would mean that we get the thrid eigenvalue to be $-s$.

Now by eigenvalue decomposition we know that $M^2 = S\Lambda^2S^{-1}$ and if it were magic its sums, $s_2$ its eigenvalues would be $s_2$ repeated twice and $-s_2$. However, notice how $\Lambda^2$ will have only positive entries. Therefore there does not exist a magic square $M$ such that $M^2$ is also magic.

• If all eigenvalues of $M$ are identical, then both $M$ and $M^2$ are magic. While I think that your proof can be modified to work, as it stands it is wrong. Apr 8, 2017 at 19:09
• Indeed it's wrong because I found the class of magic squares which work, and its nonempty. Apr 8, 2017 at 19:11
• Slight modification. You know the sum $\lambda_1 = s$ is an eigenvalue of $M$. However, since $\operatorname{Tr}(M) = \lambda_1 + \lambda_2 + \lambda_3 = s$, we know $\lambda_2 = -\lambda_3$. For both $M$ and $M^2$ to satisfy this property, we must have $\lambda_2 = \lambda_3 = 0$. So the extra property we are looking for is that $M$ is singular. I'm conjecturing the only singular magic square $3\times 3$ matrices are those with all elements equal. Jul 14, 2020 at 14:06
• Your eigenvalue-consideration is wrong. Use $S$ as magic Square, $S=M \cdot D \cdot W$ where $W=M^{-1}$ for convenience. Then $$\small \begin{array} {rrr} &42025 & 277729 & 222121 \\ S=& 360721 & 180625 & 529 \\ & 139129 & 83521 & 319225 \\ \hline &1 & 1.00000 & 1.00000 \\ M=& 1 & -0.880350 & 7.35769 \\ &1 & -0.119650 & -8.35769 \\ \hline D=& 541875 & -2.29050E5 & 2.29050E5 \\ \hline & 0.333333 & 0.333333 & 0.333333 \\ W=& 0.635887 & -0.378637 & -0.257249 \\ & 0.0307800 & 0.0453041 & -0.0760840 \\\hline \end{array}$$ Mar 24 at 16:14