This Sage worksheet was developed for the MAA PREP Workshop "Sage: Using Open-Source Mathematics Software with Undergraduates" (funding provided by NSF DUE 0817071).
As computers are discrete and finite, anything with a discrete, finite set of generators is natural to implement and explore.
Many common groups are pre-defined, usually as permutation groups. They are not always easy to find. But every group of order 15 or less is available as a permutation group.
{{{id=1| G = QuaternionGroup() G /// }}} {{{id=2| H = AlternatingGroup(5) H /// }}} {{{id=3| H.is_simple() /// }}} {{{id=4| D = DihedralGroup(8) D /// }}}Notice that we can access a lot of information - such a list of subgroups up to conjugacy, or a stabilizer, or other things demonstrated below.
{{{id=5| for K in D.conjugacy_classes_subgroups(): print K /// }}} {{{id=8| D.stabilizer(3) /// }}} {{{id=6| for K in D.normal_subgroups(): print K /// }}} {{{id=7| L = D.subgroup(["(1,3,5,7)(2,4,6,8)"]) /// }}} {{{id=9| L.is_normal(D) /// }}} {{{id=10| Q=D.quotient(L) Q /// }}} {{{id=11| Q.is_isomorphic(KleinFourGroup()) /// }}}There are some matrix groups as well, both finite and infinite.
{{{id=12| S = SL(2, GF(3)) S /// }}} {{{id=14| for a in S: print a, "\n" /// }}} {{{id=15| SS = SL(2, ZZ) /// }}}Of course, you have to be careful what you try to do!
{{{id=16| SS.list() /// }}} {{{id=17| for a in SS.gens(): print a, "\n" /// }}}Sage has many pre-defined rings to experiment with.
$\ZZ_{12}$
{{{id=20| twelve = Integers(12) twelve /// }}} {{{id=25| twelve.is_field() /// }}} {{{id=23| twelve.is_integral_domain() /// }}}$i^2=?$, $j^2=?$, then $k=i\cdot j$, all over $\QQ$
{{{id=24| quat = QuaternionAlgebra(-1, -1) quat /// }}} {{{id=26| quat.is_field() /// }}} {{{id=30| quat.is_commutative() /// }}} {{{id=31| quat.is_division_algebra() /// }}} {{{id=32| quat2 = QuaternionAlgebra(5, -7) /// }}} {{{id=33| quat2.is_division_algebra() /// }}} {{{id=34| quat2.is_field() /// }}}Support for finite fields and extensions of the rationals is superb.
The generator satisfies a Conway polynomial, by default - or the polynomial can be specified.
{{{id=50| F.polynomial() /// }}} {{{id=51| F.list() /// }}} {{{id=54| (a^3 + 2*a^2 + 2)*(2*a^3 + 2*a + 1) /// }}}$F$ should be the splitting field of the polynomial $x^{81}-x$, so no output from the following is a Good Thing (tm).
{{{id=55| for a in F: if not (a^81 - a == 0): print "Oops!" /// }}}