Ask Your Question

How do I get the inverse of an element in a finite field GF(p)?

asked 2021-08-14 05:19:28 +0100

anonymous user


If I create a finite field,

K = GF(7)

and then select and element,

a = K(5)

what do I have to type in to get the inverse as an element of the same field K?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2021-08-14 10:33:52 +0100

slelievre gravatar image

There are at least three options:

  • "one over"
  • unary division with "tilda" in prefix notation
  • the inverse_of_unit method of ring elements


sage: K = GF(7)
sage: a = K(5)

sage: 1 / a

sage: / a

sage: ~a

sage: sage: a.inverse_of_unit()

In many other settings, objects that can be inverted also have a method called inverse.

That is however not the case here:

sage: a.inverse()
Traceback (most recent call last)
AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int'
object has no attribute 'inverse'

Maybe such a method could be added for finite field elements.

edit flag offensive delete link more

answered 2021-08-15 07:21:54 +0100

guillermo gravatar image

In addition to the previous answers, you could simply write inverse_mod(a,7).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-08-14 05:19:28 +0100

Seen: 636 times

Last updated: Aug 15 '21