Sage Quickstart for Abstract Algebra

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.

Group Theory

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" /// }}}

Rings

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() /// }}}

Quaternions, and generalizations

$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() /// }}}

Polynomial Rings

{{{id=43| reset('x') # This returns x to being a variable (x^4 + 2*x).parent() /// }}} {{{id=38| R.=QQ[] R /// }}} {{{id=37| R.random_element() /// }}} {{{id=40| R.is_integral_domain() /// }}} {{{id=41| (x^4 + 2*x).parent() /// }}} {{{id=59| (x^2+x+1).is_irreducible() /// }}} {{{id=42| F=GF(5) P.=F[] /// }}} {{{id=44| P.random_element() /// }}} {{{id=45| I=P.ideal(y^3+2*y) I /// }}} {{{id=46| Q=P.quotient(I) /// }}} {{{id=47| Q /// }}}

Fields

Support for finite fields and extensions of the rationals is superb.

Finite Fields

{{{id=48| F. = GF(3^4) F /// }}}

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!" /// }}}

Field Extensions, Number Fields

{{{id=56| N = QQ[sqrt(2)] N /// }}} {{{id=58| var('z') M.
=NumberField(z^2-2) M /// }}} {{{id=60| M.degree() /// }}} {{{id=61| M.is_galois() /// }}} {{{id=62| M.is_isomorphic(N) /// }}} {{{id=65| /// }}}