How many possible determinants are there for a $3 \times 3$ matrix made of the numbers $1$ to $9$?

167 Views Asked by At

How many possible determinants are there for a $3 \times 3$ matrix made of the numbers $1$ to $9$? Each integer from $1$ to $9$ must appear exactly once in the matrix (so that the matrix could appear inside a Sudoku grid).

Clearly, a lower bound is $1$ (the matrices could theoretically all have the same determinant), while an upper bound is $\frac{9!}{2}$ (the matrices could theoretically all have different determinants unless one is the transpose of the other).

Do not use Excel to calculate the determinants. Excel will incorrectly think that the matrix $\begin{pmatrix} 1&2&3\\4&5&6\\7&8&9 \end{pmatrix}$ is invertible even though it is actually singular.

Since $\begin{pmatrix} 1&2&3\\4&5&6\\7&8&9 \end{pmatrix}$ is singular, permuting the rows and/or columns would still give singular matrices. This leads to $36$ such matrices, and taking the transposes would then double the count to $72$. So, one could improve the upper bound to $\frac{9!-72}{2}+1=\frac{9!}{2}-35$.

Also, even permutations of the rows or columns do not change the determinant, while odd permutations negate the determinant. Hence, applying a permutation of the rows and then a permutation of the columns with the same parity (even or odd) does not change the determinant. There are $3$ even permutations of the rows and another $3$ even permutations of the columns. Also, there are $3$ odd permutations of the rows and another $3$ odd permutations of the columns. So, the upper bound could be improved even further to $\frac{9!-72}{36}+1=\frac{9!}{36}-1$.

Other than that, I could not make the upper bound any better, nor the lower bound.

2

There are 2 best solutions below

0
On

Collating comments:

For a pen-and-paper approach, you could argue that since determinants of integer matrices must be integers, we can bound the possible results of determinants and this can give us an idea of how many unique determinants are possible.

The largest determinant is certainly less than $3\cdot 9\cdot 8\cdot 7=1512$ by ignoring subtractions and having every addition be maximal. You could probably argue as well that the largest determinant is less than $9\cdot 8\cdot 7 + 6\cdot 5\cdot 4 + 3\cdot 2\cdot 1=630$ with a more careful argument, again by ignoring the subtractions and trying to maximize the result of the additions.

This implies that the determinants all fall under the range $(-630,630)$ giving an upper bound of $1261$.

Even more careful fine tuning of this approach and taking the subtractions into account, you may even be able to make it all the way to finding $412$ is the maximum (and $-412$ the minimum) value for the determinant bringing the upper bound for the total down to $825$.

The true value I found via brute force and is

$777$

which is interesting as it implies that there are some determinants in that range which are not possible to achieve, but otherwise the vast majority are possible.

The code I used in javascript:

function permutator(inputArr) {
  var results = [];

  function permute(arr, memo) {
    var cur, memo = memo || [];

    for (var i = 0; i < arr.length; i++) {
      cur = arr.splice(i, 1);
      if (arr.length === 0) {
        results.push(memo.concat(cur));
      }
    permute(arr.slice(), memo.concat(cur));
  arr.splice(i, 0, cur[0]);
  }

  return results;
}

return permute(inputArr);
}

results = {};
permutator([1,2,3,4,5,6,7,8,9]).$each(function(p){results[p[0]*p[4]*p[8] + p[1]*p[5]*p[6]+p[2]*p[3]*p[7] - p[2]*p[4]*p[6] - p[0]*p[5]*p[7] - p[1]*p[3]*p[8]] = (results[p[0]*p[4]*p[8] + p[1]*p[5]*p[6]+p[2]*p[3]*p[7] - p[2]*p[4]*p[6] - p[0]*p[5]*p[7] - p[1]*p[3]*p[8]]+1)||1})
console.log(results)
console.log(Object.keys(results).length)

This shows the number of unique ways to achieve each outcome (each of which is of course a multiple of $36=3!^2$). You can choose also to instead insert the specific permutation in the loop into the results object to view examples of each determinant.

0
On

The following sage code confirms the answer of JMoravitz...

det_set = set()
for p in Permutations(8):
    if p(1) > p(2) or p(3) > p(6):    continue
    d = matrix(3, 3, [9] + list(p)).det()
    det_set.add(d)
    det_set.add(-d)

print(f'There are {len(det_set)} different determinant values.')

And the print gives:

There are 777 different determinant values.

I do not see any way to get the answer by using human methods. And since the question is not a structural one, there is no reason to do so. The answer is a dead end, so having it should be fine. The $777$ values are the zero value, together with $\frac 12(777-1)=388$ pairs of values $+d$ and $-d$. The maximal value is

sage: max(det_set)
412

and it turns out that all integers from $1$ to $323$ appear as a possible determinant. (The first natural number that cannot be realized is $324$, and the next missing natural numbers from the set are $329$, $355$, $357$, $358$, $362$, $364$, $365$, $367$, $373$, $375$, $378$... In fact, the list ends with the following numbers: $379$, $380$, $382$, $384$, $385$, $388$, $389$, $390$, $391$, $392$, $393$, $395$, $396$, $398$, $400$, $402$, $404$, $405$, $407$, $408$, $410$, $412$.)