Yet another π formula
|
11-07-2021, 12:01 PM
(This post was last modified: 11-07-2021 12:45 PM by Albert Chan.)
Post: #17
|
|||
|
|||
RE: Yet another π formula
Wallis product part is *very slowly* converging; probably not a good idea to cut down CF terms.
Another issue is to limit rounding erors of Wallis product. To improve accuracy, we keep track of partial product, less 1. (1+a)*(1+1/t) - 1 = a + (1+a)/t To recover pi, we just add back 1 (after loops finished) pi ≈ (1+a)*(1+b)*8/3 = (a*b + b + (a-1/8)) * 8/3 + 3 (*) Code: OPTION ARITHMETIC DECIMAL_HIGH n = 100 Accurate digits = 211.18296908289588 n = 101 Accurate digits = 213.27288787760364 n = 300 Accurate digits = 629.16112325948984 n = 301 Accurate digits = 631.25100446831984 For n=478, it reached 1000 digits full precision. Previous version take more total terms (3p=3*326=978) vs here (2n=2*478=956) But, pairwise sum can be greatly simplified → Previous version is faster, by about 30% (*) By Sterbenz lemma, term (a-1/8) is exact n<2: it never enter the loop, thus a = 0 n=2: a = 16/15 - 1 = 1/15, within [1/16,1/4] With more products, a is increasing. limit(a, n=inf) = 3/8*pi - 1 ≈ 1/5.6 ≤ 1/4 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)