# Minimal Faithful Degree code not working.

I'm making code to find the minimal faithful degree of reflection groups. There are two things that are going wrong as of now:

When I run for Reflection Groups, I get:

ValueError: the input data (2) is not valid for reflection groups.

The code is as below:

def getSocle(G):

Z=G.center()
gens=Z.gens()
genK=[]
while len(gens) == 0:
ExtractRep(~gens, ~gen)
ord=Order(gen)
p=Factorization(ord)
n=Factorization(ord)
gen2=gen^(p^(n-1))
genK.append(gen2) #gen2 is the element of order p in <gen>

K= G.subgroup([genK]) #(?)
return K

def getMinimalFaithfulDegree(G):

Inter=getSocle(G)
subs=G.subgroups()
F=[]
j=len(subs)

while j >= 1:
sub = subs[j-1]
if Inter.is_subgroup(sub) is False:
F.append(sub)
j -= 1
return F

def mu(F):

alph=0
for i in range(1,len(F)):
alph+= 1/F[i].order()
return alph

def abelianFactors(G):

orders=[]
gens=G.gens()
for i in gens:
orders.append(i.order())
return orders

def aplhaAbelian(G):

orders=abelianFactors(G)
return (sum(orders))/(prod(orders)) #sum of orders of cyclic groups/the product of orders, look into syntax

def Alpha(G):

if G.is_abelian(): #(?)
return alphaAbelian(G)
else:
F=getMinimalFaithfulDegree(G)
return mu(F)

Alpha(SymmetricGroup(4))


This gives 0, i don't know why.

edit retag close merge delete

I do not know what is the expected result, but you can insert a few print statements here and there in your code to see and verify correctness of intermediate results.
The definition of mu looks suspicious, as alph is simply overwritten with each iteration of the loop.