Ask Your Question
0

List members of each subgroup of integers modulo n

asked 2014-02-10 14:31:48 +0100

Martin gravatar image

Hi - I am new to Sage so apologies if this is a dumb question.

For a given n, I would like to print out the list of subgroups of the multiplicative group modulo n as a list of the members of the subgroup. Here's one of the things I have tried so far:

R = Zmod(20) grouplist = R.multiplicative_subgroups() for subgroup in grouplist: print subgroup (11, 17) (9, 11) (3,) (11,) (19,) (17,) (9,) ()

As you can see, this gives me the generators of the sub-groups, but what I'd like is the complete list of members of the subgroup for each subgroup. Something along these lines - where members() is the method I would like, but don't know if it exists!:

R = Zmod(20) grouplist = R.multiplicative_subgroups() for subgroup in grouplist: print subgroup.members() (1, 3, 7, 9, 11, 13, 17, 19) (1, 9, 11, 19) (1, 3, 7, 9) (1, 11) (1, 19) (1, 9, 13, 17) (1, 9) (1)

Thanks for any help, Martin

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-02-10 15:48:53 +0100

Luca gravatar image

multiplicative_subgroups returns only lists of generators, rather than proper group objects. This is, in my opinion, unfortunate. You can work it around with a bit of code. This function returns the list of elements spanned by a list G of generators

def list_elts(G):
    exps = [xrange(g.multiplicative_order()) for g in G]
    return [prod(g^e for g, e in zip(G, exp)) for exp in CartesianProduct(*exps)]

So, you may call

sage: R = Zmod(20)
sage: map(list_elts, R.multiplicative_subgroups())
[[1, 17, 9, 13, 11, 7, 19, 3],
 [1, 11, 9, 19],
 [1, 3, 9, 7],
 [1, 11],
 [1, 19],
 [1, 17, 9, 13],
 [1, 9],
 [1]]
edit flag offensive delete link more

Comments

Thank you - that did the trick!

Martin gravatar imageMartin ( 2014-02-10 17:11:12 +0100 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2014-02-10 14:31:48 +0100

Seen: 1,285 times

Last updated: Feb 10 '14