Help:=proc(): print(`inv1(p), Netto(n,q)`): print(`qf(n,q),MacM(n,q)`): end: with(combinat): #inv1(p): the number of inversions of #the permutation p inv1:=proc(p) local i,j,s,n: n:=nops(p): s:=0: for i from 1 to n do for j from i+1 to n do if p[i]>p[j] then s:=s+1: fi: od: od: s: end: Netto:=proc(n,q) local S,i: S:=permute(n): add(q^inv1(S[i]),i=1..nops(S)): end: qnum:=proc(n,q) local i: add(q^i,i=0..n-1):end: qf:=proc(n) local i: expand(mul(qnum(i,q),i=1..n)):end: #des1(p): the number of descents of #the permutation p des1:=proc(p) local i,s,n: n:=nops(p): s:=0: for i from 1 to n-1 do if p[i]>p[i+1] then s:=s+1: fi: od: s: end: Euler:=proc(n,t) local S,i: S:=permute(n): add(t^des1(S[i]),i=1..nops(S)): end: #maj(p): the number of descents of #the permutation p maj:=proc(p) local i,s,n: n:=nops(p): s:=0: for i from 1 to n-1 do if p[i]>p[i+1] then s:=s+i: fi: od: s: end: MacM:=proc(n,q) local S,i: S:=permute(n): sort(add(q^maj(S[i]),i=1..nops(S))): end: NettoG:=proc(a,b,q) local S,i: S:=permute([1$a,2$b]): add(q^inv1(S[i]),i=1..nops(S)): end: MacMG:=proc(a,b,q) local S,i: S:=permute([1$a,2$b]): sort(add(q^maj(S[i]),i=1..nops(S))): end: