Write a function in GAP that returns the elements in the coset gH as a list.

258 Views Asked by At

Task is to write a $function$ in GAP which takes as input a group $G$, an element $g∈G$ and a subgroup $H≤G$, and returns the elements in the coset $gH$ as a list. I am new to this software program and as far I understand code should look following:

function:=function(G,g,H)

local list, ...;

... (main code);

return list;

end; 

My question is to how to write the main code?

1

There are 1 best solutions below

0
On BEST ANSWER

The (universally recognized as beautiful and highly elegant) programming environment of GAP contains functions that make it easy to apply . Thus, to get the elements of a left coset, I would use

left_coset_elms:=function(g,H)
local list;
  list:=AsList(H);
  list:=List(list,x->g*x);
  return list;
end;

Note that there is no need to specify the whole group as extra argument.

It might be useful to sort the list of coset elements, to make comparison easier. For this, simply add a line Sort(list); befor the return command.