Help:=proc() : print(`G(m,n,q) , RatM(M,N,q), G1(m,n,q) `): print(`GuessPolq(L,q,z), PP2(M,N,q), PP3(M,N,q)`): end: #[a[1],a[2], ..., a[M]] #N>=a[1]>=...>=a[M]>=0 #G(M,N,q):The generating polynomial whose coeff. of q^n #is the number of ways of arranging #n chocolate pieces that fit into an M by N box #(left-justified and top-justified) G:=proc(M,N,q) option remember: if M=0 or N=0 then 1: elif M<0 or N<0 then 0: else #Case 1: top-right piece has been eaten sort(expand(G(M,N-1,q)+ #case 2: top-right has not (yet) been eaten q^N*G(M-1,N,q))): fi: end: RatM:=proc(M,N,q): normal(G(M,N,q)/G(M-1,N,q)):end: RatMN:=proc(M,N,q): normal(RatM(N,N,q)/RatM(N-1,M,q)):end: #G(M,2)=(1-q^(M+2))*(1-q^(M+1))/(1-q)/(1-q^2): #G(M,3)=(1-q^(M+3))*(1-q^(M+2))*(1-q^(M+1))/(1-q)/(1-q^2)/(1-q^3) G1:=proc(M,N,q) local i: normal(mul((1-q^(M+i))/(1-q^i),i=1..N)): end: #GuessPolq(L,q,z): Inputs L, a list of polynomials in q, #and conjectures a polynomial in z=q^n for them #For example GuessPolq([1,q,q^2,q^3,q^4],q,n); should be q^n GuessPolq:=proc(L,q,z) local d: for d from 0 to nops(L)-3 while GuessPolq1(L,q,z,d)=FAIL do od: if d=nops(L)-2 then RETURN(FAIL): fi: GuessPolq1(L,q,z,d): end: GuessPolq1:=proc(L,q,z,d) local eq,var,c, i,P: P:=add(c[i]*z^i,i=0..d): var:={seq(c[i],i=0..d)}: eq:={seq(subs(z=q^i,P)=L[i],i=1..nops(L))}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: factor(subs(var,P)): end: #N>=a1 >= a2>= ... >= aM>=0 #v= v= v= #N>=b1>= b2>= ... >= bM>=0 # #PP2(M,N,q): the gen. poly for 2 by M by N (two-layered) #choc. box # PP2:=proc(M,N,q): normal(PP2a(N,N,M+1,q)/q^(2*N)): end: PP2a:=proc(a1,b1,M,q) local a2,b2: option remember: if M<=0 then RETURN(FAIL): fi: if M=1 then RETURN(q^(a1+b1)): fi: expand(q^(a1+b1)* add(add( PP2a(a2,b2,M-1,q), b2=0..min(a2,b1) ),a2=0..a1)): end: #N>=a1 >= a2>= ... >= aM>=0 #v= v= v= #N>=b1>= b2>= ... >= bM>=0 # #N>=c1>=c2>= ... cM>=0 #PP3(M,N,q): the gen. poly for 2 by M by N (two-layered) #choc. box # PP3:=proc(M,N,q): normal(PP3a(N,N,N,M+1,q)/q^(3*N)): end: PP3a:=proc(a1,b1,c1,M,q) local a2,b2,c2: option remember: if M<=0 then RETURN(FAIL): fi: if M=1 then RETURN(q^(a1+b1+c1)): fi: expand(q^(a1+b1+c1)* add(add( add(PP3a(a2,b2,c2, M-1,q),c2=0..min(b2,c1)), b2=0..min(a2,b1) ),a2=0..a1)): end: