## Section 10.5 Sage

Sage has several convenient functions that will allow us to investigate quickly if a subgroup is normal, and if so, the nature of the resulting quotient group. But for an initial understanding, we can also work with the raw cosets. Let us get our hands dirty first, then learn about the easy way.

### Subsection Multiplying Cosets

The definiton of a factor group requires a normal subgroup, and then we *define* a way to â€śmultiplyâ€ť two cosets of the subgroup to produce another coset. It is important to realize that we can interpret the definition of a normal subgroup to be *exactly* the condition we need for our new multiplication to be workable. We will do two examples â€” first with a normal subgroup, then with a subgroup that is not normal.

Consider the dihedral group \(D_{8}\) that is the symmetry group of an \(8\)-gon. If we take the element that creates a quarter-turn, we can use it generate a cyclic subgroup of order 4. This will be a normal subgroup (trust us for the moment on this). First, build the (right) cosets (notice there is no output):

So `C`

is a list of lists, with every element of the group `G`

occuring exactly once somewhere. You could ask Sage to print out `C`

for you if you like, but we will try to avoid that here. We want to multiply two cosets (lists) together. How do we do this? Take *any* element out of the first list, and *any* element out of the second list and multiply them together (which we know how to do since they are elements of `G`

). Now we have an element of `G`

. What do we do with this element, since we really want a coset as the result of the product of two cosets? Simple â€” we see which coset the product is in. Let us give it a try. We will multiply coset \(1\) with coset \(3\) (there are \(4\) cosets by Lagrange's Theorem). Study the following code carefully to see if you can understand what it is doing, and *then* read the explanation that follows.

What have we accomplished? In the first line we create `p`

as the product of two group elements, one from coset \(1\) and one from coset \(3\) (`C[1]`

, `C[3]`

). Since we can choose *any* element from each coset, we choose the first element of each (`C[ ][0]`

). Then we count our way through all the cosets, selecting only cosets that contain `p`

. Since `p`

will only be in one coset, we expect a list with just one element. Here, our one-element list contains only `2`

. So we say the product of coset \(1\) and coset \(3\) is coset \(2\text{.}\)

The point here is that this result (coset \(1\) times coset \(3\) is coset \(2\)) should always be the same, *no matter which elements we pick from the two cosets to form* `p`

. So let us do it again, but this time we will not simply choose the first element from each of coset \(1\) and coset \(3\text{,}\) instead we will choose the third element of coset \(1\) and the second element of coset \(3\) (remember, we are counting from zero!).

Good. We have the same result. If you are still trusting us on `S`

being a normal subgroup of `G`

, then this is the result that the theory predicts. Make a copy of the above compute cell and try other choices for the representatives of each coset. Then try the product of other cosets, with varying representatives.

Now is a good time to introduce a way to extend Sage and add new functions. We will design a coset-multiplication function. Read the following carefully and then see the subsequent explanation.

The first line creates a new Sage function named `coset_product`

. This is accomplished with the word `def`

, and note the colon ending the line. The inputs to the function are the numbers of the cosets we want to multiply and the complete list of the cosets. The middle two lines should look familiar from above. We know `c`

is a one-element list, so `c[0]`

will extract this one coset number, and `return`

is what determines that this is the output of the function. Notice that the indentation above must be exactly as shown. We could have written all this computation on a single line without making a new function, but that begins to get unwieldly. You need to execute the code block above to actually *define* the function, and there will be no output if successful. Now we can use our new function to repeat our work above:

Now you know the basics of how to add onto Sage and do much more than it was designed for. And with some practice, you could suggest and contribute new functions to Sage, since it is an open source project. Nice.

Now let us examine a situation where the subgroup is not normal. So we will see that our definition of coset multiplication is insufficient in this case. And realize that our new `coset_product`

function is also useless since it assumes the cosets come from a normal subgroup.

Consider the alternating group \(A_4\) which we can interpet as the symmetry group of a tetrahedron. For a subgroup, take an element that fixes one vertex and rotates the opposite face â€” this will generate a cyclic subgroup of order 3, and by Lagrange's Theorem we will get four cosets. We compute them here. (Again, no output is requested.)

Again, let's consider the product of coset \(1\) and coset \(3\text{:}\)

Again, but now for coset \(3\text{,}\) choose the second element of the coset to produce the product `p`

:

So, is the product of coset \(1\) and coset \(3\) equal to coset \(0\) or coset \(2\text{?}\) We cannot say! So there is *no way* to construct a quotient group for this subgroup. You can experiment some more with this subgroup, but in some sense, we are done with this example â€” there is nothing left to say.

### Subsection Sage Methods for Normal Subgroups

You can easily ask Sage if a subgroup is normal or not. This is viewed as a property of the subgroup, but you must tell Sage what the â€śsupergroupâ€ť is, since the answer can change depending on this value. (For example `H.is_normal(H)`

will always be `True`

.) Here are our two examples from above.

The text proves in SectionÂ 10.2 that \(A_5\) is simple, i.e. \(A_5\) has no normal subgroups. We could build every subgroup of \(A_5\) and ask if it is normal in \(A_5\) using the `.is_normal()`

method. But Sage has this covered for us already.

We can also build a quotient group when we have a normal subgroup.

This is useful, but also a bit unsettling. We have the quotient group, but any notion of cosets has been lost, since `Q`

is returned as a new permutation group on a different set of symbols. We cannot presume that the numbers used for the new permutation group `Q`

bear any resemblance to the cosets we get from the `.cosets()`

method. But we can see that the quotient group is described as a group generated by two elements of order two. We could ask for the order of the group, or by Lagrange's Theorem we know the quotient has order \(4\text{.}\) We can say now that there are only two groups of order four, the cyclic group of order \(4\) and a non-cyclic group of order \(4\text{,}\) known to us as the Klein \(4\)-group or \({\mathbb Z}_2\times{\mathbb Z}_2\text{.}\) This quotient group looks like the non-cyclic one since the cyclic group of order 4 has just one element of order 2. Let us see what Sage says.

Yes, that's it.

Finally, Sage can build us a list of all of the normal subgroups of a group. The list of groups themselves, as we have seen before, is sometimes an overwhelming amount of information. We will demonstrate by just listing the orders of the normal subgroups produced.

So, in particular, we see that our â€śquarter-turnâ€ť subgroup is the *only* normal subgroup of order \(4\) in this group.