Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Just finished calculating pi to 30 trillion places.
#16
(08-16-2022, 12:21 AM)Jack Wrote: 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

@Jack

I can't say I'm a fan of this one. Digits variable at 100 runs 6 iterations. I tried other iterations with less accurate or completely skewed results. So the...
Code: (Select All)
fix(log(digits)*1.44269504088896)

...is lost on me. at digits = 100 the output was: 3.141697. Is there any way to get that more accurate and produce more digits?

Pete
Reply


Messages In This Thread
RE: Just finished calculating pi to 30 trillion places. - by Pete - 08-16-2022, 01:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  calculating ratios to find optimal grid layout madscijr 16 2,615 02-21-2025, 10:24 PM
Last Post: madscijr
  Searching sateliet calculating position program. Rudi59 4 1,227 09-20-2024, 10:50 PM
Last Post: Rudi59
  Calculating with complex numbers Kernelpanic 5 1,421 07-07-2022, 10:44 AM
Last Post: triggered

Forum Jump:


Users browsing this thread: 1 Guest(s)