In[]:=
CloseKernels[]
Out[]=
{}
In[]:=
LaunchKernels[]
Out[]=
{KernelObject[42,local],KernelObject[43,local],KernelObject[44,local],KernelObject[45,local],KernelObject[46,local],KernelObject[47,local],KernelObject[48,local],KernelObject[49,local],KernelObject[50,local],KernelObject[51,local],KernelObject[52,local],KernelObject[53,local],KernelObject[54,local],KernelObject[55,local],KernelObject[56,local],KernelObject[57,local],KernelObject[58,local],KernelObject[59,local],KernelObject[60,local],KernelObject[61,local],KernelObject[62,local],KernelObject[63,local],KernelObject[64,local],KernelObject[65,local]}
In[]:=
Print["Start time is ",ds=DateString[],"."];prec=2000;(**Numberofrequireddecimals.*.*)ClearSystemCache[];T0=SessionTime[];expM[pre_]:=Module[{x11,z,t,a,d,s,k,bb,c,end,iprec,xvals,x,pc,cores=16(*=4*numberofphysicalcores*),tsize=128,chunksize,start=1,ll,ctab,pr=Floor[1.005pre]},chunksize=cores*tsize;n=Floor[1.32pr];end=Ceiling[n/chunksize];Print["Iterations required: ",n];Print["Will give ",end," time estimates, each more accurate than the previous."];Print["Will stop at ",end*chunksize," iterations to ensure precsion of around ",pr," decimal places."];d=ChebyshevT[n,3];{b,c,s}={SetPrecision[-1,1.1*n],-d,0};iprec=pr/64;Do[xvals=Flatten[ParallelTable[Table[ll=start+j*tsize+l;x=N[E^(Log[ll]/(ll)),iprec];pc=iprec;While[pc<pr,pc=Min[4pc,pr];x=SetPrecision[x,pc];xll=x^ll;z=(ll-xll)/xll;t=2ll-1;t2=t^2;x=x*(1+SetPrecision[4.5,pc](ll-1)/t2+(ll+1)z/(2llt)-SetPrecision[13.5,pc]ll(ll-1)/(3llt2+t^3z))];(**N[Exp[Log[ll]/ll],pr]**)x,{l,0,tsize-1}],{j,0,cores-1}]];ctab=ParallelTable[Table[c=b-c;ll=start+l-2;b*=2(ll+n)(ll-n)/((ll+1)(2ll+1));c,{l,chunksize}],Method"Automatic"];s+=ctab.(xvals-1);start+=chunksize;st=SessionTime[]-T0;kc=k*chunksize;ti=(st)/(kc+10^-4)*(n)/(3600)/(24);If[kc>1,Print["As of ",DateString[]," there were ",kc," iterations done in ",N[st,5]," seconds. That is ",N[kc/st,5]," iterations/s. ",N[kc/(end*chunksize)*100,7],"% complete."," It should take ",N[ti,6]," days or ",N[ti*24*3600,4],"s, and finish ",DatePlus[ds,ti],"."]];Print[];,{k,0,end-1}];N[-s/d,pr]];t2=Timing[MRB1=expM[prec];];Print["Finished on ",DateString[],". Proccessor and actual time were ",t2[[1]]," and ",SessionTime[]-T0," s. respectively"];Print["Enter MRB1 to print ",Floor[Precision[MRB1]]," digits. The error from a 6,500,000 or more digit calculation that used a different method is "];N[MRB-MRB1,20]
Start time is Sun 31 Jul 2022 12:54:43.
Iterations required: 2651
Will give 2 time estimates, each more accurate than the previous.
Will stop at 4096 iterations to ensure precsion of around 2009 decimal places.
As of Sun 31 Jul 2022 12:54:43 there were 2048 iterations done in 0.24291 seconds. That is 8431.3 iterations/s. 50.00000% complete. It should take 3.63917× days or 0.3144s, and finish Sun 31 Jul 2022 12:54:43.
-6
10
Finished on Sun 31 Jul 2022 12:54:43. Proccessor and actual time were 0.171875 and 0.2429052 s. respectively
Enter MRB1 to print 2004 digits. The error from a 6,500,000 or more digit calculation that used a different method is
Out[]=
0.×
-2006
10
In[]:=
(*NewerloopwithNewtoninterior.*)prec=2000;(*Numberofrequireddecimals.*)expM[pr_]:=Module[{a,d,s,k,b,c},n=Floor[1.32pr];Print["Iterations required: ",n];d=N[(3+Sqrt[8])^n,pr+10];d=Round[1/2(d+1/d)];{b,c,s}={-1,-d,0};T0=SessionTime[];Do[c=b-c;x=N[E^(Log[k+1]/(k+1)),iprec=Ceiling[prec/128]];pc=iprec;Do[nprec=Min[2pc,pr];x=SetPrecision[x,nprec];(*Adjustprecision*)x=N[x-x/(k+1)+1/x^k,nprec];pc*=2;If[nprec≥pr,Break[]],{ct,1,19}];s+=c*(x-1);b*=2(k+n)(k-n)/((k+1)(2k+1));If[Mod[k,1000]0,Print["Iterations: ",k," Cumulative time (sec): ",SessionTime[]-T0];],{k,0,n-1}];N[-s/d,pr]];N[MRB-expM[prec],20]
Iterations required: 2640
Iterations: 0 Cumulative time (sec): 0.×
-8
10
Iterations: 1000 Cumulative time (sec): 0.0754642
Iterations: 2000 Cumulative time (sec): 0.1612933
Out[]=
0.×
-1997
10
In[]:=
(*NewerloopwithNewtoninterior.*)prec=2500;(*Numberofrequireddecimals.*)expM[pr_]:=Module[{a,d,s,k,b,c},n=Floor[1.32pr];Print["Iterations required: ",n];d=N[(3+Sqrt[8])^n,pr+10];d=Round[1/2(d+1/d)];{b,c,s}={-1,-d,0};T0=SessionTime[];Do[c=b-c;x=N[E^(Log[k+1]/(k+1)),iprec=Ceiling[prec/128]];pc=iprec;Do[nprec=Min[2pc,pr];x=SetPrecision[x,nprec];(*Adjustprecision*)x=N[x-x/(k+1)+1/x^k,nprec];pc*=2;If[nprec≥pr,Break[]],{ct,1,19}];s+=c*(x-1);b*=2(k+n)(k-n)/((k+1)(2k+1));If[Mod[k,1000]0,Print["Iterations: ",k," Cumulative time (sec): ",SessionTime[]-T0];],{k,0,n-1}];N[-s/d,pr]];N[MRB-expM[prec],20]
Iterations required: 3300
Iterations: 0 Cumulative time (sec): 0.×
-8
10
Iterations: 1000 Cumulative time (sec): 0.0998986
Iterations: 2000 Cumulative time (sec): 0.2123651
Iterations: 3000 Cumulative time (sec): 0.3374260
Out[]=
0.×
-2497
10
In[]:=
Print["Start time is ",ds=DateString[],"."];prec=5000;(**Numberofrequireddecimals.*.*)(*ClearSystemCache[];*)T0=SessionTime[];expM[pre_]:=Module[{a,d,s,k,bb,c,end,iprec,xvals,x,pc,cores=32(*=4*numberofphysicalcores*),tsize=2^7,chunksize,start=1,ll,ctab,pr=Floor[1.005pre]},chunksize=cores*tsize;n=Floor[1.32pr];end=Ceiling[n/chunksize];Print["Iterations required: ",n];Print["Will give ",end," time estimates, each more accurate than the previous."];Print["Will stop at ",end*chunksize," iterations to ensure precsion of around ",pr," decimal places."];d=ChebyshevT[n,3];{b,c,s}={SetPrecision[-1,1.1*n],-d,0};iprec=Ceiling[pr/27];Do[xvals=Flatten[ParallelTable[Table[ll=start+j*tsize+l;x=N[E^(Log[ll]/(ll)),iprec];pc=iprec;While[pc<pr,pc=Min[3pc,pr];x=SetPrecision[x,pc];y=x^ll-ll;x=x(1-2y/((ll+1)y+2llll));];(**N[Exp[Log[ll]/ll],pr]**)x,{l,0,tsize-1}],{j,0,cores-1},Method"EvaluationsPerKernel"64(*apowerof2commensuratewithprocessorstrength*)]];ctab=ParallelTable[Table[c=b-c;ll=start+l-2;b*=2(ll+n)(ll-n)/((ll+1)(2ll+1));c,{l,chunksize}],Method"EvaluationsPerKernel"16(*apowerof2commensuratewithprocessorstrength*)];s+=ctab.(xvals-1);start+=chunksize;st=SessionTime[]-T0;kc=k*chunksize;ti=(st)/(kc+10^-4)*(n)/(3600)/(24);If[kc>1,Print[kc," iterations done in ",N[st,3]," seconds."," Should take ",N[ti,2]," days or ",N[ti*24*3600,2],"s, finish ",DatePlus[ds,ti],"."]];,{k,0,end-1}];N[-s/d,pr]];t2=Timing[MRBtest2=expM[prec];];Print["Finished on ",DateString[],". Processor time was ",t2[[1]]," s. Actual time was ",SessionTime[]-T0,"."];(*Print[*)MRBtest2(*]*)(*Remove(**)orenterMRBtest2toprintoutput*);Print["Enter MRBtest2 to print ",Floor[Precision[MRBtest2]]," digits"];Print["If you saved m3M, the difference between this and 3,014,991 known digits is ",N[MRBtest2-m3M,10]]