I'm not sure if the title is named too obscurely, so I'll give an example of what I'm talking.
Say we have an integer matrix: M= 0 a b 0 (sorry for weird formatting; cannot seem to write matrices properly on here - any help with that as well? :P )
I want to find all values $(a,b) \in (-2,-1,0,1,2)$ such that $det(M)=2$.
I've tried the following but I'm not sure how to finish it off / if this is the right way to go:
import itertools
for (a,b) in itertools.product([-2,-1,0,1,2], repeat=2):
M = Matrix(ZZ, [[0,a],[b,0]])
if M.determinant()==2:
min_params.append((a,b))
elif
min_params = [(a,b)]
print 'Sets of parameters with this determinant:', min_params
As I say, I feel like the start would be a good way to go, but I'm stuck when reaching elif
, and I'm not sure if this is the right way to tackle this anyway!
Any help would be great!