Buffon's Needle

Buffon's Needle is one of the oldest problems in geometric probability. Drop a needle on a floor of parallel lines. The chance that it crosses a line is a simple formula, and π is in it.

Needles dropped across the lines of a wooden floor, the crossings marked
Needles dropped across the lines of a wooden floor, the crossings marked

A floor of parallel lines

In 1777 Georges-Louis Leclerc, Comte de Buffon, asked a question that sounds like a parlor trick. A needle of length l falls on a floor ruled with parallel lines a distance d apart. What is the chance P that the needle lies across a line? Only two things about the fall are random. The center of the needle is equally likely to land anywhere between the lines, and the needle is equally likely to point in any direction. Sliding the picture along the lines does not change whether it crosses, so the position along a line can be ignored.

The short needle

The classic answer is for a short needle, one that is no longer than the gap: l ≤ d. Such a needle can meet at most one line, and the chance that it does is P = 2l / (πd) A handy setup takes the needle at half the gap, l = d/2. Then P = 1/π, about 0.318. A little under one throw in three is a crossing.

Where π comes from

Call x the distance from the center of the needle to the nearest line. Then x runs from 0 to d/2. Call θ the angle between the needle and the lines. A needle has no head and no tail, so θ runs from 0 to π and that half-turn already includes every direction. The needle reaches the line when x is no greater than the projection of half the needle: x ≤ (l/2) sin θ Every pair (θ, x) is a point in a rectangle of width π and height d/2. The crossings are the region under the sine curve. For a short needle that curve stays inside the rectangle. Its area is the integral from 0 to π of (l/2) sin θ dθ, which is l. Divide by the area of the rectangle, π·d/2, and the chance is 2l/(πd). The π in the formula is the width of the angle axis.

Estimating π

Turn the formula around and the same throws estimate π: π ≈ 2l · N / (d · N_hit) N is the number of throws and N_hit is the number that cross a line. With l = d/2 this is simply π ≈ N / N_hit It is a Monte Carlo estimate: draw random positions and angles, count the hits, divide. The floor shows the needles. The rectangle beside it shows the same throws as dots, under the sine curve when they cross and above it when they miss.

A patient experiment

The estimate is unbiased, and it is slow. Each throw is a yes or a no with a chance near 1/π, so the ratio wanders for a long time. A few thousand throws usually make the first digits recognizable as π. The next digit asks for a much larger count. The ± next to the readout is one standard error of that ratio, a measure of how far a run of this length typically still sits from the true value. Buffon's Needle is a direct link between a ruled floor and a circle. It is a poor machine for computing digits of π.

Explore it in PictorX

Open Buffon's Needle and the half-needle experiment is already falling: l/d = 0.50, so the readout is throws divided by crossings. Floor and diagram shows the boards and the sine rectangle together. Drag on the floor to lay one needle by hand and read its x and its angle. That needle is drawn and left out of the count, so the estimate stays a random sample. Full gap sets l = d, where π ≈ 2N / N_hit. Short needle sets l = d/4. 1,000 throws drops a batch and pauses so you can read the estimate. The sine diagram favorite hides the floor and fills the rectangle. Save a PNG, or open the canvas in the PictorX editor. Pair it with the Ulam spiral or the Collatz Conjecture for more mathematics you can watch.

Frequently asked questions

Who posed Buffon's Needle problem?

Georges-Louis Leclerc, Comte de Buffon, in 1777. It is one of the first problems in geometric probability.

When does the needle cross a line?

When the distance x from its center to the nearest line is at most (l/2) sin θ. Here θ is the angle between the needle and the lines, from 0 to π.

Why does the answer contain π?

The needle's direction is an angle. All possible falls fill a rectangle that is π wide and d/2 tall, and the crossings are the area under a sine curve. Dividing those two areas leaves π in the denominator: P = 2l/(πd) for a short needle.

How many throws does a stable estimate take?

With the needle at half the gap, π is about throws divided by crossings. A few thousand throws usually settle the first digits. Another digit takes a much larger count. The ± on the readout is one standard error of the estimate.

What if the needle is longer than the gap?

A longer needle can cross more than one line, and P = 2l/(πd) no longer holds. This app keeps l ≤ d, so the estimate stays π ≈ 2l·N / (d·N_hit).

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Try Buffon's Needle