This page uses the Monte Carlo method to estimate the value of pi. Points are plotted at random in the square on the left and their distance from the centre of the square calculated. If the points are closer to the centre than half the width of the box then they are coloured red.

If we take *r* to be the radius of the circle, then the area of
the circle is *πr²* and the area of the square is *(2r)²*, which is
*4r²*. The ratio of the two areas is therefore *πr²:4r²*
or *π:4*, so dividing the number of red dots by the total number of
dots and multiplying by four gives an estimate of the value of *π*.

*Number of points plotted*:

*Number of points inside the circle*:

*Estimated value of *π:

NB. A potentially more accurate estimate might be obtained by plotting a quadrant, but this page is a demonstration of the principle and the maths is simpler with a full circle.