Baking-Pi Challenge - Understanding & Improving

心不动则不痛 提交于 2019-12-01 00:26:50
  1. if you want more bits computed per bpp call

    then you have to change your equation from 1/(16^k) base to bigger one. You can do it by summing 2 iterations (k and k+1) so you have something like

    (...)/16^k  + (...)/16^(k+1)
    (...)/256^k
    

    but in this case you need more precise int operations. It is usually faster to use the less precise iterations

  2. if you look at the basic equation then you see you do not need bigint for computation at all

    that is why this iterations are used but the output number is bigint of course. So you do not need to compute modular arithmetics on bigint.

    I do not know how optimized are the one you used ... but here are mine:

  3. if you want just speed and not infinite precision then use other PSLQ equations

    My understanding of PSLQ is that it is algorithm to find relation between real number and integer iterations.

here is my favorite up to 800 digits of Pi algorithm and here is extracted code from it in case the link broke down:

//The following 160 character C program, written by Dik T. Winter at CWI, computes pi  to 800 decimal digits. 
int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!