• Points inside Circle: 0
  • Total Points: 0
  • Ratio: 0.00000000
  • Pi Estimate: 0.00000000
1

The formula to calculate the area of a circle is πr2. A square that perfectly encloses a circle of radius r has an edge length of 2r, or an area of (2r)2. This can be rewritten as 4r2. This means that the ratio between the area of a circle and the area of its enclosing square is πr2/4r2, which can be simplified to π/4.

We can use this knowledge to derive the value of π. Of course, to do so algorithmically, we need to already know the value of π to calculate the area of the circle. Another approach we can take is by using probability. If one shape resides inside the perimeter of another shape and a point is randomly selected inside the outer shape, the probability that that point also overlaps with the inner shape is equal to the ratio in area between the two shapes. For example, if you split a square vertically down the middle and pick a random point within it, there is a 1/2 chance that the point resides in the left half of square.

Similarly, the chance that a point chosen at random inside of a square also resides inside of an inscribed circle is π/4. If we select random points inside a square (y) and count the number that lands inside the circle (x), the proportion of x/y will converge to π/4. Therefore, we can estimate the value of π to be (x/y)*4.

Check out my blog post for more information.