Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
10-31-2021, 03:40 PM (This post was last modified: 11-06-2021 03:00 PM by Albert Chan.)
Post: #13
 Albert Chan Senior Member Posts: 2,101 Joined: Jul 2018
RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
Another approach, getting ζ(2) with alternating series.

Σ(all terms) = Σ(even terms) * 4
Σ(odd terms) = Σ(all terms) - Σ(even terms) = Σ(even terms) * 3
Σ(odd terms) - Σ(even terms) = Σ(even terms) * 2

Let s = (-1)^n, x=n*n+n+1, T's = triangular number

ζ(2) ≈ (2 - 2/2^2 + 2/3^2 - ... + s*2/n^2)

﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ - s/(x - 1/(x+4*T1 - 2^4/(x+4*T2 - 3^4/(x+4*T3 - 4^4/(x+4*T4 - ...

Note: Tk - Tk-1 = k*(k+1)/2 - (k-1)*k/2 = k
zeta2_alt(n) is computationally less expensive than zeta2(n)

Code:
function zeta2_alt(n)     local x, t = 3*n*(n+1)+1     local a, b = 0, 0     for i = n, 2, -1 do         t = i*i         a = 2/t - a         b = t*t / (x-b)         x = x - 4*i     end     return (1-n%2*2)/(x-4-1/(x-b)) - a + 2 end

Update:

revert zeta2_alt(n) with b=0, to fairly compare against zeta2(n) (also, b=0)
zeta2_alt(n) is not as good, less accurate by about 2/5 of a decimal digit.

lua> err = function(z2) return abs(pi*pi/6-z2) end
lua> for n=1,6 do print(n, log10(err(zeta2_alt(n))/err(zeta2(n)))) end
1﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.3872388516915953
2﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.40466274755687004
3﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.4105758432666672
4﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.4132661850460007
5﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.41470949038470145
6﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.41521536217708266
 « Next Oldest | Next Newest »

 Messages In This Thread Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Gerson W. Barbosa - 10-23-2021, 02:49 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-25-2021, 01:29 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Gerson W. Barbosa - 10-26-2021, 02:12 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-26-2021, 09:47 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-26-2021, 08:28 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-29-2021, 02:16 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-01-2021, 10:42 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Gerson W. Barbosa - 11-02-2021, 12:28 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-27-2021, 05:12 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-04-2021, 08:35 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Ren - 10-26-2021, 02:13 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - floppy - 10-26-2021, 03:04 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-26-2021, 03:24 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Gerson W. Barbosa - 10-26-2021, 03:58 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Ren - 10-27-2021, 01:32 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 10-31-2021 03:40 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-05-2021, 03:55 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-01-2021, 12:56 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Gerson W. Barbosa - 11-01-2021, 05:04 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-03-2021, 12:38 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-03-2021, 01:14 AM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-03-2021, 11:28 PM RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B] - Albert Chan - 11-04-2021, 10:42 PM

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