#OK to post homework #Zhizhang Deng, 10/23/2020, Assignment 12 1. CPg := proc(L) local first, second, n, ans: # try every two combination for elements in L then pass it to CP and join the final answer ans := []; n := nops(L); for first from 1 to n - 1 by 1 do for second from first + 1 to n by 1 do # (first, second) is every unordered combination ans := [op(ans), op(CP(L[first], L[second]))] end do; end do; return ans; end: 2. AveGF := proc(f, x): return subs(x=1,diff(f,x))/subs(x=1,f): end: kthMomentGF:=proc(f, x, k) local mu,f1,i: mu:=AveGF(f, x): f1:=f/x^mu/subs(x=1,f): for i from 1 to k do f1:=expand(x*diff(f1,x)): od: subs(x=1,f1): end: 3. ScaledMomentGF := proc(f, x, k) : return kthMomentGF(f, x, k) / kthMomentGF(f, x, 2) ^ (k / 2): end: 4. sgf := [seq(ScaledMomentGF(((1 + x)/2)^n, x, k), k = 2 .. 10)] # sgf now contain a list of element with some of them have n in it seq(limit(sgf[i], n = infinity), i = 1 .. nops(sgf)) = 1, 0, 3, 0, 15, 0, 105, 0, 945 this sequence is in OEIS, with A number: A123023