The rref command can find the reduced row echelon form of a matrix with elements in ℤ/pℤ. (See 6.56.3):
Example.
Input:
Output:
⎡ ⎢ ⎢ ⎣ |
| ⎤ ⎥ ⎥ ⎦ |
This can be used to solve a linear system of equations with coefficients in ℤ/pℤ by rewriting it in matrix form
A· X = B |
rref can then take as argument the augmented matrix
of the system (the matrix obtained by augmenting matrix A to the
right with the column vector B).
rref will returns a matrix [A1,B1] where A1 has
1s on its principal diagonal and zeros outside. The
solutions in ℤ/pℤ of:
A1· X = B1 |
are the same as the solutions of:
A· X = B |
Example.
Solve in ℤ/13ℤ
⎧ ⎨ ⎩ |
|
Input:
or:
Output:
⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |
hence x=3%13 and y=3%13.