[VA] SRC #013 - Pi Day 2023 Special
|
04-01-2023, 11:39 PM
Post: #32
|
|||
|
|||
RE: [VA] SRC #013 - Pi Day 2023 Special
Hi, all, To end this thread, there's the subject of finding values of N which result in an approximation to \(\pi\) much closer than what would be statistically expected. Of course, the larger N, the better the appoximation on the long run, but perhaps there are values of N which defy the odds and result in unexpectedly close approximations. To settle the matter, this 179-byte 4-liner finds them up to a given maximum N very, very quickly, listing all successive record-breakers:
2 FOR K=S TO N STEP S @ M(K)=0 @ NEXT K @ P=FPRIM(P+1) @ END WHILE @ V=10 @ S=7 3 FOR T=11 TO N @ S=S+(M(T)#0) @ X=SQR(6*T/S) @ Y=ABS(PI-X) @ IF Y<V THEN V=Y @ DISP T;X;V 4 NEXT T @ DISP "OK";TIME
N Pi Approx. |Error| -------- ----------------------------- (smallest values, which result in irrelevant approximations, not listed) 28 3.14362099197 0.00202833838 153 3.14180962853 0.00021697494 426 3.14145282771 0.00013982588 862 3.14169206124 0.00009940765 931 3.14153751379 0.00005513980 936 3.14164722334 0.00005456975 982 3.14155164428 0.00004100931 1033 3.14156437967 0.00002827392 1061 3.14161860223 0.00002594864 1135 3.14158641730 0.00000623629 1186 3.14159601478 0.00000336119 2094 3.14159185312 0.00000080047 5147 3.14159305181 0.00000039822 5374 3.14159277156 0.00000011797 7241 3.14159270516 0.00000005157 14709 3.14159260812 0.00000004547 25684 3.14159262180 0.00000003179 OK timing (go71b: 23.37", Emu71/Win: 3.06", physical HP-71B: 49' 51")
67490 3.14159265758 0.00000000399 89440 3.14159265330 0.00000000029 The above list of record-breakers would seem to end the discussion, but there's something which doesn't look good, the fact that there are several series of them which feature very close N and errors, such as these:
936 3.14164722334 0.00005456975 982 3.14155164428 0.00004100931 It would seem preferable to find and list only those record-breakers which are a significant improvement over their predecessors, where "significant improvement" obeys some suitable criterium, and this 6-liner implements just that:
2 FOR K=S TO N STEP S @ M(K)=0 @ NEXT K @ P=FPRIM(P+1) @ END WHILE @ U=1 @ V=10 @ Q=1 @ S=7 3 FOR T=11 TO N @ S=S+(M(T)#0) @ X=SQR(6*T/S) @ Y=ABS(PI-X) @ IF Y>=V THEN 6 4 W=T/Q @ Z=V/Y @ H=(Z-1)/(W-1) @ IF H<3 THEN 6 5 Q=T @ V=Y @ DISP T;X;V;FNR(Z,3);FNR(W,3);FNR(H,3) 6 NEXT T @ DISP "OK";TIME @ DEF FNR(N,D)=IROUND(10^D*N)/10^D
N Pi Approx. |Error| Epre/E N/Npre Merit -------- ------------------------------------------------------- (smallest values, which result in irrelevant approximations, not listed) 1135 3.14158641730 0.00000623629 325.248 40.536 8.201 1186 3.14159601478 0.00000336119 1.855 1.045 19.036 2094 3.14159185312 0.00000080047 4.199 1.766 4.178 5374 3.14159277156 0.00000011797 6.785 2.566 3.693 7241 3.14159270516 0.00000005157 2.288 1.347 3.706 OK timing (go71b: 25.4", Emu71/Win: 3.33", physical HP-71B: 54' 11")
89440 3.14159265330 0.00000000029 13.759 1.325 39.229
5147 3.14159305181 0.00000039822 2.010 2.458 0.693 Finally, we can do the search for N much greater than 100,000, up to 1,500,000 and beyond by using boolean operators and variables and I've written such a version of this program implementing them, but that's left to the reader as an exercise ... Thanks to all of you who participated, much appreciated and I hope you enjoyed it all. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)