# OK to post homework # Aurora Hiveley, 2/20/26, Assignment 9 Help:=proc(): print(`NumberOfProperties(n,L,i), PIEgD(n,L,t)`): end: ## Problem 1 # NumberOfProperties(n,L,i): inputs a positive integer n, a list of subsets, L, of {1, ..., n}, # and a member of {1, ...,n} and outputs the number of sets in L such that i belongs to them. # For example NumberOfProperties(4,[{1,3},{2,4},{3,4}],1)=1, NumberOfProperties(4,[{1,3},{2,4},{3,4}],2)=1, # NumberOfProperties(4,[{1,3},{2,4},{3,4}],3)=2, NumberOfProperties(4,[{1,3},{2,4},{3,4}],4)=2 NumberOfProperties := proc(n,L,i) local l,co: co := 0: for l in L do if i in l then co++: fi: od: co: end: ## Problem 2 # PIEgD(n,L,t): outputs the sum of t^NumberOfProperties(n,L,i) over all i from 1 to n PIEgD := proc(n,L,t) local i: add(t^NumberOfProperties(n,L,i), i=1..n): end: ## Problem 3 # Test that PIEg(n,L,t)=PIEgD(n,L,t) by doing 5 times # L:=RandL(1000,4): evalb(PIEg(n,L,t)=PIEgD(n,L,t)); # n := 1000: # L:=RandL(1000,4): evalb(PIEg(n,L,t)=PIEgD(n,L,t)); # returns true!! yay! ### copied from C9.txt #C9.txt Help9:=proc(): print(` RandL(n,k), PIEd(n,L), IntL(L) , PIE(n,L), dn(n),`): print(`dnt(n,t), PIEg(n,L,t) `): end: with(combinat): #RandL(n,k): A random list of subsets of {1, ...,n} of length k RandL:=proc(n,k) local i: [seq( randcomb(n, rand(2..n-2)()), i=1..k)]: end: #PIEd(n,L): What the PIE computes, done directly PIEd:=proc(n,L) local i: nops({seq(i,i=1..n)} minus {seq(op(L[i]),i=1..nops(L))}): end: IntL:=proc(L) local i: `intersect`(seq(L[i],i=1..nops(L))): end: #PIE(n,L): PIE:=proc(n,L) local k,cu,S,s: cu:=n: for k from 1 to nops(L) do S:=choose(L,k): cu:=cu+(-1)^k*add(nops(IntL(s)), s in S): od: cu: end: #PIEg(n,L,t): The weight-enumerator of the members of the universal set #according to t^#NumberOfProperties PIEg:=proc(n,L,t) local k,cu,S,s: cu:=n: for k from 1 to nops(L) do S:=choose(L,k): cu:=cu+(t-1)^k*add(nops(IntL(s)), s in S): od: expand(cu): end: #dn(n): The number of derangements of {1, ..., n} dn:=proc(n) local k: n!*add((-1)^k/k!,k=0..n): end: #dnt(n,t): The weight-enumerator of permutations of {1, ..., n} according #to the number of fixed dnt:=proc(n,t) local k: expand(n!*add((t-1)^k/k!,k=0..n)): end: