Just finished calculating pi to 30 trillion places.
#14
the simplest and fast way to calculate pi is to use the Gauss–Legendre algorithm https://en.wikipedia.org/wiki/Gauss%E2%8..._algorithm
the Pi - Chudnovsky with binary splitting is much faster here's a version in FreeBasic https://www.freebasic.net/forum/viewtopi...85#p178885

all calculations need to be performed to full precision
Code: (Select All)
   digits=100
   pow2=1
    c0=0: ak = c0: bk = c0: ab = c0: asq = c0
    c1=1: a = c1: ck = c1
    c2=2: b = c2
    c05=.5: sum = c05

    b=sqr(b)
    b=c1/b
    for k=0 to fix(log(digits)*1.44269504088896)
        ak=a+b
        ak=c05*ak
        ab=a*b
        bk=sqr(ab)
        asq=ak*ak
        ck=asq-ab
        pow2=pow2*2
        tmp=ck*pow2
        sum=sum-tmp
        a = ak: b = bk
    next
    tmp=asq/sum
    pie=c2*tmp
    print pie
Reply


Messages In This Thread
RE: Just finished calculating pi to 30 trillion places. - by Jack - 08-16-2022, 12:21 AM



Users browsing this thread: 13 Guest(s)