Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to find matrix Inverse over finite field?

I am using MATLAB, and I know gf() in MATLAB can enable me to do linear algebra operations over finite field $F_{2^m}$ for some m.

However, if I want to find the matrix inverse over finite field $F_p$ for some prime $p\neq 2$, how should I do in MATLAB and on the paper?

For example, if $p=11$ and if matrix A is:


I need to derive its inverse $A^{-1}$ as:


share|cite|improve this question
On paper? The same way you do it over the reals. See my walkthru answer to an example with $p=29$. – Jyrki Lahtonen Jan 9 '13 at 8:43

You could compute the adjugate for the matrix, and the determinant of the matrix, and then apply the formula: $$(1/\det(A))\mathrm{adj}(A)=A^{-1}$$

You would just need to do all computations mod $p$.

Doing it over a field size $p^m$, you would need to first generate a multiplication and addition table for the field (it is not simply $\Bbb Z/(p^m)$.) The same approach would then work. You just need to teach matlab how to do arithmetic in that field!

I remember modeling finite fields in matlab in the past, but you will probably be smarter about it and find a preexisting package or something handy that programming savvy people would do, rather than reinvent the wheel as I did.

share|cite|improve this answer
Such as SAGE: – dls Jan 8 '13 at 21:01
@dls Could I ask you fast what your top picks for computer algebra systems that are good for messing with finite rings are? – rschwieb Jan 8 '13 at 21:05
Sorry @rschwieb, that's not my area of expertise. – dls Jan 9 '13 at 2:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.