# [GAP Forum] Z/nZ x Z/nZ

Thomas Breuer thomas.breuer at math.rwth-aachen.de
Fri Oct 24 17:01:58 BST 2008

```Dear GAP Forum,

Dan Lanke wrote

> I'd like to form the group G := Z/nZ x Z/nZ. Of course I can just do
> G := DirectProduct(CyclicGroup(n), CyclicGroup(n)).
> I would like Elements(G) to give me a list of ordered pairs of cosets of
> nZ in Z. How do I do this?

1. If the main point is that the cosets of nZ in Z shall occur as group
The reason is that GAP's groups are always written *multiplicatively*,
whereas the cosets of nZ in Z form an *additive* group.

A way around this is to identify the cosets of nZ in Z with the
elements of a (multiplicative) group of order n,
to let GAP compute with this group,
and to interpret the elements as the corresponding cosets where needed.
An easy but not very efficient solution is provided by the (currently
which wraps an additive element into a multiplicative element;
the function `UnderlyingElement' then maps back to the additive element.

2. If the main point is that elements in direct products shall be
represented by ordered pairs then the answer is that GAP can do this,
but this approach is not very efficient.
For example, a direct product of two permutation groups is better
represented as a permutation group than as a group whose elements are
pairs of permutations.

One can force GAP to deal with pairs of group elements by constructing
the pairs explicitly with the (currently undocumented) function `Tuple'.
For example, the direct product of two groups of order 2 and 3,
respectively, could be created as follows.

gap> x:= Tuple( [ (1,2), () ] );
Tuple( [ (1,2), () ] )
gap> y:= Tuple( [ (), (1,2,3) ] );
Tuple( [ (), (1,2,3) ] )
gap> g:= Group( x, y );  Size( g );
<group with 2 generators>
6
gap> x[1];  x[2];
(1,2)
()

I would not recommend this approach.
In general, one can identify elements of direct products with pairs of
the direct factors using the function `Projection', see the description
of `DirectProduct' in the GAP Reference Manual.

All the best,
Thomas

```