Post Reply 
Yet another π formula
01-07-2021, 09:56 PM (This post was last modified: 01-09-2021 08:35 PM by Albert Chan.)
Post: #11
RE: Yet another π formula
(01-07-2021 12:57 PM)Gerson W. Barbosa Wrote:  Great! The continued fraction part is left unproved, however. But that would not be easy, I presume.

"Wasicki's formula" had first term converge to pi, correction converge to 0. QED

As to the gain of 25/12 digits per term, it tested OK even with 10,000 digits precision. Smile

Code:
def test_pi(n, cf=0, c=0, s=0):
    cf += n         # extra cf "terms"
    b = 2*n*(n+1) + 4*cf*(cf+1) + mpfr(1.5)
    for k in range(cf,n,-1):
        t = mpfr(4*k*k-1)
        c = k*k*t/(b-c)
        b = b - 8*k
    for k in range(n,0,-1):
        t = mpfr(4*k*k-1)
        s = 1/t - s
        c = k*k*t/(b-c)
        b = b - 8*k
    return (s+0.5)*4 + (-1)**n/(b-c)

>>> from gmpy2 import *
>>> get_context().precision = 34000 # > 10000 dec. digits
>>> pi = const_pi()
>>>
>>> for n in range(1000,4001,1000): print n, format(pi - test_pi(n), 'g')
...
1000 2.19966e-2091
2000 2.92237e-4181
3000 3.88382e-6271
4000 5.16203e-8361
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Yet another π formula - Gerson W. Barbosa - 01-04-2021, 08:41 PM
RE: Yet another π formula - Albert Chan - 01-05-2021, 10:50 PM
RE: Yet another π formula - Albert Chan - 01-06-2021, 01:32 AM
RE: Yet another π formula - Albert Chan - 01-07-2021 09:56 PM
RE: Yet another π formula - toml_12953 - 01-06-2021, 02:10 AM
RE: Yet another π formula - ttw - 01-06-2021, 03:44 AM
RE: Yet another π formula - Albert Chan - 01-09-2021, 09:22 PM
RE: Yet another π formula - Albert Chan - 11-06-2021, 06:28 PM



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