Post Reply 
Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
11-03-2021, 12:38 AM
Post: #18
RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
(10-31-2021 03:40 PM)Albert Chan Wrote:  Another approach, getting ζ(2) with alternating series.

I translated the code to Decimal Basic, to check its convergence rate.
Amazingly, it is almost the same as original! 2.0899 digit per iteration

However, accuracy is less by 0.4180 digit, compared with non alternating sum.
Cost per loop is a lot smaller though.

Code:
OPTION ARITHMETIC DECIMAL_HIGH
10 INPUT  PROMPT "n = ":n
   LET x = 3*n*(n+1)+1
   LET a = 0
   LET b = 0
   FOR i = n TO 2 step -1
      LET t = i*i
      LET a = 2/t - a
      LET b = t*t / (x-b)
      LET x = x - 4*i
   NEXT i   
   LET z2 = (1-MOD(n,2)*2)/(x-4-1/(x-b)) - a + 2  
   PRINT "Accurate digits ="; 1-LOG10(ABS(PI*PI/6-z2))
   GOTO 10
END

Note: I did not add the b initial correction, for fair comparison.

n = 100
Accurate digits = 210.27025201561072
n = 101
Accurate digits = 212.36014715889508
n = 102
Accurate digits = 214.45004193935936
n = 400
Accurate digits = 837.2346060430264
n = 401
Accurate digits = 839.32448364856168
n = 402
Accurate digits = 841.41436124813102

For n=478, it almost reached 1000 digits full precision (1 ULP error, last digit = 8 instead of 9)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-03-2021 12:38 AM



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