Post Reply 
Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
10-25-2021, 01:29 PM (This post was last modified: 10-25-2021 07:16 PM by Albert Chan.)
Post: #2
RE: Evaluation of ζ(2) by the definition (sort of) [HP-42S & HP-71B]
Code:
function zeta2(n)
    local a, b, c, N, t = 0, 0, (n%2)*6+2, n+0.5
    local N2 = N*N
    for i = n, 2, -1 do
        t = i*i
        a = a + 1/t
        b = t*t/(b + c*N2)
        c, N2 = 10-c, N2-N
    end
    return 1/(N+1/(b+c*N2)) + a + 1
end

This lua code loop from n down to 2 instead of n to 1.
Note: for n = 0, this return 1.4 instead of 2.

lua> for n=0,8 do print(n, zeta2(n)) end
0     1.4
1     1.6428571428571428
2     1.644949494949495
3     1.644933946685539
4     1.6449340678010402
5     1.6449340668406054
6     1.6449340668482877
7     1.644934066848226
8     1.6449340668482264

Convergence speed very impressive, n=8 converged to float(pi^2/6) Smile
How did you derive the continued fraction form ?

I was reading Why pi^2 so close to 10 ? With pi^2 ≈ 10, pi^2/6 ≈ 5/3

5/3 = 1 + sum(4/(4*k^2-1), k=2..inf)       // terms telescopically cancel, leaving only 5/3

ζ(2) = 1 + sum(1/k^2, k=2..inf)
5/3 - ζ(2) = sum(4/(4*k^2-1) - 1/k^2, k=2..inf)
ζ(2) = 5/3 - sum(1/(k^2*(4*k^2-1)), k=2..inf)

We might as well pull 1 term out. (pi^2/6 ≈ 9.9/6 = 1.65)

ζ(2) = 1.65 - sum(1/(k^2*(4*k^2-1)), k=3..inf)

With denominator of O(k^4), this converge much faster than ζ(2) "definition"
How can we accelerate this with continued fraction ?

---

This converge even faster, A cute sum of Ramanujan

zeta2(n) := (10 - sum(1/(k*(k+1))^3, k=1..n)) / 6
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-25-2021 01:29 PM



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