#OK to post #Yuxuan Yang, March 14th, Assignment 15 with(combinat): #1 UDbetter:=proc(n) local pn,S,i,j,A,B,k,p,C,Ckco: option remember: if n=0 then RETURN({[]}): fi: if n=1 then RETURN({[1]}): fi: S:={}: for pn from 2 by 2 to n do A:=UDbetter(pn-1): B:=UDbetter(n-pn): C:=choose({seq(1..n-1)},pn-1): for i from 1 to nops(A) do for j from 1 to nops(B) do for k from 1 to nops(C) do Ckco:={seq(1..n-1)} minus C[k]: S:=S union {[seq(C[k][A[i][p]],p=1..pn-1),n,seq(Ckco[B[j][p]],p=1..n-pn)]}: od: od: od: od: S: end: #2 # to prove cos(x)*add(ud(n)/n! * x^n)=1+sin(x) # consider writing {1,2,...,n} in the following form # a_1b_3...b_m # an even-length increasing sequence and a up-down sequence # a_1,a_2,...,a_(2k),b_1,...b_m are distinct and compose {1..n}. # each one of these ordered pair of sequence has weight (-1)^k in cos(x)*add(ud(n)/n! * x^n) # Here is the killer-involution for # a_1b_3...b_m # (1) if a_(2k)...b_m (need m>=2) # (2) if a_(2k)>b_1 or m=0, map it to a_1b_1b_3...b_m (need k>=1) # the sign of weight is reversed by the map, so they are cancelled in cos(x)*add(ud(n)/n! * x^n) # the remaining terms which are not cancelled are: # if m=0, then k=0, the corresponding egf is 1 # if m=1, then a_(2k)pi[i+1] then RETURN(false): fi: if i mod 2=0 and pi[i]