#OK to post homework #Blair Seidler, 2021-03-14 Assignment 15 with(combinat): Help:=proc(): print(`UDbetter(n),PiGuillera(N)`): end: # 1. #UDbetter(n): The set of up-down permutations of length n, using the ideas behind # the enumeration procedure ud(n) done in class UDbetter:=proc(n) local numleft,Left,Right,L,R,l,r,G: option remember: if n=0 then RETURN({[]}): fi: if n=1 then RETURN({[1]}): fi: G:={}: for numleft from 1 to n-1 by 2 do L:=UDbetter(numleft): R:=UDbetter(n-numleft-1): for Left in choose(n-1,numleft) do Right:=convert({seq(1..n-1)} minus convert(Left,set),list): G:=G union {seq(seq([op(l),n,op(r)], l in subs({seq(i=Left[i],i=1..nops(Left))},L)), r in subs({seq(i=Right[i],i=1..nops(Right))},R))} od: od: G: end: # 2. Not getting this one done by the due date. I will think about it some more # 3. #PiGuillera(N): Outputs an approximation to pi equal to the sum of the #first N terms of Jesus Guillera's series. PiGuillera:=proc(N) local sum,n: sum:=0: for n from 0 to N do sum:=sum+(-1)^n*binomial(2*n,n)^5*(820*n^2+180*n+13)/2^(20*n): od: sqrt(128/sum): end: #### Setting Digits:=10000, PiGuillera(3340)-Pi returns 0.