Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Do you mean something like this?

min_det = 4
min_params = []
import itertools
for (i,j,k) in itertools.product([0,-1,1], repeat=3):
    M = Matrix(ZZ, [[0,1,i,j], [1,0,1,k], [0,1,0,1], [0,0,1,0]])
    M_det = M.determinant()
    if M_det == min_det:
        min_params.append((i,j,k))
    elif M_det != 0 and M_det < min_det:
        min_det = M_det
        min_params = [(i,j,k)]
print 'Minimal nontrivial determinant:', min_det
print 'Sets of parameters with this determinant:', min_params

Output:

Minimal nontrivial determinant: 1
Sets of parameters with this determinant: [(0, 0, 0), (0, 0, -1), (0, 0, 1), (-1, 0, 0), (-1, 0, -1), (-1, 0, 1), (1, 0, 0), (1, 0, -1), (1, 0, 1)]

Do you mean something like this?

min_det = 4
infinity
min_params = []
import itertools
for (i,j,k) in itertools.product([0,-1,1], repeat=3):
    M = Matrix(ZZ, [[0,1,i,j], [1,0,1,k], [0,1,0,1], [0,0,1,0]])
    M_det = M.determinant()
    if M_det == min_det:
        min_params.append((i,j,k))
    elif M_det != 0 and M_det < min_det:
        min_det = M_det
        min_params = [(i,j,k)]
print 'Minimal nontrivial determinant:', min_det
print 'Sets of parameters with this determinant:', min_params

Output:

Minimal nontrivial determinant: 1
Sets of parameters with this determinant: [(0, 0, 0), (0, 0, -1), (0, 0, 1), (-1, 0, 0), (-1, 0, -1), (-1, 0, 1), (1, 0, 0), (1, 0, -1), (1, 0, 1)]