CoCalc Shared FilesFTonRandomPerm.sagews
Author: Sarah Wolff
Views : 39
ABC=0
ACB=0
BAC=0
BCA=0
CAB=0
CBA=0

for i in [1..50]:
s=Permutations(3).random_element()
if s==[1,2,3]:
ABC=ABC+1
if s==[1,3,2]:
ACB=ACB+1
if s==[2,1,3]:
BAC=BAC+1
if s==[2,3,1]:
CAB=CAB+1
if s==[3,2,1]:
CBA=CBA+1
if s==[3,1,2]:
BCA=BCA+1
#this part above creates a function on the permutations in S_3 by randomly generating 50 permutations and counting how many occurrences of each one. this is our f

spc = SymmetricGroupRepresentation([2,1], 'specht')
MABC=spc.representation_matrix(Permutation([1,2,3]))
MACB=spc.representation_matrix(Permutation([1,3,2]))
MBAC=spc.representation_matrix(Permutation([2,1,3]))
MCAB=spc.representation_matrix(Permutation([2,3,1]))
MCBA=spc.representation_matrix(Permutation([3,2,1]))
MBCA=spc.representation_matrix(Permutation([3,1,2]))
alt=SymmetricGroupRepresentation([1,1,1],'specht')
AABC=alt.representation_matrix(Permutation([1,2,3]))
AACB=alt.representation_matrix(Permutation([1,3,2]))
ABAC=alt.representation_matrix(Permutation([2,1,3]))
ACAB=alt.representation_matrix(Permutation([2,3,1]))
ACBA=alt.representation_matrix(Permutation([3,2,1]))
ABCA=alt.representation_matrix(Permutation([3,1,2]))
#the part above gets the matrices for each permutation in S_3, for each representation.

P111=ABC*AABC+ACB*AACB+BAC*ABAC+BCA*ABCA+CAB*ACAB+CBA*ACBA
#this computes the sum f(s)rho(s) for each element s in S_3, for the representation 1,1,1. In other words, this is the fourier coefficient for the representation 1,1,1
P21=ABC*MABC+ACB*MACB+BAC*MBAC+BCA*MBCA+CAB*MCAB+CBA*MCBA
#same as above but for 2,1
print 'P111', P111
print 'P21'
print P21

P111 [8] P21 [-2 -7] [-2 -3]
#this is the same process as above but for S_4 instead of S_3
perm=[[1, 2, 3, 4],[1, 2, 4, 3],[1, 3, 2, 4],[1, 3, 4, 2],[1, 4, 2, 3],[1, 4, 3, 2],[2, 1, 3, 4],[2, 1, 4, 3],[2, 3, 1, 4],[2, 3, 4, 1],[2, 4, 1, 3],[2, 4, 3, 1],[3, 1, 2, 4],[3, 1, 4, 2],[3, 2, 1, 4],[3, 2, 4, 1],[3, 4, 1, 2],[3, 4, 2, 1],[4, 1, 2, 3],[4, 1, 3, 2],[4, 2, 1, 3],[4, 2, 3, 1],[4, 3, 1, 2],[4, 3, 2, 1]]
#perm=permutations(4)

L=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in [1..7000]:
s=Permutations(4).random_element()
for j in [0..23]:
if s==perm[j]:
L[j]=L[j]+1
print L

M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

spc = SymmetricGroupRepresentation([3,1], 'specht')
for k in [0..23]:
M[k]=spc.representation_matrix(Permutation(perm[k]))

square = SymmetricGroupRepresentation([2,2], 'specht')
for k in [0..23]:
S[k]=square.representation_matrix(Permutation(perm[k]))

three = SymmetricGroupRepresentation([2,1,1], 'specht')
for k in [0..23]:
T[k]=three.representation_matrix(Permutation(perm[1]))

alt = SymmetricGroupRepresentation([1,1,1,1], 'specht')
for k in [0..23]:
A[k]=alt.representation_matrix(Permutation(perm[k]))

P22=0
P31=0
P211=0
P1111=0

for l in [0..23]:
P22=P22+S[l]*L[l]

for l in [0..23]:
P31=P31+M[l]*L[l]

for l in [0..23]:
P211=P211+T[l]*L[l]

for l in [0..23]:
P1111=P1111+A[l]*L[l]

print 'P31'
print P31
print 'P22'
print P22
print 'P211'
print P211
print 'P1111'
print P1111

print (P31[0,0]^2+P31[0,1]^2+P31[0,2]^2+P31[1,0]^2+P31[1,1]^2+P31[1,2]^2+P31[2,0]^2+P31[2,1]^2+P31[2,2]^2)/9.0
print (P22[0,0]^2+P22[0,1]^2+P22[1,0]^2+P22[1,1]^2)/4.0
print (P211[0,0]^2+P211[0,1]^2+P211[0,2]^2+P211[1,0]^2+P211[1,1]^2+P211[1,2]^2+P211[2,0]^2+P211[2,1]^2+P211[2,2]^2)/9.0

[268, 289, 286, 290, 301, 274, 300, 272, 296, 304, 282, 290, 291, 266, 298, 298, 278, 309, 281, 310, 288, 297, 321, 311] P31 [-101 89 -46] [ -5 -1 -40] [ 27 -95 26] P22 [ 32 -20] [ 134 -138] P211 [ 7000 0 0] [ 7000 -7000 0] [ 7000 0 -7000] P1111 [-14] 3588.22222222222 9606.00000000000 2.72222222222222e7


L=[1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

spc = SymmetricGroupRepresentation([3,1], 'specht')
for k in [0..23]:
M[k]=spc.representation_matrix(Permutation(perm[k]))

square = SymmetricGroupRepresentation([2,2], 'specht')
for k in [0..23]:
S[k]=square.representation_matrix(Permutation(perm[k]))

three = SymmetricGroupRepresentation([2,1,1], 'specht')
for k in [0..23]:
T[k]=three.representation_matrix(Permutation(perm[k]))

alt = SymmetricGroupRepresentation([1,1,1,1], 'specht')
for k in [0..23]:
A[k]=alt.representation_matrix(Permutation(perm[k]))

P22=0
P31=0
P211=0
P1111=0

for l in [0..23]:
P22=P22+S[l]*L[l]

for l in [0..23]:
P31=P31+M[l]*L[l]

for l in [0..23]:
P211=P211+T[l]*L[l]

for l in [0..23]:
P1111=P1111+A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Q[2,3],Q[3,0]+Q[0,1]+Q[2,2]+Q[1,3],Q[3,0]+Q[1,1]+Q[0,2]+Q[2,3],Q[3,0]+Q[1,1]+Q[2,2]+Q[0,3],Q[3,0]+Q[2,1]+Q[0,2]+Q[1,3],Q[3,0]+Q[2,1]+Q[1,2]+Q[0,3]]
print L

M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

spc = SymmetricGroupRepresentation([3,1], 'specht')
for k in [0..23]:
M[k]=spc.representation_matrix(Permutation(perm[k]))

square = SymmetricGroupRepresentation([2,2], 'specht')
for k in [0..23]:
S[k]=square.representation_matrix(Permutation(perm[k]))

three = SymmetricGroupRepresentation([2,1,1], 'specht')
for k in [0..23]:
T[k]=three.representation_matrix(Permutation(perm[k]))

alt = SymmetricGroupRepresentation([1,1,1,1], 'specht')
for k in [0..23]:
A[k]=alt.representation_matrix(Permutation(perm[k]))

P22=0
P31=0
P211=0
P1111=0

for l in [0..23]:
P22=P22+S[l]*F[l]

for l in [0..23]:
P31=P31+M[l]*F[l]

for l in [0..23]:
P211=P211+T[l]*F[l]

for l in [0..23]:
P1111=P1111+A[l]*F[l]

print 'P31'
print P31
print 'P22'
print P22
print 'P211'
print P211
print 'P1111'
print P1111

print (P31[0,0]^2+P31[0,1]^2+P31[0,2]^2+P31[1,0]^2+P31[1,1]^2+P31[1,2]^2+P31[2,0]^2+P31[2,1]^2+P31[2,2]^2)/9.0
print (P22[0,0]^2+P22[0,1]^2+P22[1,0]^2+P22[1,1]^2)/4.0
print (P211[0,0]^2+P211[0,1]^2+P211[0,2]^2+P211[1,0]^2+P211[1,1]^2+P211[1,2]^2+P211[2,0]^2+P211[2,1]^2+P211[2,2]^2)/9.0

[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] P31 [ 270 -406 216] [ 706 -490 560] [ 246 -70 160] P22 [0 0] [0 0] P211 [0 0 0] [0 0 0] [0 0 0] P1111 [0] 158616.000000000 0.000000000000000 0.000000000000000
#attempting to create their algorithm

F=[0,0,10,0,16,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,20,0,0,0]

Q=matrix([[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]])

for i in [0..23]:
for j in [1..4]:
if perm[i][0]==j:
Q[0,j-1]=Q[0,j-1]+F[i]
for j in [1..4]:
if perm[i][1]==j:
Q[1,j-1]=Q[1,j-1]+F[i]
for j in [1..4]:
if perm[i][2]==j:
Q[2,j-1]=Q[2,j-1]+F[i]
for j in [1..4]:
if perm[i][3]==j:
Q[3,j-1]=Q[3,j-1]+F[i]

print Q
S=sorted(Q.list()) #ascending order of Q
print S

p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in [1..9]:
C= Subsets([0..k[i-1]], submultiset=True).list()
print C
for l in [1..len(C)-1]:
print sum([C[l][h] for h in [0..len(C[l])-1]])
if S[i-1]==p[0]:
k[i-1]=k[i-2]
else:
k[i-1]=k[i-2]+1
p[i]=S[i-1]

print k

[26 0 5 20] [ 5 20 10 16] [20 26 0 5] [ 0 5 36 10] [0, 0, 0, 5, 5, 5, 5, 10, 10, 16, 20, 20, 20, 26, 26, 36] [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [[], [0]] 0 [0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0]
#start with a function f, find its Q1 and Q2, build the 'obvious' f, compare (see page 31 in notebook)
Q1=matrix([[12,51,6,7],[3,52,22,120],[11,11,1,9],[3,3,3,8]])
Q2=matrix([[5,0,10,3,1,0],[0,14,0,0,0,5],[6,0,6,0,4,3],[3,4,0,6,0,6],[5,0,0,0,14,0],[0,1,3,10,0,5]])
F1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
#perm=permutations(4)
for k in [0..len(perm)-1]:
for i in [1..4]:
for j in [1..4]:
if perm[k][i-1]==j:
F1[k]=F1[k]+Q1[j-1,i-1]
print F1
F2=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
I=[[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
#i indexes row in matrix Q2, j indexes column in matrix Q2, I[i-1] indexes the pair corresponding to that row, I[j-1] the pair corresponding to that column
for k in [0..len(perm)-1]:
for i in [1..6]:
for j in [1..6]:
#            print 'i',i,'j',j, I[i-1], I[j-1]
if perm[k][I[i-1][0]-1]==I[j-1][0] and perm[k][I[i-1][1]-1]==I[j-1][1] or perm[k][I[i-1][0]-1]==I[j-1][1] and perm[k][I[i-1][1]-1]==I[j-1][0]:
F2[k]=F2[k]+Q2[i-1,j-1]
#eg if i=3  and j=2 (so I[i-1]=1,4 and I[j-1]=1,3), does the kth permutation send 1->1,4->3 or 1->3,4->1?
#if so, then add the i,j element of Q2 to F2[k]
#                print 'k',k,'i',i,'j',j,perm[k]

print F2

M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

spc = SymmetricGroupRepresentation([3,1], 'specht')
for k in [0..23]:
M[k]=spc.representation_matrix(Permutation(perm[k]))

square = SymmetricGroupRepresentation([2,2], 'specht')
for k in [0..23]:
S[k]=square.representation_matrix(Permutation(perm[k]))

three = SymmetricGroupRepresentation([2,1,1], 'specht')
for k in [0..23]:
T[k]=three.representation_matrix(Permutation(perm[k]))

alt = SymmetricGroupRepresentation([1,1,1,1], 'specht')
for k in [0..23]:
A[k]=alt.representation_matrix(Permutation(perm[k]))

P22=0
P31=0
P211=0
P1111=0
P22F2=0
P31F2=0
P211F2=0
P1111F2=0

for l in [0..23]:
P22=P22+S[l]*F1[l]

for l in [0..23]:
P31=P31+M[l]*F1[l]

for l in [0..23]:
P211=P211+T[l]*F1[l]

for l in [0..23]:
P1111=P1111+A[l]*F1[l]

for l in [0..23]:
P22F2=P22F2+S[l]*F2[l]

for l in [0..23]:
P31F2=P31F2+M[l]*F2[l]

for l in [0..23]:
P211F2=P211F2+T[l]*F2[l]

for l in [0..23]:
P1111F2=P1111F2+A[l]*F2[l]
print 'P31'
print P31
print 'P22'
print P22
print 'P211'
print P211
print 'P1111'
print P1111
print 'P31F2'
print P31F2
print 'P22F2'
print P22F2
print 'P211F2'
print P211F2
print 'P1111F2'
print P1111F2

[73, 76, 53, 146, 46, 136, 63, 66, 28, 24, 21, 14, 92, 185, 77, 73, 140, 43, 85, 175, 70, 63, 140, 43] [50, 10, 12, 12, 20, 60, 18, 10, 14, 18, 2, 14, 6, 10, 40, 16, 28, 0, 26, 38, 8, 24, 8, 12] P31 [ 270 -406 216] [ 706 -490 560] [ 246 -70 160] P22 [0 0] [0 0] P211 [0 0 0] [0 0 0] [0 0 0] P1111 [0] P31F2 [ 80 -24 16] [ 80 -8 80] [ 24 0 128] P22F2 [-48 48] [ 36 120] P211F2 [0 0 0] [0 0 0] [0 0 0] P1111F2 [0]


spc = SymmetricGroupRepresentation([3,2], 'seminormal')

print spc

Seminormal representation of the symmetric group corresponding to [3, 2]
spc.representation_matrix(Permutation([1,2,3,5,4]))

[ 1 0 0 0 0] [ 0 -1/2 0 3/2 0] [ 0 0 -1/2 0 3/2] [ 0 1/2 0 1/2 0] [ 0 0 1/2 0 1/2]


spc = SymmetricGroupRepresentation([4,1], 'orthogonal')
spc.representation_matrix(Permutation([1,2,4,5,3]))

[ -1/4 1/4*sqrt(15) 0 0] [ -1/12*sqrt(15) -1/12 2/3*sqrt(2) 0] [1/6*sqrt(15)*sqrt(2) 1/6*sqrt(2) 1/3 0] [ 0 0 0 1]


spc = SymmetricGroupRepresentation([2,2,1], 'orthogonal')
L=spc.representation_matrix(Permutation([1,2,4,3,5]))
L.nrows()

5