Let $\Z[\Z/n]$ denote the integral group ring of the cyclic group $\Z/n$. How would you create $\Z[\Z/n]$ in Sage so that you could easily multiply elements?

First, if you’ve already assigned a group to the variable ‘A’, then

1 |
R = GroupAlgebra(A,ZZ) |

will give you the corresponding group ring and store it in the variable ‘R’. The first argument of ‘GroupAlgebra(-,-)’ is the group and the second is the coefficient ring. Sage uses ‘ZZ’ to denote the integers, ‘QQ’ to denote the rationals, etc.

So how do you specify the cyclic group $A$? The first posibility is to use the construction:

1 |
A = CyclicPermutationGroup(n) |

where you’d replace ‘n’ by the actual number that you want there. This is useful if you want to work with other permutation groups, because the elements of ‘A’ are stored as permutations:

1 2 3 |
A = CyclicPermutationGroup(10) for i in A: print(i) |

The output to this snippet is:

1 2 3 4 5 6 7 8 9 10 |
() (1,2,3,4,5,6,7,8,9,10) (1,3,5,7,9)(2,4,6,8,10) (1,4,7,10,3,6,9,2,5,8) (1,5,9,3,7)(2,6,10,4,8) (1,6)(2,7)(3,8)(4,9)(5,10) (1,7,3,9,5)(2,8,4,10,6) (1,8,5,2,9,6,3,10,7,4) (1,9,7,5,3)(2,10,8,6,4) (1,10,9,8,7,6,5,4,3,2) |

In most use cases this probably won’t be ideal because referring to elements of ‘A’ in code is difficult, and only gets more cumbersome as the modulus increases! A far easier approach is to use the ‘AbelianGroup’ constructor. Here is how it works:

1 |
A.<y> = AbelianGroup([10]) |

This constructs a cyclic group of order 10 with generator ‘y’. Now you can create the group ring with

1 |
R = GroupAlgebra(A,ZZ) |

Here is how you write down elements of R:

1 |
1 + R(y) |

We use the constructor ‘R(y)’ to specify that in this expression, ‘y’ is to be considered as an element of the group ring ‘R’ rather than the abelian group ‘A’. In fact, evaluating ‘1 + y’ would just result in an error. You can do arithmetic on this expression. Evaluating

1 |
(1 + R(y))^30 |

gives

1 |
2 + 6*y + 2*y^2 + 4*y^3 + 6*y^4 + 5*y^5 + 6*y^6 + 4*y^7 + 2*y^8 + 6*y^9 |

Here is another more interesting example. In the paper ‘Units of Integral Group Rings’, Sudarshan Sehgal claimed that the element

1 |
u = -372099 + 114985*R(y) + 301035*R(y^2) - 301035*R(y^3) - 114985*R(y^4) + 372100*R(y^5) - 114985*R(y^6) - 301035*R(y^7) + 301035*R(y^8) + 114985*R(y^9) |

is a unit in $\Z[\Z/10]$. Was he right? He even provided an inverse:

1 |
v = -372099 - 301035*R(y) - 114985*R(y^2) + 114985*R(y^3) + 301035*R(y^4) + 372100*R(y)^5 + 301035*R(y^6) + 114985*R(y^7) - 114985*R(y^8) - 301035*R(y^9) |

Indeed, evaluating ‘u*v’ in Sage returns ‘1’. Excellent!

Actually, did you know there is a third way of making the group ring $\Z[\Z/10]$ in Sage? It uses finitely presented groups like so:

1 2 3 |
F.<x> = FreeGroup() A.<x> = F/[x^10] R = GroupAlgebra(A,ZZ) |

I would not recommend this method for finitely generated abelian groups though because Sage won’t automatically reduce ‘x^10’ to the group identity, whether you’re working directly with ‘A’ or with a group ring of ‘A’ over some coefficient ring. Therefore, the nice check we did that ‘u’ was actually a unit and its inverse of ‘v’ would not be as straightfoward.