Life of Pi (π): Calculating its Value
Recently, there were many headlines celebrating how we’ve managed to calculate pi to the 100 trillionth digit:
If you prefer reading, A Fun Look at How to Calculate the Value of Pi is the article version of the above video that covers similar content.
With that said, let’s get to what I want to talk with you about. Depending on how deep you went into mathematics in your career or schooling, you may have seen equations that look a bit like this:
The sigma (Σ) character in our equation is our for loop, and the terms following the sigma character make up the body of our for loop.
When this code runs, what we eventually get is a value that is almost identical to what we would get if we used
Math.PI directly. The only difference is that we did a lot of heavy lifting to calculate pi in the first place, and this heavy lifting primarily involved putting loops, console log statements, functions, and mathematical operators in their right places. Nothing too heavy at all! 🧠
How about you?
Having our computers solve complicated math problems is nothing new. Number crunching was one of the earliest jobs our computers and their predecessors did. Digging into something like my exercise in calculating pi, I realized that they are still very good at crunching numbers - even if the direct work they do there is abstracted away by many layers of UX goodness where writing formulas is replaced with point/click/tap gestures.
Let me turn this around now. When was the last time you had to do something with your computer that falls into the realm of “math-heavy computation”? Reply to my tweet or create a thread on the forums…like the days of yore!
Of course, I always enjoy hearing from readers like you! Please feel free to ping me, and I’ll get back to you ASAP.
Thanks for reading! Subscribe for free to receive new posts. Also, don’t forget to follow me on Twitter for more bite-sized updates!