# Magic square matrices

A magic square is a square which allow non-negative integers entries in which all row sums and columns sums are equal. Let $$H_3(r)$$ denotes number of magic squares of size $$3*3$$ in which each row and column have sum equals $$r$$. Prove that $$H_3(r) =\binom{r+4}{4}+\binom{r+3}{4}+\binom{r+2}{4}$$ where $$H_3(r)$$ is the number of $$3*3$$ magic squares of line sum $$r$$.

I try to find out the relations between all the $$\left[ \begin{array}\\ a&b&c\\ d&e&f\\ g&h&i\\ \end{array} \right]$$ variables. I thought if I manage to built a relation between all the variables so that the values of all variables depend upon any one or two independent variables. But I fail to built such relations among variables.

I asked this question to all my faculty teachers and school teacher, but no answer come up.

If the question is worth, please solve it.

• @MorganRodgers Yes sir I tried it, but the equations formed are dependent on one another. – Parker May 11 at 19:19
• Up to what I see, there are $5$ conditions. [1-4] $\max(a+b, d+e, a+d, b+e ) \le r$ for $c,f,g,h \ge 0$ and [5] $a+b+d+e \ge r$ for $i \ge 0$. – achille hui May 11 at 19:27
• Usually, the diagonals are also of the same sum in magic squares - I suppose here that's not the case? – vrugtehagel May 11 at 19:58
• @vrugtehagel If you force the diagonals to also sum to $r$ then the formula will not give the right count. – Morgan Rodgers May 11 at 20:08
• Anyhow, this equation counting the "magic squares" (missing the usual condition that diagonals also sum to $r$) seems to be correct, but I don't see an easy insight for giving a combinatorial proof. You probably want to interpret each of the three binomial coefficients as "counting" the number of squares of a particular form. – Morgan Rodgers May 12 at 1:03