# Determinant of a 3x3 Magic Square

Hello guys. This is my first question with mathOverflow so I hope my etiquette is up to par here.

My question is regarding a 3x3 magic square constructed using the la Loubere method (see la Loubere method)

Using the method, I have constructed a magic square and several semimagic squares (where one or both of the diagonals do not add up to a magic sum) with a program on written on my graphing calculator. After playing around with the program, I was shocked that the determinants of these 3x3 magic squares are all the same (specifically -360). Why is this so? (I am still an undergraduate so please go easy on the math :] )

-
I think that this question is more suitable for math.stackexchange.com . – Tsuyoshi Ito Aug 29 '10 at 15:58
The determinant can be 360 instead of −360. These are the only values because every 3×3 magic square can be obtained from a single 3×3 magic square by exchanging the first and the last columns (which negates the determinant), transposing (which does not change the determinant), or combinations of them. – Tsuyoshi Ito Aug 29 '10 at 16:04

I don't have an explanation, but here is an outline of a proof (I've checked all the details myself, but it's laborious to write up correctly) that what you claim to happen actually does happen.

Result: Let $M$ be a 3x3 integer matrix whose columns, rows, diagonal, and anti-diagonal each total 15. The following are equivalent:

1. The entries of $M$ are distinct and positive;
2. The determinant of $M$ is $\pm 360$;
3. Calling $h,i$ the (3,2) and (3,3) entries, $$(h,i)\in \{(1,6), (1,8), (3,4), (3,8), (7,2), (7,6), (9,2), (9,4)\}.$$

The proof is just writing down the equations for the sums, rows, etc., to be 15 and solving, and then writing down the formula for the determinant and simplifying (it turns out $det = 45(h-5)(h+2i-15)$) and solving the resulting diophantine equation.

The explanation may well be just that there aren't very many 3x3 magic squares (basically, it looks like there's just one that we rotate and flip to get eight). For 4x4, the solution space will be 7d instead of 2d, and that is a lot of extra freedom. If you find a simply-described structure in the determinants of those, I'd be surprised.

-
The OEIS (oeis.org/classic/A006052) says that there's one 3-by-3 magic square using the numbers 1 to 9, and 880 4-by-4s using the numbers 1 to 16. I assume that these are up to rotation and reflection, although there are other semi-obvious symmetries, like replacing k by (n^2+1)-k in an n-by-n magic square. – Michael Lugo Aug 29 '10 at 18:31
Someone has done the work for the 4-by-4 case. At mathpages.com/home/kmath310.htm, it's said that most 4-by-4 magic squares (5120 out of 7040) have determinant zero, and there are 22 other determinants which occur. – Michael Lugo Aug 29 '10 at 18:34
Thank you. Your outline does explain the 3x3 magic square but im still unsure about the 3x3 semi-magic squares (where the diagonals do not have equal sums). Doesnt this give the semi-magic squares a lot more freedom? – inutard Sep 17 '10 at 21:35

Kevin has done the magic squares; I'll do the semi-magics. So the rules are, we're using the 9 digits, once each, and all the row sums and all the column sums are equal. Note that this common sum must be 15. Now the only ways to use 1 and get 15 are $1+6+8$ and $1+5+9$. Since exchanging rows doesn't affect the (absolute value of) the determinant, and exchanging columns doesn't, either, and taking the transpose doesn't, and since further these operations don't affect semi-magicity, we may assume the matrix looks like this: $$\pmatrix{1&6&8\cr5&&\cr9&&\cr}$$ Now the only ways to use 9 are $1+5+9$, which we've already used, and $2+4+9$, so the matrix must look like $$\pmatrix{1&6&8\cr5&&\cr9&2&4\cr}\qquad{\rm or}\qquad\pmatrix{1&6&8\cr5&&\cr9&4&2\cr}$$ The first matrix fills out uniquely to $$\pmatrix{1&6&8\cr5&7&3\cr9&2&4\cr}$$ while the second one can't be completed. So, up to transpose, row swaps, and column swaps, there is only one order 3 semi-magic square, hence, only one determinant (up to sign).

-