bigdecimal icon indicating copy to clipboard operation
bigdecimal copied to clipboard

Implement BigMath::PI with Gauss-Legendre algorithm

Open tompng opened this issue 3 months ago • 0 comments

It's fast and simple. Pi calculation will be the bottleneck when we improve sin/cos or erf/erfc with bit burst algorithm. Multiplication cost needs to be less than O(N^2). Requires #407.

Time and error. PI(prec) calculates prec+16 digits internally and round to prec digits.

calculation time correct_digits last 5 digits of extra 16 digits
PI(1000000) 9.171798s 1000015 calculated: 20849 true_value: 20845
PI(10000000) 135.526677s 10000015 calculated: 26483 true_value: 26482
PI(100000000) 1624.233964s 100000014 calculated: 78333 true_value: 78327

tompng avatar Sep 18 '25 19:09 tompng