#C16.txt: Help16:=proc(): print(` PiJGyuxuan(dig), PiJGrao(d), PiJGrdb(n)`): print(`PiJGmm(N), PiJGblair, PiJG(d),LT(n,k) , IsGood1(n,k), LT(n,k)`): end: PiJGyuxuan:=proc(dig) local i,j: Digits:=3*dig+10: i:=13: for j from 1 to dig do i:=evalf(i+(-1)^j*binomial(2*j,j)^5*(820*j^2+180*j+13)/2^(20*j)): od: Digits:=dig: evalf(sqrt(128/i)): end: #PiJG(10000) gives the same output as Digits:=10000:evalf(Pi): on my computer. PiJGrao := proc(d) local p: Digits := d: p := 13 + Sum((-1)^k*(doublefactorial(2*k-1)/doublefactorial(2*k))^5*((k*20*(41*k+9)+13)/2^(k*10)),k=1..infinity): RETURN(evalf(sqrt((1/p)*128))): end: PiJGmm:=proc(N) local n, term, accum, smallTerm, result; accum:=13; for n from 1 to N do term := ((-1)^n) * ((binomial(2*n,n))^5) * (820*n^2 + 180*n + 13)/2^(20*n); accum:=accum + term; #if n mod 500 = 0 then # smallTerm:= evalf(term); # print(smallTerm); #fi; od; #print(accum); result:=evalf(sqrt(128/accum)); result; end proc; PiJGrdb := proc(n) local total,front,power,k,top: total := 0: front := 1: power := 1: for k from 1 to n do front := -1 * front * (2 * k - 1) / (2 * k): power := power * 2^10: top := 20 * k * (50 + 41 * (k - 1)) + 13: total := total + (front)^5 * top / power: od: total := 13 + total: sqrt(128 / total): end: #PiJGblair(N): Outputs an approximation to pi equal to the sum of the #first N terms of Jesus Guillera's series. PiJGblair:=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: #PiJG(d): Adapting RDB's code to specifying the number of digits PiJG := proc(d) local n,total,front,power,top,term: Digits:=d+5: total := 0: front := 1: power := 1: term:=13: total:=13: for n from 1 while abs(term)>=1/10^(Digits+2) do front := -1 * front * (2 * n - 1) / (2 * n): power := power * 2^10: top := 20 * n * (50 + 41 * (n - 1)) + 13: term:=(front)^5 * top / power : total := total + evalf(term): od: total := total: sqrt(128 / total): end: with(combinat): #added after class #IsGood1(T): Given a potential trapezoid (in the right-angled format) # that you know that its horiz. , vertical #and its NW->SE diagonals for the truncated version (where you chopped #the last row), returns true iff the new one is also OK #Try: #IsGood1([[1,2,3],[2,1]]); IsGood1:=proc(T) local n,k,i: k:=nops(T): n:=nops(T[1]): for i from 1 to nops(T[k]) do #checking that all NW->SW diagonals are OK if member(T[k][i],{seq(T[k-j][i+j],j=1..k-1)}) then RETURN(false): fi: #Checking that all vertical lines are distinct if member(T[k][i],{seq(T[j][i],j=1..k-1)}) then RETURN(false): fi: od: true: end: #LT(n,k): The SET OF REDUCED n by k LATIN TRAPEZOIDS #The bottom line is 1,...,n, and each floor above it #of length n-1,n-2, .., n-k+1 has all DIFFERENT entries #also VERTICALLY all different also A[i][i],A[i+1][i+1], ... are #all different LT:=proc(n,k) local S, Sold,PNF,old1,f,new1: option remember: if k=1 then RETURN({[[seq(i,i=1..n)]]}): fi: Sold:=LT(n,k-1): PNF:=permute(n,n-k+1): S:={}: for old1 in Sold do for f in PNF do new1:=[op(old1),f]: if IsGood1(new1) then S:=S union {new1}: fi: od: od: S: end: