Ask Your Question
2

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

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

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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

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

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.

edit flag offensive delete link more
1

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

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

Stats

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

Seen: 1,844 times

Last updated: Aug 15 '21