Wow, I wonder why Firefox is so much slower? Quantum seems pretty zippy overall, but maybe that's largely due to fast rendering speeds? Does anyone on the Spidermonkey team have some insight?
A Million Digits of Pi in 9 Lines of JavaScript
11–20 of 86 posts
Re: A Million Digits of Pi in 9 Lines of JavaScript
#12edit: There also some nice formulae for quick convergence in this article: https://julialang.org/blog/2017/03/piday
Re: A Million Digits of Pi in 9 Lines of JavaScript
#13Quick proof of this: as the number of terms n in the sum goes to infinity, the ratio of each term to the previous one is approximately 1/4 - the first factor contributes m/(m+1), the second q/(q+2) for some m and q that go to infinity along with n, the third contributes 1/4.
If we counted base 4, then the value of each digit would be on average 1/4 of the previous one, certainly for a normal number like pi. But we count base 10, so we get log_10 4 decimal digits every time we get one base-four digit. Which is very close to 0.6.
Re: A Million Digits of Pi in 9 Lines of JavaScript
#14bc -l <<< "scale=$n; 4*a(1)"
Re: A Million Digits of Pi in 9 Lines of JavaScript
#15Re: A Million Digits of Pi in 9 Lines of JavaScript
#16Re: A Million Digits of Pi in 9 Lines of JavaScript
#17JS Error `No identifiers allowed directly after numeric literal` when running http://ajennings.net/pi.html on Mac OS Mojave 10.14.6, Safari 12.1.2 (14607.3.9)
Re: A Million Digits of Pi in 9 Lines of JavaScript
#18On 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)"