#OK to post homework #Karnaa Mistry, 12/13/20, Assignment HW #25 with(combinat): # 1. # ********* # ****** # ***** # *** # * # * # * # Doing it column by column: # Conjugate partition: [7, 4, 4, 3, 3, 2, 1, 1, 1] # 2. # Note: this equals the number of partitions of 151 whose largest part is 10 # pnk(151,10) = 79811865 # 3. # a(j) = j*(j+1)/2 # [[6,5,3,1,1,1,1,1],-1] --> 19, a(-1) = (-1)*(3*(-1)+1)/2 = 1 --> 19 + a(-1) = 20 # BZ([[6,5,3,1,1,1,1,1],-1]) = [[6, 4, 2, 2, 2, 2, 2], 0] # note: a(0) = 0*(3*0+1)/2 = 0 # 6+4+2+2+2+2+2 + a(0) = 20 # 20 = 20 # 4. # When I did pnFast(10000) I actually did get an answer, which was # 36167251325636293988820471890953695495016030339315650422081868605887952568754066420592310556052906916435144 # (same as the one with the sequence) # But, an error could have been likely due to the fact that it has so many levels of recursion. It would try # to compute thousands of layers, (especially repeats) in order to get a direct answer, which could lead to an # error or fail. If we do the sequence, however, it would be okay because the procedure uses option # remember, which lets it remember all smaller values of pnFast(i) (since we're going from i=1..10000), so # it does not have to RE-COMPUTE all of these values of pnFast(i) during the recursion - it already # remembers the ones that happen to be computed again! # [seq(PnFast(i),i=1..20000)][20000] = 2521148138125296979166195332304704522813289496018115934368503141080342.. # 84423801564956623970731689824369192324789351994903016411826230578166735959242113097 # I was able to get to 80000, but I'm sure I could have gone WAY further since Maple remembers on the way # (was just starting to take longer & longer) # 5. #pnFastMod(n,m): returns p(n) mod m pnFastMod:=proc(n,m) local j: [seq(pnFast(j),j=1..n)][n] mod 101: end: # pnFastMod(10^5,101) = 89 # 6. #InvGlashier(M): Inverse of Glashier InvGlashier:=proc(M) local i,j,L: j:=nops(M): i:=j-1: L:=[]: while (j > 0 and i > 0) do if not(M[i] = M[j]) then i:=i-1: j:=j-1: L:=[op(L),M[j]]: next: fi: L:=[op(L),M[i]+M[j]]: i:=i - 2: j:=j - 2: od: L:=[op(L),M[1]]: return(sort(L, `>`)): end: # I had trouble with this one since the inverse-Glashier relation is not unique for every possible Glashier list, but # this works for such a test case like [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1]; so this proc returns Glashier with # many (possibly all) even elements # 7. #InvSyl(L): Inverse of Sylvester's bijection InvSyl:=proc(L) local i,r,m,L1,M1,a1: option remember: if nops(L) = 1 then return([1$L[1]]): fi: ### # I had extra trouble figuring out how to actually implement this one, but I think my main trouble came from # "solving" for a1 a2 ... etc. values when we build up this partition to equal the distinct partition in #2, # keeping track of the indices when doing 2 to r & 3 to s where S(m) = 1, because once we actually get r, we # follow up with step #3 right before we have our form 2a+1,..., for the odd partition, but maybe # I'm missing some understanding from the bigger picture that would consist of straight-forward # implementation in Maple..