Estimating Pi for Pi Day!

circle dartboard

As it was Pi Day on Tuesday (14th of March is 3.14 in American style date!) we thought we would try and estimate the value of Pi by simulating throwing darts randomly at a square dartboard like below and seeing how many land inside the circle.

One way to do this is to generate a random point by typing the following in the input bar.

(RandomUniform[-1, 1], RandomUniform[-1, 1])

This will generate a point with x coordinate inbetween -1 and 1 and y coordinate inbetween -1 and 1.

Then right click on the point and select “Trace On”.

In the View menu there is a command called “Recompute All Objects”. The shortcut for this is to hold down Ctrl and press R.

You should see your random point going to different places in the screen. You can do this say 80 times.

Alternatively, you can create 80 points on a spreadsheet with the Random Uniform command and then “Create List of Points”. See here for a working applet with this method.

Either way you can now estimate the value of Pi!!!

Count the number of points inside the circle
Divide this by 80 to get the proportion of points that are inside the circle.
Area of the circle is π * 1² = π
Area of square is 2*2=4
So this proportion should be π/4.
So if we multiply our proportion by 4 we get an estimate for π.

The more points you use the better the estimate will be.

Good luck, and happy Pi Day!

Leave a Reply

Your email address will not be published. Required fields are marked *