Processing math: 100%
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solving system of linear Diophantine equations

A is a m×n integer matrix with m>n. Consider the set S={-1,0,1}.

I want to enumerate all possible XSn such that AX=0

I tried using smith_form(), but then i could not figure out how to force the solution to belong to elements of S;

click to hide/show revision 2
No.2 Revision

Solving system of linear Diophantine equations

A is a m×n integer matrix with m>n. Consider the set SZ. For example suppose S={-1,0,1}.

I want to enumerate all possible XSn such that AX=0

I tried using smith_form(), but then i could not figure out how to force the solution to belong to elements of S;

click to hide/show revision 3
No.3 Revision

Solving system of linear Diophantine equations

A is a m×n integer matrix with m>n. Consider the set SZ. For example suppose S={-1,0,1}.

I want to enumerate all possible XSn such that AX=0AX=0.

I tried using smith_form(), but then i could not figure out how to force the solution to belong to elements of S;S.


EDIT. Thank you Dima for the solution. It works well. I am adding example code here.

lb = -1
ub = 1
A = matrix(ZZ, [(8,2,10,0,12,2,0), (4,6,9,1,14,5,2), (2,0,1,1,0,1,0), (2,1,3,0,4,0,1)])
eq1 = [(0,8,2,10,0,12,2,0), (0,4,6,9,1,14,5,2), (0,2,0,1,1,0,1,0), (0,2,1,3,0,4,0,1)]
ieq1 = [(-lb,1,0,0,0,0,0,0), (ub,-1,0,0,0,0,0,0),
         (-lb,0,1,0,0,0,0,0), (ub,0,-1,0,0,0,0,0),
         (-lb,0,0,1,0,0,0,0), (ub,0,0,-1,0,0,0,0),
         (-lb,0,0,0,1,0,0,0), (ub,0,0,0,-1,0,0,0),
         (-lb,0,0,0,0,1,0,0), (ub,0,0,0,0,-1,0,0),
         (-lb,0,0,0,0,0,1,0), (ub,0,0,0,0,0,-1,0),
         (-lb,0,0,0,0,0,0,1), (ub,0,0,0,0,0,0,-1)]
p = Polyhedron(eqns=eq1, ieqs=ieq1, base_ring=QQ)
p.integral_points()

returns the answer

((-1, -1, 1, 1, 0, 0, 0),
 (0, -1, -1, 1, 1, 0, 0),
 (0, -1, 0, -1, 0, 1,1), 
 (0, 0, 0, 0, 0, 0, 0),
 (0, 1, 0, 1, 0, -1, -1),
 (0, 1, 1, -1, -1, 0,0),
 (1, 1, -1, -1, 0, 0, 0))

which is exactly what i needed. Thanks again.

click to hide/show revision 4
No.4 Revision

Solving system of linear Diophantine equations

A is a I have an m×n integer matrix A with m>n. Consider the m>n, and a set $S \subset Z$. For \mathbb{Z}$, for example suppose S={-1,0,1}.S={1,0,1}.

I want to enumerate all possible XSn such that AX=0.

I tried using smith_form(), but then i could not figure out how to force the solution to belong to elements of S.


EDIT. Thank you Dima for the solution. It works well. I am adding an example code here.here to illustrate your solution.

lb = -1
ub = 1
A = matrix(ZZ, [(8,2,10,0,12,2,0), (4,6,9,1,14,5,2), (2,0,1,1,0,1,0), (2,1,3,0,4,0,1)])
eq1 = [(0,8,2,10,0,12,2,0), (0,4,6,9,1,14,5,2), (0,2,0,1,1,0,1,0), (0,2,1,3,0,4,0,1)]
ieq1 = [(-lb,1,0,0,0,0,0,0), (ub,-1,0,0,0,0,0,0),
         (-lb,0,1,0,0,0,0,0), (ub,0,-1,0,0,0,0,0),
         (-lb,0,0,1,0,0,0,0), (ub,0,0,-1,0,0,0,0),
         (-lb,0,0,0,1,0,0,0), (ub,0,0,0,-1,0,0,0),
         (-lb,0,0,0,0,1,0,0), (ub,0,0,0,0,-1,0,0),
         (-lb,0,0,0,0,0,1,0), (ub,0,0,0,0,0,-1,0),
         (-lb,0,0,0,0,0,0,1), (ub,0,0,0,0,0,0,-1)]
p = Polyhedron(eqns=eq1, ieqs=ieq1, base_ring=QQ)
p.integral_points()

returns the answer

((-1, -1, 1, 1, 0, 0, 0),
 (0, -1, -1, 1, 1, 0, 0),
 (0, -1, 0, -1, 0, 1,1), 
 (0, 0, 0, 0, 0, 0, 0),
 (0, 1, 0, 1, 0, -1, -1),
 (0, 1, 1, -1, -1, 0,0),
 (1, 1, -1, -1, 0, 0, 0))

which is exactly what i needed. Thanks again.