Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
3

Easiest way to work in the multiplicative group of Zmod(n)

asked 9 years ago

B r u n o gravatar image

updated 2 years ago

tmonteil gravatar image

Given an integer n, one can define in SageMath the additive group Z/nZ by

sage: Zn = Zmod(n) # or Integers(n)

Now, I would like to work in the multiplicative group (Z/nZ). Of course, I can write

sage: G = [a for a in Zn if gcd(a,n) == 1]
sage: Zn(4).multiplicative_order()
6

What I would like is an easier way of writing such a thing, such as:

sage: G = Zn.multiplicative_group() # does not exist!
sage: G(4).order() 
6

Does there exist something in SageMath to perform such kind of computations?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

You can use the unit group of your ring:

sage: n = 10
sage: Zn = Zmod(n)
sage: G = Zn.unit_group()
sage: G
Multiplicative Abelian group isomorphic to C4
sage: G.order()
4
sage: G.inject_variables()
Defining f
sage: f^2
f^2
sage: f.order()
4
sage: (f^2).order()
2

This group G comes with and embedding into Zn:

sage: Zn(f)
7
sage: Zn(f^2)
9
sage: Zn(f^3)
3
sage: Zn(f^4)
1
sage: Zn(f^5)
7
Preview: (hide)
link

Comments

Do you think there needs to be better documentation in Zmod() of this? Maybe a note about multiplicative group? Or an alias for tab-completion? Just wondering what you think.

kcrisman gravatar imagekcrisman ( 9 years ago )
1

Apparently I am not the only one who did not find that unit_group is the right method for this (cf this sage-devel thread). Another point: Though I understand that "the" G defined by unit_group is indeed the multiplicative group of Zn, I am still disturbed by the fact that its elements are not represented as integers. In particular, this implies that G(4) does not work, not G(Zn(4)).

B r u n o gravatar imageB r u n o ( 9 years ago )

In your example, 4 is not invertible in Z/10Z, so the map is not well defined. However you can go on the other way, from G to Zn. I edited the end of my answer to give an example.

tmonteil gravatar imagetmonteil ( 9 years ago )

Right, I chose a bad example, though of course it does not work with G(7) either. Well, thanks for the answer and its edition!

B r u n o gravatar imageB r u n o ( 9 years ago )

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: 9 years ago

Seen: 8,478 times

Last updated: Sep 29 '15