News for hackers. Stuff that matters.
Re:A Million Digits of Pi in 9 Lines of JavaScript by LeoPanthera on Thursday September 12, 2019 @03:49PM (#20955639)
On any standard unix system with bc installed - it's preinstalled on most of them, you can calculate pi to $n digits using bc:

bc -l <<< "scale=$n; 4*a(1)"

Re:A Million Digits of Pi in 9 Lines of JavaScript by ajennings on Thursday September 12, 2019 @05:07PM (#20956465)
Yes, 4 * arctan(1) will do in any language. I just find some joy in knowing a formula that uses only addition, multiplication, and addition, and computing it directly.
Re:A Million Digits of Pi in 9 Lines of JavaScript by mjcohen on Thursday September 12, 2019 @03:58PM (#20955741)
The algorithm seems to be at least quadratic in the length. On a 2014 i7 Mac mini, (n, time(sec)) = (1000, 0.29), (2000, 1.65), (4000, 9.70), (8000, 58.42).
Re:A Million Digits of Pi in 9 Lines of JavaScript by notfashion on Thursday September 12, 2019 @07:04PM (#20957424)
I think this section on Wikipedia is relevant: https://en.wikipedia.org/wiki/Approximations_of_%CF%80#Grego...