TITLE: the vector space of Magic Squares
QUESTION [5 upvotes]: 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.

REPLY [2 votes]: 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.