Pi estimate:

Number of points:

What is going on?

This is the Monte Carlo method of estimating a value for pi. You can take a circle (radius of \(r\)) inscribed within a square (side length \(2r\)), as shown above, and consider their two areas. The square has area \((2r)^2\), or \(4r^2\), and the circle has area \({\pi}r^2\). Therefore, the ratio of the area of the circle to the area of the square is \({\pi}r^2:4r^2\), which can be simplified to \({\pi}:4\). This means that, if we place points randomly inside the square and count how many of these are also inside the circle, we can use the ratio of the number of points inside the circle to total number points to find an estimate of \({\pi}\).