Back
Quside Blog
Monte Carlo Method and Pi Approximation Day

22 de julio de 2021
Contact

# Monte Carlo Method and Pi Approximation Day

Pi (π) is probably one of the most recognizable and relevant constants in mathematics. Defined as the ratio between the perimeter of a circle and its diameter, its importance both in geometry and in other fields such as physics, architecture, or engineering is such that, since ancient times, we humans have sought methods to calculate its value, even in an approximate way. It’s not surprising that people decided to celebrate 22/07 as Pi’s approximation day.

As time passed, we have progressed from very crude approximations (such as the Babylonians’ π ≈ 3, which also appears in the Bible) to extraordinarily powerful formulas, such as those proposed by Ramanujan, whose methods, when combined with today’s computers, allow us to know the first 50000000000000 digits of π. Along the way, we have come across useful approximations such as Archimedes’ π ≈ 22/7, which gives rise to this day’s celebration, or Ptolemy’s π ≈ 377/120. We have even seen attempts to legislate the real value of Pi as one of these approximations, as π ≈ 16/5!

We at Quside, as random number lovers, enjoy using another method to calculate π: we warmly call it “The Pepperoni π-zza method”, although some will recognize it better by its regular name: the Monte Carlo method. ?

To calculate π using this method, we take a pizza in a box and start throwing pepperoni slices randomly into the box: the more we throw, the better (the more accurate the calculation and the better the pizza will taste). When we get enough, we count how many slices have fallen on top of the pizza: if we have done it right, the ratio between the number of pepperoni slices on the pizza and the total number of slices used is close to π/4.

The more slices we throw, the closer we get to the real value of Pi: here are some examples of how we get closer and closer the more slices of pepperoni we put on the pizza.

Pizza 1: π ≈ 12/15 x 4 = 3,2
Pizza 2: π ≈ 25/32 x 4 = 3,125

Using a Monte Carlo method to calculate an ultra-precise value of π is rare anyway. However, these tools are widely applied today in countless areas: logistics, finance, insurance, medicine, physics, engineering, … in all of them, a fast and reliable source of pepperoni random numbers, such as the ones we manufacture and sell at Quside, is essential to solving the problems that their users must deal with every single day.

Get to know Quside’s QRNG now, and, in between simulations, you can enjoy Pi’s approximation day by making a nice pizza “à la Monte Carlo”.