How to Estimate Pi with Monte Carlo Methods, Part 2
Learn how to estimate the decimal digits of the number pi from a fun arts-and-crafts style project that uses an amazing math technique called a Monte Carlo method.
Jason Marshall, PhD
Listen
How to Estimate Pi with Monte Carlo Methods, Part 2
By the time we got to the end of the last article, we had learned several fun facts about pi. First, that pi is an irrational number. Second, that we can think of pi as being the number you get when you divide a circle’s circumference by its diameter. And third, that we can alternatively think of pi as being the area of a unit circle. In addition to these things, I left you with a small pi-related mystery to think about: How can we accurately estimate the decimal digits of pi? Your wait to find out is finally over because today we’re going to learn how to do exactly that using something called a Monte Carlo method.
Recap: What is the Meaning of Pi?
As we learned in our first article about pi, the value of pi is the number you get when you divide the circumference of a circle by its diameter. When we did our experiment to discover this, we found that pi has to be a little larger than 3. Measured more carefully with a ruler, we found that pi is actually closer to 3.1, and even more accurately 3.14. But it was hard to discover any more of pi’s infinite number of non-repeating decimal digits (which we know it has since it’s an irrational number) without a better technique.
Which is precisely why we introduced the alternative interpretation in which pi is the area of a unit circle. To understand this we need to know that the area of a circle is π x r^2 and that a unit circle is simply a circle whose radius is equal to 1. To be clear: both of the interpretations of the meaning of pi we’ve talked about are correct. This isn’t a case of one or the other, it’s a case of two ways to look at the same thing. Now, with all that in mind, we’re finally ready to tackle the problem of estimating pi’s value.
More Pi-Inspired Arts-and-Crafts
To find the digits of pi, we’re going to do another hands-on arts-and-crafts style experiment that you can try at home. To do the experiment you’ll need some chalk, a piece of string, a ruler, and a few handfuls of small relatively heavy things like grains of rice or popcorn kernels. Take all of this outside and find a sidewalk, driveway, or patio that you can write on with chalk that’s at least a couple of feet wide. Use your ruler and draw a square with sides that are each 2-feet long. Next use your string to draw a circle inside this square so that the circle just barely intersects each side. If you need help figuring out how to do this, check out the article for our previous pi-related arts-and-crafts project for details.
Now that you’ve finished drawing your square with a circle inside it, you’re ready to move on to the next step. Take a few handfuls of rice or popcorn and scatter them randomly all over your drawing. The key here is to do this really randomly. You’ll want to drop them from a little above the ground so they have a chance to bounce around and settle, and you’ll want to be sure to move your hand around a bit so you’re dropping them over different parts of the drawing. If some grains end up outside the square, you can pick them back up and randomly drop them inside again.
How to Estimate Pi
Believe it or not, at this point you’re almost done with your estimate of pi. All you have to do now is count up the number of grains that ended up inside the circle and the total number of grains that you dropped into your drawing. Then, using a calculator if you’d like, divide the number of grains inside the circle by the total number of grains within the drawing, and multiply this by 4. What does that give you? Well, let’s think about it.
First, what’s the area of the square? Well, since the sides of the square are each 2-feet long, the area must be 2×2=4 square-feet. How about the area of the circle? The area of a circle is π x r^2 and since the radius of our circle is half the length of a side of the square—in other words it’s 1 foot long—the area of the circle must be π x 1^2 or π square-feet. If we divide the area of the circle by the area of the square we get the number π / 4. If we then multiply this by 4, we get π. So the number of grains of rice in the circle divided by the total number of grains times 4 gives you an estimate of the actual value of π.
What Are Monte Carlo Methods?
But why does this work? The key thing to understand is that the number of grains of rice that landed in the circle divided by the number of grains that landed within the entire drawing must be approximately the same as the ratio of the area of the circle to the area of the square—which is π / 4. If this is confusing, imagine laying out grains of rice side-by-side over the entire drawing so that every last bit of space is filled up. In that case the number of grains of rice in the circle and square are simply the areas of the circle and square measured in “rice-grain-areas,” so the ratio of the two numbers must be the ratio of the areas. Once you understand this, it should be fairly clear that the grains in the circle divided by the grains in the square must be approximately equal to π / 4…and thus that you’ve estimated pi!
It’s interesting to note that this alternative method of completely filling up the entire area with grains of rice and then counting them will actually give a more accurate estimate of pi than the method of randomly scattering the grains that we used. In fact, if you used something really tiny like grains of sand to do this experiment you’d get an even more accurate estimate. So why didn’t we fill up the entire area…or use sand? Because our experiment with randomly strewn grains of rice is a lot easier to do and much less time consuming. Imagine laying out all those grains of sand or rice side-by-side and counting them up…that could literally take days! But using a smaller number of grains and assuming that randomly distributing them will give a pretty good estimate of the true value can be done in just minutes.
Wrap Up
And that’s the essence of what’s called a Monte Carlo method. Why Monte Carlo? Because just like gambling at the famed Monte Carlo Casino, the outcome of our experiment relies upon chance and randomness. We don’t have time to go into all the details of Monte Carlo methods right now (we’ll talk more about them in the future), but the fact that it’s possible to come up with a fairly accurate estimate of pi using the experiment described today attests to their power.
Okay, that’s all the math we have time for. Remember to become a fan of the Math Dude on Facebook where you’ll find a new featured number or math puzzle posted every weekday. And if you’re on Twitter, please follow me there too. Finally, if you have math questions, feel free to send them my way via Facebook, Twitter, or by email at mathdude@quickanddirtytips.comcreate new email.
Until next time, this is Jason Marshall with The Math Dude’s Quick and Dirty Tips to Make Math Easier. Thanks for reading, math fans!
Image courtesy of Shutterstock