#C15.txt: March 10, 2016; Celebrating Pi Day early Help:=proc(): print(` SlowPi(N), MachinPi, AT1(X,Y) , AT(L), JG(N) `): end: Digits:=1000: #SlowPi(N): Using Gottfried L.'s stupid formula to compute Pi SlowPi:=proc(N) local i: evalf(4*add((-1)^i/(2*i+1),i=0..N)): end: MachinPi:=proc() 4*evalf(4*arctan(1/5)-arctan(1/239)): end: #AT1(X,Y): AT1:=proc(X,Y): normal((X+Y)/(1-X*Y)): end: #AT(L): inputs a list of numbers or symbols iterates AT1 AT:=proc(L) if nops(L)=1 then RETURN(L[1]): elif nops(L)=2 then RETURN(AT1(L[1],L[2])): else RETURN( normal(AT1(L[nops(L)], AT(L[1..nops(L)-1]) ) )): fi: end: #JGslow(N): The amazing fast formula of Jesus #Guillera for computing 128/Pi^2. Slow Version, superseded by JG(N) JGslow:=proc(N) local i,Pol,x,j,hyp,su: su:=0: for i from 0 to N do Pol:=13+20*i*(9+41*i): x:=1/2^10: hyp:=mul(2*j-1,j=1..i)/mul(2*j,j=1..i): su:=evalf(su+(-1)^i*Pol*hyp^5*x^i): od: su: end: #JG(N): The amazing fast formula of Jesus Guillera for computing 128/Pi^2 JG:=proc(N) local i,Pol,x,su,te: su:=13: te:=1: x:=1/2^10: for i from 1 to N do Pol:=13+20*i*(9+41*i): #hyp:=mul(2*j-1,j=1..i)/mul(2*j,j=1..i): te:=-x*te*((2*i-1)/(2*i))^5: su:=evalf(su+te*Pol): od: su: end: #UD(n): the number of up-down permutations of length n UD:=proc(n) local i: option remember: if (n=0 or n=1) then RETURN(1): fi: add(binomial(n-1,2*i-1) * UD(2*i-1)*UD(n-2*i),i=1..trunc(n/2)): end: #SeqUD(N): the list of UD(n)from n=1 to n=N SeqUD:=proc(N) local n: [seq(UD(n),n=1..N)]: end: