Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
2

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

asked 3 years ago

anonymous user

Anonymous

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 3 years ago

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

Illustration:

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

sage: 1 / a
3

sage: K.one() / a
3

sage: ~a
3

sage: sage: a.inverse_of_unit()
3

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.

Preview: (hide)
link
1

answered 3 years ago

guillermo gravatar image

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

Preview: (hide)
link

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

Stats

Asked: 3 years ago

Seen: 2,660 times

Last updated: Aug 15 '21