## Calculating Pi Terribly

I’m not really a fan of Pi Day. I’m not fond of the 3/14 format for writing dates to start with — it feels intolerably ambiguous to me for the first third of the month — and it requires reading the / as a . to make sense, when that just is not how the slash works. To use the / in any of its normal forms then Pi Day should be the 22nd of July, but that’s incompatible with the normal American date-writing conventions and leaves a day that’s nominally a promotion of the idea that “mathematics is cool” in the middle of summer vacation. This particular objection evaporates if you use . as the separator between month and day, but I don’t like that either, since it uses something indistinguishable from a decimal point as something which is not any kind of decimal point.

Also it encourages people to post a lot of pictures of pies, and make jokes about pies, and that’s really not a good pun. It plays on the coincidence of sounds without having any of the kind of ambiguity or contrast between or insight into concepts that normally make for the strongest puns, and it hasn’t even got the spontaneity of being something that just came up in conversation. We could use better jokes is my point.

But I don’t want to be relentlessly down about what’s essentially a bit of whimsy. (Although, also, dropping the ’20’ from 2015 so as to make this the Pi Day Of The Century? Tom Servo has a little song about that sort of thing.) So, here’s a neat and *spectacularly* inefficient way to generate the value of pi, that doesn’t superficially rely on anything to do with circles or diameters, and that’s probability-based. The wonderful randomness of the universe can give us a very specific and definite bit of information.

Suppose that you have a floor with a set of uniformly spaced parallel lines across it. And suppose that you have a short stick, like a needle or toothpick or match, which is not as long as the lines are apart. If you have a great deal of patience, and are able to drop the needle repeatedly so that there’s no predicting where on the floor it’ll land, and what angle it’ll make relative to the parallel lines, then you can work out the value of pi. In principle, you can work it out to as many decimal places as you want, although in practice, you’re a crazy person to try it.

But here’s how. Suppose that the parallel lines are each a length from their nearest neighbors. And suppose the needle (toothpick, match, whatever) is some shorter length . If you drop the needle a grand total of times, and if the needle crosses the lines some of those times, then the value of pi is estimated by

This little problem of dropping things on floors is known as Buffon’s Needle Problem, Buffon in this case being Georges-Louis Leclerc, Comte de Buffon, the 18th-century naturalist and mathematician and encyclopedia-writer. In mathematics he’s known for advancing the study of probability, particularly in bringing calculus into it. In cosmology he’s known for proposing the idea that planets were formed when comets collided with stars, which is not generally accepted these days, although it was a strong rival to the condensing-nebula idea we now take to be so. He also noted, based on experiments with how spheres of iron cooled, that the Earth had to be considerably more than a mere six thousand years old. He only estimated the age of the world to be about 75,000 years, but it’s hard to discover Deep Time except incrementally, and the problem of the flow of heat into and out of the Earth would be critical to the 19th-century struggle between geologists and physicists about how old the Earth could be. As a naturalist he’s regarded as one of the forerunners to modern evolutionary theory; as an anthropologist he’s known with a fair amount of embarrassed coughing and attempts to place him in historical context.

Nevertheless, I find this needle-dropping result to be wonderful. It shows one of the strange truths about probability, which is that pure randomness carries predictability within it. You can know with certainty the result of a group of many experiments even though you cannot predict the result of any one of them. If a falling needle can be said to have liberty, it has it; we do not need to know any details of its plummet, much less do we need to control it, to know something precise about what happens in uncountably many trillions of unique needle-drops.

That said, *why* is this such a terrible method of finding pi? Besides the problem of cleaning up the floor after all these needle-drops, the method is very much like working out the value of 1/2 by flipping a fair coin and counting the number of tails that come up compared to the number of flips. While the average of the number of tails to the number of flips will tend toward 0.5, and get closer to it the more flips you try, after any finite number of flips the number of tails will probably be a little high or a little low of the “true” value. This variation is unavoidable. The variation will shrink as the number of attempts grows, but it can’t be counted on to drop to zero unless you do infinitely many flips.

The University of Illinois’s Office for Mathematics, Science, and Technology Education has a pretty nice, Javascript-and-HTML5-based, simulator and you can try tossing down thousands of needles of any length up to the line spacing, and see what estimate of pi you come up with.

We can work out an error estimate, and we can use that to say how many needle drops we can expect to need to do if we want, say, two decimal digits of accuracy. Sadly, the formula requires the actual value of pi in the right-hand side of the formula so there’s a bit of a bootstrapping problem here. (Well, we could use a preliminary estimate of pi to help us figure out how much work would be needed to make a better estimate.) If the length of the needle is shorter than the distance between lines , then to get an estimate of pi that’s not any more than away from the true value implies the number of needle-drops has to be big enough that

If the needle length is half the spacing between parallel lines, this works out to approximately and you see how really huge numbers of needle-drops are needed if you want the error margin E to be all that small. To have an error margin smaller than 0.005 implies running over 3,380,000 needle-drops.

Now, that you need a huge number of needle-drops to be *sure* the error is small doesn’t mean that you can’t get lucky. But if you truly didn’t know the value of pi beforehand, you wouldn’t know to stop when your running total got lucky, and while you might after a couple million needle-drops feel pretty sure you had got the “3.14” part of pi down I daresay you aren’t going to keep on doing needle drops to try getting the next digit after that.

This is, though, an example of the ways that probabilistic methods can be used to give reliable and true results. These kinds of probabilistic methods are described by many terms: “stochastic” is a popular one, and “Monte Carlo” another, and yes, that name derives from the famed casinos. Probabilistic approaches tend to make it possible to study problems using experimental methods that are not hard — there’s nothing tricky about dropping a needle and seeing if it crosses a line, once you’ve decided what to do in case the end of the needle touches but doesn’t cross over the line — but they do tend to require a lot of simple work. As a result, they’re usually best done in computer simulation. This presents a subtle but real problem of how to produce random results on a machine that follows algorithms precisely, but that’s a grand set of problems on its own.

## abyssbrain 10:28 am

onSaturday, 14 March, 2015 Permalink |When I first read about this method for calculating pi before, I have entertained the idea of trying it myself but I quickly discarded that idea, since who knows how long it would take before I would reach pi :)

Btw, I’m also very confused with the American way of writing dates since I’m used to either ddmmyyyy format or yyyymmdd format. So, March 14, 2015 for me is 14/3/2015. I’ve also just posted some of my reasons why I don’t celebrate pi day…

LikeLike

## Joseph Nebus 12:25 am

onMonday, 16 March, 2015 Permalink |Oh, it would just take forever to find pi using needles and ruled lines. You’d do considerably better if you drew a quarter-circle on a square dartboard, and tossed darts at it, counting the ratio of darts that hit inside the quarter-circle to darts outside. At least you’d have a better night of it.

I don’t know why the United States uses the month-day-year format, particularly since it hasn’t got much (any?) use elsewhere in the world. My

suspicionis that there probably was a time when both month-day and day-month were common enough in English-speaking nations and the United States settled on one format while the United Kingdom another back in the 19th Century back when stuff standardized.LikeLike

## abyssbrain 1:08 am

onMonday, 16 March, 2015 Permalink |Well, it seems widespread because of US websites like Google use mmddyyyy format by default and most of the top sites are from the US…

Though I have noticed that they are now slowly changing the date format of many wikipedia articles to ddmmyyyy format.

LikeLike

## Joseph Nebus 9:05 pm

onTuesday, 17 March, 2015 Permalink |I have noticed what looks like a slow shift in american use to day-month-year format, at least when the month is given its proper name rather than a number. The year-month-day order seems irresistible if you’re determined to stick to writing things as digits, for reasons I have to agree are pretty solid.

Anyway, there does seem to be something logical about sticking to one logical path about whether the thing written first should be the thing most likely to change and the thing written last the least likely, or the other way around.

LikeLiked by 1 person

## LFFL 6:09 pm

onSaturday, 14 March, 2015 Permalink |See. I opened this blog after avoiding it for such a long time and my headache started instantly! The agony.

LikeLike

## Joseph Nebus 12:26 am

onMonday, 16 March, 2015 Permalink |Aw, dear. If it helps any I should have a fresh comic strips review in the next day or so. That’s nice and friendly.

LikeLike

## LFFL 12:53 am

onMonday, 16 March, 2015 Permalink |:)

LikeLike

## My Mathematics Blog, As March 2015 Would Have It | nebusresearch 7:34 pm

onWednesday, 1 April, 2015 Permalink |[…] Calculating Pi Terribly, my semi-ironic contribution to the Pi Day Of The Century. I’ve actually got a couple follow-ups to that to post when I have the time to write them. […]

LikeLike

## Calculating Pi Less Terribly | nebusresearch 7:06 pm

onSunday, 17 May, 2015 Permalink |[…] Back on “Pi Day” I shared a terrible way of calculating the digits of π. It’s neat in principle, yes. Drop a needle randomly on a uniformly lined surface. Keep track of how often the needle crosses over a line. From this you can work out the numerical value of π. But it’s a terrible method. To be sure that π is about 3.14, rather than 3.12 or 3.38, you can expect to need to do over three and a third million needle-drops. So I described this as a terrible way to calculate π. […]

LikeLike

## Terrible And Less-Terrible Things with Pi | nebusresearch 4:01 pm

onSunday, 13 March, 2016 Permalink |[…] Calculating Pi Terribly, in which I show a way to work out the value of π that’s fun and would take forever. I mean, yes, properly speaking they all take forever, but this takes forever just to get a couple of digits right. It might be fun to play with but don’t use this to get your digits of π. Really. […]

LikeLike