[Math] Showing a set of matrices is a basis of all 3×3 magic squares

linear algebramagic squarematricesvector-spaces

I am trying to show that
$$\left\{\begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix},\begin{bmatrix} 0 & 1 & −1 \\ −1 & 0 & 1 \\ 1 & −1 & 0 \end{bmatrix},\begin{bmatrix} −1 & 1 & 0 \\ 1 & 0 & −1 \\ 0 & −1 & 1 \end{bmatrix}\right\}$$
is a basis for the vector space of
all 3×3 magic squares (3×3 matrices such that the sum of each row and column and diagonal is equal).

Is there an easy way to do this?

Best Answer

This is really an extension to my comment above. If you denote the entries of the matrix by $a,b,c,d,e,f,g,h,i$, then your condition that all rows and columns and diagonals have the same sum corresponds to the solutions to the matrix equation:

$$ \left[ \begin{array}{ccccccccc|c} 1 & 1 & 1 & 0 & 0 &0 &0 &0 &0 & k\\ 0 & 0 & 0 & 1 & 1 &1 & 0 & 0 &0 & k \\ 0 & 0 & 0 & 0& 0 &0 &1 &1 & 1 & k\\ 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0&k \\ 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 &k\\ 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1&k \\ 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 &k\\ 0 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 0 &k\\ \end{array} \right] $$

Where the first three rows represent the rows, the next three rows represent the columns, and the last two rows represent the diagonals. The $k$ represent any old fixed constant that you want the sums to be, all the same because this square is magic.

I'll work on reducing this matrix for this answer, but I suspect a TI84 or some other calculator can do this faster than I can.

After working this out on pen and paper and doing it improperly (of course, you can never get them right the first time), I went to this site here, and entered the matrix with $k = 1$. It doesn't matter what $k$ is since this variable is going to be free no matter what, and you can just scale that column.

The output given is this: $$ \left[ \begin{array}{ccccccccc|c} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 2k/3\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 2k/3 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 &-1 &-1 & -k/3\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 &-1 &-2 & -2k/3 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & k/3\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & 2 & 4k/3 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & k\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ \end{array} \right] $$

This matrix has $2$ free variables, and $k$ is also free like we said above, so this is the $3$ dimensional solution set we wanted. Since you have found $3$ such matrixes that are linearly independent and have the desired property, they must span the set of all magic squares.

Related Question