Post Reply 
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
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
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 - 10-31-2021 03:40 PM



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