# Matrix determinants (modulo)

#### craig

When calculating the inverse of a normal matrix, for $$\displaystyle M = \begin{pmatrix} x & y \\ z & v \end{pmatrix}$$ for example, you would simply use $$\displaystyle \frac{1}{xv-yz}\begin{pmatrix} v & -y \\ -z & x \end{pmatrix}$$.

However, if your matrix was $$\displaystyle \begin{pmatrix} \bar{1} & \bar{2} \\ \bar{2} & \bar{0} \end{pmatrix}$$ in $$\displaystyle \mathbb{Z}_3$$, the inverse would be:

$$\displaystyle (-\bar{4})^{-1}\begin{pmatrix} \bar{0} & \bar{-2} \\ \bar{-2} & \bar{1} \end{pmatrix} = (\bar{2})^{-1}\begin{pmatrix} \bar{0} & \bar{1} \\ \bar{1} & \bar{1} \end{pmatrix}$$.

Ok up to here, just forgotten how to calculate $$\displaystyle (\bar{2})^{-1}$$

#### Dinkydoe

I suppose with $$\displaystyle \mathbb{Z}_3$$ you mean the invertible elements of $$\displaystyle \mathbb{Z}/3\mathbb{Z}$$? (I've seen different notation for that).

Anyway, $$\displaystyle (\overline{2})^{-1}=2$$ since $$\displaystyle 2\cdot 2 = 4 \equiv 1$$ mod 3

• craig

#### craig

Yeh that was what I meant, cheers.

#### undefined

MHF Hall of Honor
For finding an arbitrary modular inverse (if it exists), there is an algorithm using the extended Euclidean algorithm, described here. Also, if you choose the method involving direct exponentiation using Euler's theorem, there are algorithms for fast modular exponentiation, one of which is described in this thread, posts #5 and #7.