Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is a good notion for dealing with such problems : the kernel of a matrix. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set x0+kkinK.

So, you can do the following:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]
click to hide/show revision 2
No.2 Revision

There is a good notion for dealing with such problems : the kernel kernel of a matrix. matrix, and i strongly suggest you to learn about it. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set ${x_0+k \mid k in \in K}$.

So, you can do the following:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]
click to hide/show revision 3
No.3 Revision

There is a good notion for dealing with such problems : the kernel of a matrix, and i strongly suggest you to learn about it. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set ${x_0+k $\{x_0+k \mid k \in K}$.K\}$.

So, you can do the following:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]
click to hide/show revision 4
No.4 Revision

There is a good notion for dealing with such problems : the kernel of a matrix, and i strongly suggest you to learn about it. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set $\{x_0+k $x_0+K = \{x_0+k \mid k \in K\}$.

So, you can do the following:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]
click to hide/show revision 5
No.5 Revision

There is a good an important mathematical notion for dealing with such problems : the kernel of a matrix, and i strongly suggest you to learn about it. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set x0+K={x0+kkK}.

So, you can do the following:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]
click to hide/show revision 6
No.6 Revision

There is an important mathematical notion for dealing with such problems : the kernel of a matrix, and i strongly suggest you to learn about it. If K is the (right) kernel of A, if x0 is a solution of the equation Ax=b, then the set of solutions of the equation is the set x0+K={x0+kkK}.

So, you can do the following:

Setting:

sage: A = random_matrix(GF(3),4,6) ; A
[2 1 2 2 0 2]
[2 2 0 1 2 0]
[0 2 2 1 2 2]
[2 0 0 1 0 2]
sage: b = vector(GF(3),(2,2,0,2)) ; b
(2, 2, 0, 2)
 

Find parameters x0 and K:

sage: x0 = A.solve_right(b)
sage: x0
(1, 0, 0, 0, 0, 0)

sage: K = A.right_kernel() ; K
Vector space of degree 6 and dimension 2 over Finite Field of size 3
Basis matrix:
[1 0 1 1 0 0]
[0 1 2 1 0 1]
 

Enumerate solutions:

sage: solutions = [x0 + k for k in K] ; solutions
[(1, 0, 0, 0, 0, 0),
 (2, 0, 1, 1, 0, 0),
 (0, 0, 2, 2, 0, 0),
 (1, 1, 2, 1, 0, 1),
 (2, 1, 0, 2, 0, 1),
 (0, 1, 1, 0, 0, 1),
 (1, 2, 1, 2, 0, 2),
 (2, 2, 2, 0, 0, 2),
 (0, 2, 0, 1, 0, 2)]

You can check:

sage: for i in solutions:
....:     print A*i
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)
(2, 2, 0, 2)