# How to test with whether a group is cyclic?

Does Sage offer a 'native' way to test whether a group is cyclic?

Remarks. Needless to say, Sage offers commands like 'is_abelian()' or 'is_finite()', but wherever I look, nothing like 'is_cyclic'.

edit retag close merge delete

Sort by » oldest newest most voted

As @dan_fulea says, it depends on the class of the group:

sage: search_def('is_cyclic')
groups/abelian_gps/abelian_group.py:1037:    def is_cyclic(self):
groups/perm_gps/permgroup.py:3482:    def is_cyclic(self):
plot/arc.py:221:            def is_cyclic_ordered(x1, x2, x3):
rings/finite_rings/integer_mod_ring.py:818:    def multiplicative_group_is_cyclic(self):


The command search_def searches for the given string as part of the definition of a function or method, so you can see that is_cyclic is defined for abelian groups, additive abelian groups, and permutation groups.

more

Please declare an explicit group, the class of it is important. For instance:

sage: G = DihedralGroup(8)
sage: G.is_cyclic()
False
sage: G.gens()
[(1,2,3,4,5,6,7,8), (1,8)(2,7)(3,6)(4,5)]


Also

sage: G = SymmetricGroup(3)
sage: for H in G.subgroups():
....:     print "gens=%s order=%s abelian=%s cyclic=%s" % (H.gens(), H.order(), H.is_abelian(), H.is_cyclic())
....:
gens=[()] order=1 abelian=True cyclic=True
gens=[(2,3)] order=2 abelian=True cyclic=True
gens=[(1,2)] order=2 abelian=True cyclic=True
gens=[(1,3)] order=2 abelian=True cyclic=True
gens=[(1,2,3)] order=3 abelian=True cyclic=True
gens=[(2,3), (1,2,3)] order=6 abelian=False cyclic=False


and

sage: AbelianGroup(1).is_cyclic()
True

more

## Stats

Seen: 320 times

Last updated: Mar 25 '18