#C4.txt: Feb. 1, 2016 ExpMath (Spring 2016) (no relation to explosive) Help:=proc(): print(` BP(K), Cr(f) , LtoN(L), BAr(f), C(x,N) , BA(x,N) `): end: Digits:=1000: #BP(K): the first (prob.) prime after K BP:=proc(K) local i: for i from K+1 while not isprime(i) do od: i: end: #Cr(f): Home made continued fraction of a positive fraction f Cr:=proc(f) if type(f,integer) then [f] else [trunc(f), op(Cr(1/(f-trunc(f))))] fi end: #LtoN(L): inpts LtoN:=proc(L) if nops(L)=1 then L[1] else L[1]+ 1/LtoN(L[2..nops(L)]) fi end: #BAr(f): the sequence of BEST appx. to f with smaller denominators BAr:=proc(f) local L,i: L:=Cr(f): [seq(LtoN(L[1..i]),i=1..nops(L))]: end: #C(x,N): Home made first N terms of the continued fraction of any pos. real number x C:=proc(x,N) local y: if type(x,integer) then RETURN([x]): fi: y:=trunc(evalf(x)): if N=1 then [y]: else [y, op(C(1/(x-y) , N-1)) ]: fi: end: #BA(x,N): the sequence of BEST rational (aka Diophantine) appx. to real number x BA:=proc(x,N) local L,i: L:=C(x,N): [seq(LtoN(L[1..i]),i=1..N)]: end: