I have written the following snippet of code to compute the subgroup permutability degree of a finite group $G$.
spd := function(G)
local allsubs, subreps, count, H, K, index;
subreps := Flat(List(ConjugacyClassesSubgroups(G),Representative));
allsubs := Flat(List(ConjugacyClassesSubgroups(G),Elements));
count:=0;
for H in subreps do
index := Index(G,Normalizer(G,H));
for K in allsubs do
if ArePermutableSubgroups(H,K) then
count := count+index;
fi;
od;
od;
return Float(count/(Size(allsubs)^2));
end;
I want to ask two things: first, whether this can be slightly improved to run faster, and second, how to install this as a function in GAP so that I don't have to define it every time I run the programme.
The first comment by Alexander Konovalov already tells you how you could make the function available in every run automatically.
Unless all your groups are solvable (in which case PC groups would be the choice), and assuming they can be represented by permutations of plausible degree, permutation groups are as good as it gets.
As for further improvements, you could replace `allsubs' with representatives of the orbits of the normalizer of H. These are parameterized by double cosets. That is your code would have the structure:
and then go on as you have. This will not imprve the complexity, but the number of permutability tests by a factor.