公理,413个315 292字节
p(n,a,b)==(x:=log(n^b);y:=n^a;[y*cos(x),y*sin(x)]);z(a,b)==(r:=[0.,0.];e:=10^-digits();t:=p(2,1-a,-b);y:=(1-t.1)^2+t.2^2;y=0=>[];m:=(1-t.1)/y;q:=t.2/y;n:=0;repeat(w:=2^(-n-1);abs(w)<e=>break;r:=r+w*reduce(+,[(-1)^k*binomial(n,k)*p(k+1,-a,-b) for k in 0..n]);n:=n+1);[r.1*m-q*r.2,m*r.2+r.1*q])
这也将实现来自http://mathworld.wolfram.com/RiemannZetaFunction.html的等式21
上面的应该是一个迭代的公理函数z(a,b),在这里它比下面的函数Zeta(a,b)慢16倍[这应该是已编译的全部],并注释掉[Zeta()为1秒,z()为16秒,浮点后为20位的一个值)。对于数字问题,可以通过调用digits()选择精度。函数,例如digits(10); z(1,1)应该在该点之后打印10位数字,但是digits(50); z(1,1)应该在该点之后打印50位数字。
-- elevImm(n,a,b)=n^(a+i*b)=r+i*v=[r,v]
elevImm(n:INT,a:Float,b:Float):Vector Float==(x:=log(n^b);y:=n^a;[y*cos(x),y*sin(x)]::Vector Float);
-- +oo n
-- --- ---
-- 1 \ 1 \ n
--zeta(s)= ---------- * / ------ * / (-1)^k( )(k+1)^(-s)
-- 1-2^(1-s) ---n 2^(n+1) ---k k
-- 0 0
Zeta(a:Float,b:Float):List Float==
r:Vector Float:=[0.,0.]; e:=10^-digits()
-- 1/(1-2^(1-s))=1/(1-x-i*y)=(1-x+iy)/((1-x)^2+y^2)=(1-x)/((1-x)^2+y^2)+i*y/((1-x)^2+y^2)
t:=elevImm(2,1-a,-b);
y:=(1-t.1)^2+t.2^2;
y=0=>[]
m:=(1-t.1)/y;
q:=t.2/y
n:=0
repeat
w:=2^(-n-1)
abs(w)<e=>break --- this always terminate because n increase
r:=r+w*reduce(+,[(-1)^k*binomial(n,k)*elevImm(k+1,-a,-b) for k in 0..n])
n:=n+1
-- (m+iq)(r1+ir2)=(m*r1-q*r2)+i(m*r2+q*r1)
[r.1*m-q*r.2,m*r.2+r.1*q]
this is one test for the z(a,b) function above:
(10) -> z(2,0)
(10) [1.6449340668 482264365,0.0]
Type: List Expression Float
(11) -> z(1,1)
(11) [0.5821580597 520036482,- 0.9268485643 3080707654]
Type: List Expression Float
(12) -> z(-1,0)
(12) [- 0.0833333333 3333333333 3,0.0]
Type: List Expression Float
(13) -> z(1,0)
(13) []