ôô

# How to Estimate Pi with Monte Carlo Methods, Part 1

Hot on the heels of our celebrations of the number pi on March 14, today we’re going to learn how to estimate the value of pi using an amazing math technique called a Monte Carlo method.

By
Jason Marshall, PhD,
March 16, 2012
Episode #098

The math we’re going to talk about in the next few articles is quite simply amazing. Seriously, I’m not just saying that to hype it up…it’s true. Sometimes math can seem a little magical and that’s certainly an apt description for the technique known as a Monte Carlo method (even the name sounds cooler than your average bit of math, right?). And hot on the heels of pi day celebrations on March 14, the best part of the next few articles is that not only are we going to learn about Monte Carlo methods, but we’re also going to learn about how to use them to estimate the value of everyone’s favorite mathematical constant – pi.

## What is the Meaning of Pi?

As we learned in our arts-and-crafts inspired article about pi, the value of pi is the number you get when you divide the circumference of a circle—and remember this can be absolutely any circle—by the circle’s diameter. You probably learned this in school by memorizing the formula: C = π x D. If you turn this formula on its head by dividing both sides by the diameter of the circle, D, you’ll see that it also says that: π = C / D…which is really no big surprise since that’s exactly what we just said!

When we did our experiment to discover this meaning of pi the old-fashioned way—using a pencil, a piece of paper, and some string—we saw that the value of pi has to be a little bigger than 3. With some effort and the introduction of a ruler, we could have done a bit better and figured out that pi was actually closer to 3.1. And if we were really super persistent, we could have found that it was even closer to 3.14. But no matter how hard we try, it would be really difficult to use our stringy experiment to measure the value of pi much more accurately than this. But what if that’s exactly what we want to do? Are we out of luck or is there perhaps another way?

## Is Pi an Irrational Number?

And the answer is of course there’s another way (this would be a rather anti-climactic series of articles otherwise!). But before we get to that other way, I should mention a fun-fact about pi that thus far has gone unsaid: pi is an irrational number. As you’ll recall, that means that the decimal digits of pi go on and on forever without ever beginning to repeat a predictable pattern. So, in truth, our effort here to accurately find the value of pi is ultimately doomed to fail since it can’t actually be represented using a finite number of decimal digits. But that doesn’t mean we can’t come up with more and more accurate estimates by finding more and more of those decimal digits. So that’s exactly what we’re going to do!

## What Is the Area of a Circle?

The better way of estimating the value of pi that I mentioned before requires us to rethink everything we’ve said about the meaning of pi. I know that might sound drastic but don’t worry—we’re not actually abandoning the meaning that we came up with before. What we’re doing is thinking about another—equally valid—meaning of pi. And the good news is that just as you most likely learned about the first meaning of pi in school—that’s the meaning that says that pi is equal to the circumference of a circle divided by its diameter—you probably learned this second alternative meaning in school too.

So what is it? Well, do you remember how to find the area of a circle? We aren’t going to go into all the details right now, but all you really need to know is that the area of a circle is equal to the number pi times the square of the circle’s radius. In other words: A = π x r^2. Sound familiar? Okay, but how does this formula for a circle’s area help us find the decimal digits in the value of pi? Well, let’s think for a minute about the very special circle called the “unit circle” whose radius is 1. What’s the area of a unit circle? Since the radius, r, is equal to 1, the area of a unit circle is A = π x 1^2 = π. So a unit circle has an area equal to pi. Or, put another way, we can define pi as the area of a unit circle.

## What Are Monte Carlo Methods?

But how does that help? And what do those super amazing Monte Carlo methods have to do with any of this? And, while we’re at it, how can we use all of this to estimate the value of pi to as high a precision as we’d like? Well, unfortunately we’re all out of time for today. Which means the answers to these questions will have to wait until next week. In the meantime, think about the problem and see if you can come up with any ideas. Then be sure to check back next week for the very clever and very cool solution.

## Wrap Up

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.com.

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