Maximising determinant problem

HINT:

The product of eigenvalues are the determinant. The trace is the sum of eigenvalues. It may be reasonable to believe that a large eigenvalue sum increases the chance of a large eigenvalue product. If that is the case then 9,8,7 would be good candidates for diagonal elements. Then some symmetry argument could possibly be used for the remaining 6 positions.

This would reduce from having to try $9! = 362880$ to $6! = 720$ matrices.

SPOILER WARNING:

Using Matlab or Octave, we can with a short but obscure brute force script (don't worry it took maybe 5-10 seconds on my machine ) :

b = reshape(permute(perms(1:9),[3,2,1]),[3,3,362880]);

s=-1; for o_=1:size(b,3); if det(b(:,:,o_))>s; i_=o_; end; s = max(s,det(b(:,:,o_))); end;

b(:,:,i_)

Find that the matrix

$$\left[\begin{array}{rrr}7&1&5\\6&8&3\\2&4&9\end{array}\right]$$

Has a determinant $412$ which supposedly is the largest of the bunch. Of course as someone mentioned in the comments any combination of row or column permutations would give the same value so the important thing is that 7,8,9 don't share any row or column as we then could permute them into the diagonal.


Swapping rows and columns leaves the absolute value of the determinant unchanged, so we can assume that the middle cell contains 1. Then, since the absolute value of the determinant is unaffected by taking transposes (and swapping the top & bottom rows or the left and right columns), we can assume that the 2 occurs in either a corner of the middle of the top row.

This leaves $2 \cdot 7! = 10,080$ possibilities to check, which is an improvement on $9!=362,880$.

After fixing the 1,2, one could notice that there are only 4 essentially different places to put the 3, hence we only need to check $2 \cdot 4 \cdot 6! = 5,760$ possibilities.

Brute force (computing all 9! possibilities), always a favourite of mine, works too:

# python 2.7.6
import numpy
import itertools

sup = 0
for p in itertools.permutations(range(1,10)):
    m = [ p[0:3], p[3:6], p[6:10] ]
    d = abs(numpy.linalg.det(m))
    if d > sup:
        sup = d

print sup

This prints 412.0 after 8 seconds on my old X201 tablet.