# the vector space of Magic Squares

Can anyone offer help? I have no clue how to do this problem.

Magical squares are 3 by 3 matrices with the following properties: the sum of all numbers in each row, and in each column, and in each diagonal is equal. This number is called the magical number.

(i)Prove that the set of magical squares forms a vector space with the usual matrix addition and scalar-matrix product.

(ii) Find a basis of the vector space of magical squares and determine its dimension.

• Do you know how many $3\times 3$ magic square exist? – user217174 Mar 11 '16 at 6:06
• Sorry what do you mean by that? – stephenbutters Mar 11 '16 at 6:08
• You need to specify what sort of "numbers" the squares contain. Magical squares are more usually thought of as containing integers, and in that case they don't form a vector space. – joriki Mar 11 '16 at 6:10
• The usual way to prove some set $W$ is a vector space is to prove that it is a subspace of some set $V4 that you already know to be a vector space. So, it there any set containing the one you're asked about that you know is a vector space? And do you know how to prove something is a subspace? – Gerry Myerson Mar 11 '16 at 6:27 ## 4 Answers The given relations correspond to a homogeneous system of linear equations for the$9$entries (ordered left to right, top to bottom) and the negated sum, with the following matrix: $$\pmatrix{ 1&1&1&0&0&0&0&0&0&1\\ 0&0&0&1&1&1&0&0&0&1\\ 0&0&0&0&0&0&1&1&1&1\\ 1&0&0&1&0&0&1&0&0&1\\ 0&1&0&0&1&0&0&1&0&1\\ 0&0&1&0&0&1&0&0&1&1\\ 1&0&0&0&1&0&0&0&1&1\\ 0&0&1&0&1&0&1&0&0&1 }$$ This matrix has rank$7$over the real numbers (as you can establish by hand or using Wolfram|Alpha), so the solution set is a vector space of dimension$10-7=3$. If the squares are meant to contain real numbers, their addition and scalar multiplication correspond to those of these solution vectors, so the squares also form such a vector space. • So, there are$8$equations for$3$rows,$3$columns and$2$diagonals if we have: $$\begin{bmatrix}x_1&x_2&x_3\\x_4&x_5&x_6\\x_7&x_8&x_9\end{bmatrix}\;\;?$$ – ms._VerkhovtsevaKatya Jan 28 at 15:32 • @VerkhovtsevaKatya: Yes -- though it doesn't matter which direction you take as horizontal and which as vertical. – joriki Jan 28 at 15:44 Assuming the entries of your magic square belong to some field of characteristic zero to avoid complications, the given relations tell us that a generic magic square looks like $$\begin{pmatrix}a & 2a -4b +3c & b \\ c & a -b + c & 2a - 2b + c \\ 2a - 3b + 2c & 2b-c &a-2b+2c\end{pmatrix}$$ with magic number$3a -3b+3c$. Thus your space has dimension$3$. (Verifying that the set of magic squares really forms a subspace of the space of$3 \times 3$matrices with coefficients in the chosen field is routine; alternatively, this argument shows that the set of all magic squares is precisely the span of three specific magic squares, namely the ones obtained by setting exactly one of$a,b,c$equal to$1$and the rest to zero.) • Why do we know that if we choose different 'starting fields'$a,b$and$c$, that we could also find such a matrix and therefore a basis? – Viktor Glombik Jan 6 '19 at 23:20 • @ViktorGlombik Could you rephrase? I don't understand your question at all. – Alex Provost Jan 7 '19 at 17:56 • One can show, that if you chose three numbers, all other numbers are determined by those three numbers. In you answer, you choose those numbers (I called them the ''starting squares'')$a,b$and$c$to be in certain positions. But how do we know that we can find such a representation for every triple of ''starting squares''? – Viktor Glombik Jan 7 '19 at 20:38 (i) The map "compute the sum of elements in row$i$" (or in column$j$, or in one of the diagonal) is a linear map from the vector space of$3\times 3\$ matrices to the base field, hence so is each difference of such maps. The set of magic squares is the intersection of the kernels of these difference maps, hence a subspace.

Here's an easy way to do this for general $$n$$: given a magic number $$S$$, consider the topleft $$(n-1)$$ by $$(n-1)$$ submatrix of the square. Given these values, one can fill in the margins by subtracting rows and columns of the submatrix from $$S$$, and the bottom-right entry by subtracting the diagonal of the submatrix from $$S$$.

The only equations remaining to satisfy are: (1) the sum of each new margin equals $$S$$ and (2) the sum of the non-principal diagonal equals $$S$$. The condition (1) is the same for each margin (because the last column can be determined given all the rows and all the other columns). So the conditions are, where $$1\le i,j\le n$$ and $$1\lt k\lt n$$:

$$\sum_{i}a_{ii}=(n-1)S-\sum_{ij}a_{ij}$$

$$\sum_k a_{k(n-k+1)}+\sum_j a_{1j}+\sum_i a_{i1}=S$$

These can be checked to be linearly independent for $$n>2$$. Allowing $$S$$ to be free, the dimension of our space is therefore $$(n-1)^2-2+1$$, which equals:

$$n^2-2n$$

Which indeed gives 3 in the case $$n=3$$ Meanwhile, for $$n=1$$ and $$n=2$$, the dimension is clearly 1.