#OK to post homework #William Wang, 10/18/2020, Assignment 12 #1. CPg := proc(L) local i, j, k, l, S: S := []: for i to nops(L) do for j from 2 to nops(L) do if i < j then S := [op(S), op(CP(L[i], L[j]))]: fi: od: od: S: end: CPg([[1, 2], [3, 4]]); [4, 5, 5, 6] CPg([[3, 4], [5, 6]]); [8, 9, 9, 10] CPg([[1, 2, 3, 4], [5, 6, 7, 8]]); [6, 7, 8, 9, 7, 8, 9, 10, 8, 9, 10, 11, 9, 10, 11, 12] CPg([[1, 2], [3, 4], [5, 6]]); [4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10] #2. AveGF := proc(f, x): 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 to k do f1 := expand(x*diff(f1, x)): od: subs(x = 1, f1): end: L := [3, 4, 5, 6, 7] #Check that AveGF(WtEn(L, x), x) = AveClever(L) evalb(AveGF(WtEn(L, x), x) = AveClever(L)); true #Check that kthMomentGF(WtEn(L, x), x, k) = kthMomentClever(L, k) seq(evalb(kthMomentGF(WtEn(L, x), x, k) = kthMomentClever(L, k)), k = 1 .. 4); true, true, true, true #3. ScaledMomentGF := proc(f, x, k): kthMomentGF(f, x, k)/kthMomentGF(f, x, 2)^(1/2*k): end: #Checking that ScaledMomentGF works for L (as defined above in #2) and k=4: kthMomentGF(WtEn(L, x), x, 4)/kthMomentGF(WtEn(L, x), x, 2)^2; 17 -- 10 ScaledMomentGF(WtEn(L, x), x, 4); 17 -- 10 #4. seq(ScaledMomentGF(((1 + x)/2)^n, x, k), k = 2 .. 10); / 1 3 2\ /1 15 3 15 2\ 16 |- - n + -- n | 64 |- n + -- n - -- n | \ 8 16 / \4 64 32 / 1, 0, ------------------, 0, ------------------------, 0, 2 3 n n / 17 105 3 147 2 105 4\ 256 |- -- n - --- n + --- n + --- n | \ 16 64 64 256 / ---------------------------------------, 0, 4 n /31 945 5 4095 3 1185 2 1575 4\ 1024 |-- n + ---- n + ---- n - ---- n - ---- n | \4 1024 256 64 256 / --------------------------------------------------- 5 n #Limit as n approaches infinity for all k=2..10: #1,0,3,0,15,0,105,0,945 #This sequence is in the OEIS, its A number is A123023