Evaluation of ζ(2) by the definition (sort of) [HP42S & HP71B]

11052021, 03:55 PM
(This post was last modified: 11062021 02:59 PM by Albert Chan.)
Post: #23




RE: Evaluation of ζ(2) by the definition (sort of) [HP42S & HP71B]
(10312021 03:40 PM)Albert Chan Wrote: Let s = (1)^n, x=n*n+n+1, T's = triangular number Alternating sum CF correction, compared with nonalternating sum version, is lousy. The only reason RHS also have 2.0899 digits per iteration is because error to fix is shrinking fast. lua> z2 = pi^2/6 lua> z2(1+1/4) , z2(11/4)*2 0.3949340668482264 0.1449340668482264 lua> z2(1+1/4+1/9) , z2(11/4+1/9)*2 0.28382295573711525 0.07728815537399591 lua> z2(1+1/4+1/9+1/16) , z2(11/4+1/91/16)*2 0.22132295573711525 0.047711844626004085 But, this may actually be useful ! We can spend more time summing the alternating series, less time doing CF corrections. In the end, we may come out ahead. As an experiment, we cut down CF terms in half. (p pairs alternating series, do p CF terms) Bonus: summing alternating series pairwise also made final sum more accurate. Code: OPTION ARITHMETIC DECIMAL_HIGH p (pairs) = 66 Accurate digits = 204.17629078832496 p (pairs) = 68 Accurate digits = 210.30106011838216 p (pairs) = 266 Accurate digits = 816.6266359578656 p (pairs) = 268 Accurate digits = 822.75106992654514 For p=326, it almost reached 1000 digits full precision (1 ULP error, last digit = 8 instead of 9) Because of asymmetry of terms, 2p (pairs) here, we expect cost about n = 3p, for previous version. 2*(2p) + (2p) = 6p = (3p) + (3p) Using previous standard, for gain in digits per "iteration" p = 66 to 68: (210.3011  204.1763) / 3 = 2.0416 p = 266 to 268: (822.7511  816.6266) / 3 = 2.0415 It seems convergence is slightly worse. But, timings suggested otherwise. For almost full precision case (p = 326) vs previous version (n=478), this version is faster, by quite a bit: time(old version, n=478) / time(new version, p=326) = (0.22 sec) / (0.14 sec) ≈ 1.57 I cannot explain this ... 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)