Ordering finite groups by sum of order of elements

The following Maple function (code here requires the Maple package GroupTheory) takes as argument a group and returns the sum of the orders of its elements:

sumOfOrders := G -> add(u, u in map(PermOrder, convert(Elements(G), list), G));

This function takes as argument a positive integer $n$ and returns the multiset of sums of orders of elements of groups of order $n$:

sumOfOrdersList := n -> sort(map(sumOfOrders, AllSmallGroups(n)));

Checking the lowest orders manually we find that groups incomparable in your sense occur first in order 16: Executing sumOfOrdersList(16) shows there are three groups with sum $47$, three with sum $55$ and two with $87$.

(Cf. https://groupprops.subwiki.org/wiki/Groups_of_order_16 )


Feed the following code to Magma(http://magma.maths.usyd.edu.au/calc/):

for grouporder in [1..24] do
  printf "Checking sum of order for groups or order %o:", grouporder;
  numgroup := NumberOfSmallGroups(grouporder);

  sset := [];
  for i in [1..numgroup] do
    sumorder := 0;
    G := SmallGroup(grouporder,i);
    for j in G do
      sumorder := sumorder + Order(j);
    end for;
    Append(~sset, sumorder);
  end for;

  sset;
  printf "\n";
end for;

You can see that there are two groups with "signature" $(16,47)$. Much thanks to Travis for pointing it out. Two of them are non-abelian; they have GAP id $(16,3)$ and $(16,13)$. Please refer the groupprop page for the description. The third is $\mathbb Z/4\mathbb Z \times (\mathbb Z/2\mathbb Z)^2$. All have 1 element of order 1, 7 elements of order 2, and 8 elements of order 4.

Also, there are three groups with "signature" $(16,55)$.

The groups are the following:

$G_1 = (\mathbb Z/4\mathbb Z)^2$; $G_2 = \langle a, b \ | \ a^4 = b^4 = 1, ba = ab^3\rangle$ (the semi-direct product of two copies of $\mathbb Z/4\mathbb Z$), $G_3 = Q \times \mathbb Z/2\mathbb Z$, where $Q$ is the quaternion group. All have 1 element of order 1, 3 elements of order 2, and 12 elements of order 4.

Edit: This is copied from Travis' comment below. There are two groups of signature $(16,87)$ as well. One of them is the abelian group $\mathbb Z/8\mathbb Z \times \mathbb Z/2\mathbb Z$, and the other is the non-abelian group with GAP ID $(16, 6)$ or is also called $M_4(2)$. They both have 1, 3, 4, and 8 elements of order 1, 2, 4, and 8, respectively.


To give an answer which uses open source software - one could do this in GAP.

First, the GAP code based on the one from the answer by @Travis. It looks quite similar.

gap> sumOfOrders := G -> Sum(List(G,Order));
function( G ) ... end
gap> sumOfOrdersList := n -> SortedList(List(AllSmallGroups(n),sumOfOrders));
function( n ) ... end
gap> List([1..16],sumOfOrdersList);
[ [ 1 ], [ 3 ], [ 7 ], [ 7, 11 ], [ 21 ], [ 13, 21 ], [ 43 ], 
  [ 15, 19, 23, 27, 43 ], [ 25, 61 ], [ 31, 63 ], [ 111 ], 
  [ 31, 33, 45, 49, 77 ], [ 157 ], [ 57, 129 ], [ 147 ], 
  [ 31, 39, 47, 47, 47, 55, 55, 55, 59, 67, 75, 87, 87, 171 ] ]

You can see that the last list contains 47 three times. Now let's find those three groups:

gap> l:=AllSmallGroups(16,g->sumOfOrders(g)=47);
[ <pc group of size 16 with 4 generators>, 
  <pc group of size 16 with 4 generators>, 
  <pc group of size 16 with 4 generators> ]

and get their IDs:

gap> List(l,IdGroup);
[ [ 16, 3 ], [ 16, 10 ], [ 16, 13 ] ]

Some notion about their structure can be obtained by StructureDescription (which however does not define the group up to isomorphism - see here):

gap> List(l,StructureDescription);
[ "(C4 x C2) : C2", "C4 x C2 x C2", "(C4 x C2) : C2" ]

If I would be less lucky and did not manage to find an example with such quick exploration, I would likely write some code for more systematic search, which would look like the code below, following the guidelines from "Small groups search" in the GAP Software Carpentry lesson:

TestOneOrder:=function(n)
# find the smallest example among the groups of order n
local s,i,m,d,x;
# Calculate lists of sums of element orders.
# Avoid using AllSmallGroups(n) which potentially may be very large
s := List([1..NrSmallGroups(n)],i->Sum(List(SmallGroup(n,i),Order)));
if Length(Set(s))=NrSmallGroups(n) then
  # Sum of element orders uniquely defines each group
  return fail;
else
  # There are duplicates - find them first
  d := Filtered( Collected(s), x -> x[2] > 1 );
  # Find the minimal possible value of the sum of element orders
  m := Minimum( List( d, x-> x[1] ) );
  # Find positions of m in the list
  # Return the list of group IDs
  return List( Positions(s,m), x -> [n,x] );
fi;
end;

FindSmallestPair:=function(n)
# check all groups of order up to n
local i, res;
for i in [1..n] do
  # \r at the end of the print returns to the beginning of the line
  Print("Checking groups of order ", i, "\r");
  res := TestOneOrder(i);
  if res<>fail then
    # print new line before displaying the output 
    Print("\n");
    return res;
  fi;
od;
return fail;
end;    

You can find this code on GutHub here. Reading it into GAP, one could obtain the same result as follows:

gap> FindSmallestPair(20);
Checking groups of order 16
[ [ 16, 3 ], [ 16, 10 ], [ 16, 13 ] ]