#C15.txt, March 8, 2018, Expmath(RU) Help:=proc(): print(` CFI(A,B), CFII(A,B), tanRat(c,d,N) , PiRat(n) `): end: #CFI(A,B): the non-simple finite continued fraction with numerators B and denominators by A, see Chrystal's book p. 512, I CFI:=proc(A,B) local t: if nops(A)<>nops(B) or A=[] then RETURN(FAIL): fi: if nops(A)=1 then RETURN(B[1]/A[1]): fi: t:=CFI([op(2..nops(A),A)], [op(2..nops(B),B)]): B[1]/(A[1]+t): end: #CFII(A,B): the non-simple finite continued fraction with numerators B and denominators by A, with Minus signs see Chrystal's book p. 512, II CFII:=proc(A,B) local t: if nops(A)<>nops(B) or A=[] then RETURN(FAIL): fi: if nops(A)=1 then RETURN(B[1]/A[1]): fi: t:=CFII([op(2..nops(A),A)], [op(2..nops(B),B)]): B[1]/(A[1]-t): end: #tanRat(c,d,N): the pair A,B that you get when you replace x by c/d , c,d integers#corrected by Edna Jones tanRat:=proc(c,d,N) local i: #[d,-3*d,5*d,-7*d, 9*d, ...] [c,c,c^2$(N-1)] [seq(d*(2*i+1)*(-1)^i,i=0..N-1)], [c,c^2$(N-1)]: end: #PiRat(n): rational approximations of Pi better than 22/7 PiRat:=proc(n) local george: george:=int((x*(1-x))^(4*n)/(1+x^2),x=0..1): -coeff(george,Pi,0)/coeff(george,Pi,1): end: