# Is it possible to change the ring in which Mathematica does operations?

I would like to use Mathematica to find the eigenvalues of various members of a family of matrices which I'm using for research. The problem is that these matrices exist in $M_{n\times n}\left(\mathbb{Z}/2\mathbb{Z}\right)$, and thus even simple matrix properties would be different from the properties Mathematica would calculate by default. Take, for example, the matrix $$\begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix}.$$ In $M_{n\times n}(\mathbb{R})$, this matrix has a rank of 3, but in $M_{n\times n}(\mathbb{Z}/2\mathbb{Z})$, its rank is 2. My initial thought was to use Booleans rather than integers as the entries because $\mathbb{Z}/2\mathbb{Z}$ is of course a Boolean ring; however, it would appear that either Mathematica is not equipped to deal with operations between Booleans, or I'm not familiar enough with Mathematica to make it do so, as it outputs {False - True, False - True, False + 2 True} when asked for the eigenvalues of the above matrix written with 1=True and 0=False (I would hope for something more like {True, True, False}).

Is there any way to make Mathematica perform numerical operations in $\mathbb{Z}/2\mathbb{Z}$?

## 1 Answer

Some (but not all) linear algebra methods have an option Modulus. For example, MatrixRank[{{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}, Modulus -> 2] returns 2. Also LinearSolve and RowReduce feature a Modulus option. Unfortunately, Eigensystem does not. But the only true eigenvalue in your case is 1 and so the following gives the eigenvalues of your example matrix:

eigenvectors = NullSpace[
{{0, 1, 1}, {1, 0, 1}, {1, 1, 0}} - IdentityMatrix,
Modulus -> 2
]

• @Jules, is there a problem with this answer? – Henrik Schumacher Apr 23 '18 at 13:39