IntegerSolution HockeyStickFormula Intermediate

Problem - 4425

How many $3\times 3$ matrices of non-negative integers are there such that the sum of every row and every column equals $n$?


Let the matrix be $$\begin{bmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{bmatrix}$$

First, let's consider the top two rows. There are $\binom{n+2}{2}$ solutions each to the following two equations $$a_1 + b_1 + c_1 = n\quad\text{and}\quad a_2 + b_2 + c_2 = n$$

Because the sum of each column is $n$, therefore fixing the top two rows will determine the third row. However, we need to exclude those cases where the third row contains negative elements.

Without loss of generality, let's assume $a_3 < 0$. This means that $$a_1+a_2 = n-a_3 \ge n_1$$

Then $$b_1 + c_1 + b_2 + c_2 = 2n - (a_1+a_2)\le n-1$$

which implies both $b_3$ and $c_3$ will have to be positive. So there is at most one negative element in the third row. The number of such cases equal to the non-negative integer solutions to $$b_1+c_1+b_2+c_2 = 2n -(a_1+a_2)=n+a_3$$

where $-n\le a_3 \le -1$ which equals $$\sum_{a_3=-n}^{-1}\binom{n+a_3+3}{3}=\binom{n+3}{4}$$

There are three cases of which element in the third row can be negative. Therefore, the final answer is $$\boxed{\binom{n+2}{2}^2 - 3\binom{n+3}{4}}$$


report an error