08-15-2022, 09:35 PM
(This post was last modified: 08-15-2022, 09:35 PM by Kernelpanic.)
Just finished calculating pi to 30 trillion places.
|
Kernelpanic
Ramanujan’s Formula for Pi would go something like this, consider it pseudo-code Code: (Select All) pie=0
08-15-2022, 11:02 PM
(08-15-2022, 10:23 PM)Jack Wrote: Kernelpanic Nice work at applying the formula, Jack. It works up to 8 iterations before the binary computer math breaks it. Makes me with I had powers and square roots coded for my routine. I'll hang on to this for some time in the future. Pete
08-16-2022, 12:21 AM
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
08-16-2022, 12:56 AM
(08-15-2022, 08:43 PM)Pete Wrote:(08-15-2022, 07:28 PM)JRace Wrote: @KernelPanic: the first constant: Yeah, looks like a precision issue, but the location of the discrepancy strikes me as odd.
08-16-2022, 01:25 AM
(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 @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
Pete, that should work but you need to perform all calculations to digits accuracy
there's a quartic version of the Gauss–Legendre algorithm for Pi, that is the accuracy quadruples on each iteration, but I find that's a bit slower https://en.wikipedia.org/wiki/Approximat...algorithms the quartic version would be something like the following Code: (Select All) y=2 : y=sqr(y)
08-16-2022, 12:30 PM
A really nice and quick one is this one:
Code: (Select All) $Console:Only
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
08-16-2022, 01:43 PM
Pete, you could adapt this code https://qb64forum.alephc.xyz/index.php?P...#msg133377
08-16-2022, 05:11 PM
(This post was last modified: 08-16-2022, 05:12 PM by Kernelpanic.)
|
« Next Oldest | Next Newest »
|
Users browsing this thread: 3 Guest(s)