Pi on the fly
Calculating the value of pi using JavaScript. With realtime visual updates.
author: Gene Biondo
3/2014 (based on my older article here)
I wanted a page where you can actually watch the value of pi being calculated in realtime. This was inspired by a BASIC program I used on a Commodore 64 in the 1980's.
This is obviously not as lightning-quick as a compiled program, especially since displaying to the screen repeatedly slows it down further. But it's more fun. If you're looking for instant results, I've included the first 1,000 digits below.
This is using the following formula: pi/4 = 1 -1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15.... As I'm sure you know, it loops infinitely, and over time gets closer to the irrational non-repeating decimal.
Next things to do:
- ensure accuracy of resume feature
- list some formulas. Examples
- find references/links to original programs
- optimize speed of calculatePi(). Faster in Chrome any more?
Here is the actual value of pi to the first 1000 decimal points:
Pi = 3. 1415926535 8979323846 2643383279 5028841971 6939937510 : 50 5820974944 5923078164 0628620899 8628034825 3421170679 : 100 8214808651 3282306647 0938446095 5058223172 5359408128 : 150 4811174502 8410270193 8521105559 6446229489 5493038196 : 200 4428810975 6659334461 2847564823 3786783165 2712019091 : 250 4564856692 3460348610 4543266482 1339360726 0249141273 : 300 7245870066 0631558817 4881520920 9628292540 9171536436 : 350 7892590360 0113305305 4882046652 1384146951 9415116094 : 400 3305727036 5759591953 0921861173 8193261179 3105118548 : 450 0744623799 6274956735 1885752724 8912279381 8301194912 : 500 9833673362 4406566430 8602139494 6394819912 8378179183 : 550 3418247744 4853615337 3608835056 5132349664 8227184400 : 600 6947763137 5263307273 3185606008 7806765476 3491032337 : 650 4818639519 9947798976 5496143576 0713078663 7658227890 : 700 5182753138 1518899515 6063792499 5583597838 9682252140 : 750 5876176842 2661335613 7253712755 8442444995 1099021885 : 800 7134767647 7107069051 0992854782 0084796524 1346530135 : 850 5358194569 9854672410 0288340228 5318125444 8475683595 : 900 0543750053 5668828211 7470492377 8411625840 3680909735 : 950 6478019548 0795466544 0260245141 9277318661 7863637397 : 1000
Want more?
Okay, here is 40k decimal points of pi.
If you really need more, you can alter the "40k" to "1m" in that link and get 1 million/mega digits. Warning - that's of course a 1MB download.
idxPages in this section: (sorry, still building this)
Related info:
Lorem ipsem
Still not blah?
Blah a [blah] at Blah.
Why should I even bother to put a footer here? Blah blah blah, legal mumbo jumbo and so forth. You actually read this thing? If you’re so smart, what should I put here?