I can hear a wag saying that you can merely look up the value of pi in Google! Fair enough, but I'm talking here about a method of actually calculating pi, from scratch, rather than simply looking up the value. The final calculation involves little more than a bit of counting followed by a multiplication operation. So, let's go.
To perform the operations I'm about to describe, you'll need a device that fires some kind of projectiles in such a way that you can clearly distinguish their points of impact. An ideal device, for example, would be a so-called air gun that fires birdshot pellets, known as BB slugs.
• Obtain a big square of white cardboard, the bigger the better, and place it flat on the ground beneath a tall tree. Make sure it doesn't move, maybe with the help of a couple of metal spikes.
• Armed with your airgun, or whatever, and a good supply of projectiles, climb up into the tree, high above the square of white cardboard... which will be used as your target. [I forgot to point out that you should probably let your neighbors know beforehand that you're conducting a scientific experiment in computing... otherwise they might become unnecessarily alarmed.]
• Now, here's the essential part of the calculation procedure. You're expected to fire projectiles (slugs, chewing gum, goo, whatever) in the vague general direction of the square of white cardboard down on the ground. Above all, you have to fire at the cardboard in a totally random fashion, without ever aiming deliberately at any particular region of the square. In other words, your projectiles are expected to produce impacts that are scattered all over the cardboard in a completely random fashion. Indeed, if ever you aimed carefully, and you were such a good marksman that all your projectiles hit the middle of the cardboard, then the method I'm describing would not work at all.
• You're expected to carry on bombarding the target with projectiles for as long as possible, until the cardboard is completely covered in impacts.
• When you've produced a huge number of randomly-located impacts (let's say, to be generous, a few tens of thousands), climb down out of the tree and examine meticulously the bombarded square of cardboard. You will have understood by now that my method of "calculating for dummies" is a little weird. Call it a thought experiment, if you prefer.
• Using a corner of the cardboard as the center, draw a circle whose radius is equal to the length of a side of the square. Your big square of cardboard should look something like this:
• Start out by counting the number of red impacts, inside the quadrant, which we shall designate as Q. Then count the total number of impacts on the cardboard square, red + blue, which we shall designate as T.
• Divide Q by T, and multiply the result by 4. This will give you a value of pi.
It's easy to understand why this counting procedure should provide us with the value of pi. Consider the ratio of the area of the quadrant and that of the square. Elementary geometry tells us that this ratio is pi divided by 4. And, provided the impacts are scattered randomly over the entire square, then we can see intuitively that Q divided by T should be a good approximation to the value of this same ratio. To put it in simple terms, the quantity of impacts in any particular zone indicates, as it were, the relative area of that zone.
The Monte Carlo method of problem solving was invented in 1947 by John von Neumann and two of his colleagues, Stan Ulam and Nick Metropolis, at the Los Alamos National Laboratory in New Mexico. A small group of brilliant scientists, many of whom had recently arrived in the USA, had come together with the intention of designing the world's first full-fledged electronic computer, named Maniac, to be used primarily as a development tool for the hydrogen bomb.
When I started work as a computer programmer with IBM Australia in 1957, the Monte Carlo method had reached the zenith of its popularity as an almost magical problem-solving approach, which fascinated all of us. Today, over half a century later, Monte Carlo computational algorithms are still in widespread use in many simulation contexts.
No comments:
Post a Comment