#Yusra Naqvi #HW 26 #OK to post ################################################################################ #1. #Number of necklaces with 15 beads colored Red, 23 beads colored Blue, and #12 beads colored Green #coeff(coeff(coeff(WtCol(Cn(15+23+12),3,x),x[1],15),x[2],23),x[3],12); #37564175809042384320 ################################################################################ #2. #Number of ways one can color the faces of a cube (up to rotational symmetry) #with 3 faces colored Red, 2 faces colored Blue, and 1 face colored Green #coeff(coeff(coeff(WtCol(Gp({[1,4,2,5,3,6],[2,6,3,4,1,5],[4,2,1,6,5,3]}),3,x), #x[1],3),x[2],2),x[3],1); #3 ################################################################################ ###Stuff from C26.txt### ################################################################################ with(combinat): with(group): ################################################################################ #Wt(pi,s): the weight, according to Polya, of a permutation pi #weight(pi)=prod(s[i]^(number of cycles of length i) #For example: #wt([2,1,4,5,3])=s[2]*s[3] #wt([1,2,3,4,5,6])=s[1]^6 #wt([2,3,4,5,6,1])=s[6] Wt:=proc(pi,s) local L,n,i,W: n:=nops(pi): L:=convert(pi,`disjcyc`): W:=mul(s[nops(L[i])],i=1..nops(L)): W*s[1]^n/subs({seq(s[i]=s[1]^i,i=2..n)},W): end: ################################################################################ #CIP(G,s): inputs a group or even a set of permutations, and a variable s, and #outputs the Polya cycle-index polynomial #1/|G|*(sum of the weights of all pi in G) CIP:=proc(G,s) local pi: add(Wt(pi,s),pi in G)/nops(G): end: ################################################################################ #Cn(n): the group of rotations of a circle with n beads #[i,i+1..,n,1,...i-1] Cn:=proc(n) local i,j: {seq([seq(j,j=i..n),seq(j,j=1..i-1)],i=1..n)}: end: ################################################################################ #WtCol(G,c,x): The generating function of all colorings with weight #x[1]^nc[1]*x[2]^nc[2]*... WtCol:=proc(G,c,x) local i,s,P,n: n:=nops(G[1]): P:=CIP(G,s): expand(subs({seq(s[i]=add(x[j]^i,j=1..c),i=1..n)},P)): end: ################################################################################ ###End of Stuff from C26.txt### ################################################################################ ################################################################################ ###Stuff from hw24.txt### ################################################################################ #3 #Mul(P,Q): inputs two permutations (written as lists) of the same lengths and #outputs their product Mul:=proc(P,Q) local L,i: if nops(P)<>nops(Q) then return(FAIL): fi: L:=[]: for i from 1 to nops(P) do L:=[op(L),Q[P[i]]]: od: L: end: ################################################################################ #4 #Gp(S): inputs a set of permutations of the same length and outputs the set #of all permutations in the group generated by the members of S Gp:=proc(S) local check,G,NewP,s,p: if not type(S,set) then return(FAIL): fi: check:={}: for s in S do check:=check union {nops(s)}: od: if nops(check)<>1 then return(FAIL): fi: G:={}: NewP:=S: while NewP minus G <> {} do G:=G union NewP: NewP:={seq(seq(Mul(s,p),s in S),p in NewP)}: od: G: end: ################################################################################ #5 #Using the convention that a cubic die is given by: #Front: 1 ; Back: 6; Left:3; Right: 4; Bottom: 2; Top: 5; #we get the following permutations: #Rotation about x-axis: #[1,4,2,5,3,6] #Rotation about y-axis: #[2,6,3,4,1,5] #Rotation about z-axis: #[4,2,1,6,5,3] #The subgroup of S_6 generated by these rotations is: #Gp({[1,4,2,5,3,6],[2,6,3,4,1,5],[4,2,1,6,5,3]}); #{[1, 2, 3, 4, 5, 6], [1, 3, 5, 2, 4, 6], [1, 4, 2, 5, 3, 6], #[1, 5, 4, 3, 2, 6], [2, 1, 4, 3, 6, 5], [2, 3, 1, 6, 4, 5], [2, 4, 6, 1, 3, 5], #[2, 6, 3, 4, 1, 5], [3, 1, 2, 5, 6, 4], [3, 2, 6, 1, 5, 4], [3, 5, 1, 6, 2, 4], #[3, 6, 5, 2, 1, 4], [4, 1, 5, 2, 6, 3], [4, 2, 1, 6, 5, 3], [4, 5, 6, 1, 2, 3], #[4, 6, 2, 5, 1, 3], [5, 1, 3, 4, 6, 2], [5, 3, 6, 1, 4, 2], [5, 4, 1, 6, 3, 2], #[5, 6, 4, 3, 1, 2], [6, 2, 4, 3, 5, 1], [6, 3, 2, 5, 4, 1], [6, 4, 5, 2, 3, 1], #[6, 5, 3, 4, 2, 1]} ################################################################################ ###End of Stuff from hw24.txt ################################################################################