I don't understand why the inverse is this?

All the calculators that you found do their arithmetic with rationals or reals, so they are quite the wrong technology for arithmetic in the field $F_{29}$. But the usual algorithm of inverting a matrix is immune to such trifles and works the same way. I walk you thru this one. As always, we start with the given matrix augmented with an identity block on the right $$ \pmatrix{22&27&18&1&0&0\cr18&28&5&0&1&0\cr4&17&1&0&0&1\cr}. $$ To get going we want a $1$ in the upper left corner. To that end we divide the first row by $22$. In $F_{29}$ we have $4\cdot22=88=1$, so $22^{-1}=4$, and we can as well multiply the first row by $4$ (and remember to reduce everything modulo $29$) to get $$ \pmatrix{1&21&14&4&0&0\cr18&28&5&0&1&0\cr4&17&1&0&0&1\cr}. $$ Now we can pivot the first column. So we add the first row to the second multiplied by $-18=11$ and to the third multiplied by $-4=25$. Reduce modulo $29$ and get $$ \pmatrix{1&21&14&4&0&0\cr0&27&14&15&1&0\cr0&20&3&13&0&1\cr}. $$ Next we need a $1$ at the $(2,2)$-position. This time $14\cdot27=378=1$ in $F_{29}$, so we multiply the second row by $14$. $$ \pmatrix{1&21&14&4&0&0\cr0&1&22&7&14&0\cr0&20&3&13&0&1\cr}. $$ Next we clear the second column by adding to the first row the second row multiplied by $8=-21$, and adding to the third row the second row multiplied by $9=-20$: $$ \pmatrix{1&0&16&2&25&0\cr0&1&22&7&14&0\cr0&0&27&18&10&1\cr}. $$ Multiplying the third row by $14=27^{-1}$ gives us $$ \pmatrix{1&0&16&2&25&0\cr0&1&22&7&14&0\cr0&0&1&20&24&14\cr}. $$ Then we can work on the third column, and add the third row (multiplied by the appropriate constant) to the two top rows, and we end with $$ \pmatrix{1&0&0&1&18&8\cr0&1&0&2&8&11\cr0&0&1&20&24&14\cr}. $$ The row reduction worked as expected so we can deduce that the given matrix was non-singular, and its inverse can be read from the right half of the above end result.

You should walk away from this exercise with the understanding that the algorithm given in a linear algebra course works over any field. Only the details of the field arithmetic vary case-by-case. Here in particular division looked very different, but also testing whether an entry is equal to zero, $0=29=\cdots$, appears occasionally. For extra credit review the algorithm, and observe that all the operations and laws of algebra that the algorithm depends on hold in all fields.


By Cramer's rule, each coefficient of the inverse matrix is the determinant of a submatrix divided by the determinant $D$ of the original matrix. Here $D=15\pmod{29}$, whose inverse is $2$ mod $29$, hence the coefficients of the inverse matrix are twice the determinants of submatrices, that is, integers mod $29$.

Note that since $29$ is a prime, every integer which is not $0$ mod $29$ has an integer inverse hence the only case when this can fail is when the determinant is $0$ mod $29$, and then there is no inverse matrix anyway.


You could use Maple to find the inverse of some matrix. You just write the command Inverse(A) mod n. The instructions can be found here.

To find the inverse of a matrix in the field of integers mod a prime number $p$, you proceed in an analogue way as you calculate the inverse of a matrix. The usual formula can be found, for example, here.

The only thing that you need to do is to find $1/\det(A)$ in the field $\Bbb{Z}_p$, i.e. solve the equation $\det(A) \cdot x =1$ in $\Bbb{Z}_p$, and instead of dividing the entries of $A^*$ with the determinant of $A$, you multiply the entries of $A$ with $x$, the solution of the previous equation in $\Bbb{Z}_p$.