PuzzleReels
Sections

Buffon's Needle

The maths · Episode 17 · 3:26 · gives the answer

The puzzle

A wooden floor of parallel planks, all the same width. A needle is dropped on it and lands wherever it lands: sometimes clear inside a plank, sometimes across the line between two. The needle is exactly as long as a plank is wide.

Drop it 1000 times and count the crossings. What fraction of the drops cross a line?

There is no circle anywhere in the room. There is a floor and a pin.

The maths, properly

Write d for the width of a plank and ℓ for the length of the needle. The verifier fixes d=1, so a length is a number of planks, and puts the seams at the whole numbers.

The model: what "at random" means

A drop is two numbers.

  • x, the distance from the needle's centre to the nearest seam. The centre is equally likely to be anywhere across a plank, so its distance from the nearer of the two seams is equally likely to be anything from 0 to d/2. It is uniform on [0,d/2].
  • θ, the angle the needle makes with the seams. Every direction is equally likely, and turning the needle half a turn changes nothing, so θ is uniform on [0,π).

The two are independent: where the centre lands tells you nothing about which way the needle points. That independence is the whole of the assumption, and the film, the verifier and the proof below all use it.

Route one: the integral

Take the seam nearest the centre. The needle runs a vertical distance ℓ2sinθ up or down from its centre (the angle is measured from the seams, so sinθ is how steeply it climbs). It reaches the seam exactly when the centre is no further away than that:

x≤ℓ2sinθ

Could it also reach the far seam? That one is at distance d−x≥d/2, and the needle reaches at most ℓ/2≤d/2. So it cannot, except on drops of probability zero, and "crosses the nearest seam" is the same as "crosses a line". This is where ℓ≤d is used.

Now the probability. The pairs (θ,x) fill a box, θ from 0 to π and x from 0 to d/2, evenly, so a probability is an area divided by the area of the box:

box=π·d2

The crossing drops are the ones under the curve x=ℓ2sinθ, the lobe in the film. Because ℓ2≤d2, the lobe sits inside the box. Its area is

∫0πℓ2sinθdθ=ℓ2[−cosθ]0π=ℓ2·2=ℓ

So

P=ℓπd/2=2ℓπd

For ℓ=d the lobe has area d and the box has area πd/2, and P=2/π. In the verifier's units that is 0.63662, and the film's "about sixty-four percent". The same sum for needles of 14, 12, 34 and 1 plank gives 0.159155, 0.31831, 0.477465 and 0.63662.

Nothing here is round, but the answer is. The π is the length of the interval of angles, since θ runs from 0 to π. A viewer is entitled to suspect that is a trick of the set-up, and route two answers it.

Route two: Barbier's noodle

Stop asking whether the needle crossed and ask how many times. Count every place where the wire meets a seam. For a straight needle that count is 0 or 1 when ℓ≤d, so its expected value is the probability. But the count also makes sense for a wire of any shape, bent however you like.

Call E the expected number of crossings of a wire dropped at a random position and angle. Three steps.

1. Crossings add. Cut a wire into two pieces. On every drop, every crossing belongs to one piece or the other, so the whole wire's count is the sum of the pieces' counts. (A seam could pass exactly through the cut, but that has probability zero.) Expectations add, so

E(whole)=E(piece one)+E(piece two)

2. The expected number depends on length and on nothing else. Dropping a whole wire at a random position and angle drops each piece of it at a random position and angle too, so a piece's E does not depend on where it sits in the wire. Look at straight pieces first. Let g(s) be the expected number of crossings of a straight wire of length s. By step 1, g(s+t)=g(s)+g(t). So g(ns)=ng(s) for whole n, and then g(s/n)=g(s)/n, so g(q)=qg(1) for every rational q. And g never decreases as s grows, since a longer wire has at least the crossings of a shorter one lying inside it. A function that is additive and never decreasing is squeezed between rationals on both sides, so g(s)=cs for one constant c.

A wire made of straight pieces, a polygon, is a sum of such pieces, so its E is c times its length. The film then treats a curve as a limit of polygons, and that last step is the standard one, not proved here:

E(any wire)=c×length of the wire

3. Find c with the easiest shape. Bend a wire into a circle exactly one plank across, so its diameter is d and its length is πd. Wherever it lands, it spans a vertical stretch of exactly d, and a stretch of length d always contains exactly one seam (apart from the drops that put one exactly on its edge). A circle meets a line it reaches in two places. So the count is 2 on every drop, with no chance left in it:

2=c·πd⇒c=2πd

The circle meets one line, in two places, which is why the film says "in exactly two places" and not "two lines".

4. Unbend it. A needle of length ℓ≤d crosses at most one line, so its expected count is its probability:

P=cℓ=2ℓπd

This is route one's answer with no integral and no angle. The π is now the ratio of a circle's length to its width. Both routes are about the same π, and the circle is not in the room: we bent it ourselves.

A needle longer than a plank

For ℓ>d the needle can meet two lines or more. Now the probability of crossing at least once and the expected number of crossings are different things, and only the second keeps its formula. By step 2, a wire of length ℓ has E=2ℓπd for any ℓ: cut it into pieces each no longer than d, and add. But

E=P(at least one)+P(at least two)+…

so once a second crossing is possible, P falls short of E.

With d=1 and ℓ>1, the chance given the angle is capped at 1, and the integral becomes

P=1π∫0πmin(1,ℓsinθ)dθ=1+2π(ℓ−ℓ2−1−sin−11ℓ)

The verifier simulates ℓ=1.5 and finds the probability 0.77901, below the formula 2ℓ/π=0.95493, and the average number of crossings 0.955661, which matches it. That is why the film prints needle≤plank.

Measuring π, and how slowly

If a fraction p=2/π of N drops cross, then the estimate is π~=2N/C=2/p~, where p~=C/N is the observed fraction (a tilde marks an estimate; the film writes it with a hat). Two facts decide how good that is.

The fraction is binomial. Each drop crosses with probability p, independently. So C has variance Np(1−p) and p~ has standard deviation p(1−p)/N.

Turn the fraction into an estimate of π. For a small error, 2/p~−2/p≈−2p2(p~−p), so the spread of π~ is 2p2 times the spread of p~. With p=2/π that is

sd(π~)≈2p(1−p)p2N=21−pp3/2·1N=2.3735N

This is an approximation that gets better as N grows (it is the first term of a Taylor expansion, often called the delta method). The verifier checks it by experiment, below.

The N is the whole story. Every drop adds an independent amount of noise of the same size. Independent noise adds in variance, so after N drops the variance of the average is the variance of one drop divided by N, and the standard deviation shrinks like 1/N. To halve the error, drop four times as many needles. To gain one more decimal digit, a tenth of the error, drop a hundred times as many.

A 95% interval is 1.96 standard deviations either side:

DropsSpread of the estimate95% half-width
1000.23740.4652
10000.07510.1471
10,0000.02370.0465
100,0000.00750.0147
1,000,0000.00240.0047
100,000,0000.00020.0005

The film's closing caveat asks how many drops it takes before the 95% half-width is under half a unit in the last digit shown. That is a rule of thumb for "sure of that digit", not a guarantee that the digit is right, but the count is exact for the rule:

DigitsDrops neededThe film says
3.18657about 8700
3.14865,672about 870,000
3.14286,567,136about 87,000,000
3.14168,656,713,593(not shown)

Each row is a hundred times the one above. Pi is in there. It is a dreadful way to find it.

A worked case: the film's drops

The film's first five drops come from the verifier's seeded generator: 4 of the five crossed a line, and one lay clear. Five drops say almost nothing, and the film goes on to a thousand.

The running count of the same run, with the estimate 2N/C at each stage. The spread is the formula's 2.3735N:

Drops so farCrossedEstimate of π
1054
30193.1579
100633.1746
3001993.0151
10006463.096

At 1000 drops the estimate is 3.096, which is -0.0456 from π. The spread at that size is 0.0751, so the error is well inside one spread and inside the 95% band of ± 0.1471. That is whatever the seed gave. If the run had landed further out the film would have said so, and the verifier only requires the estimate to sit within three spreads of π, at every checkpoint.

After the first ten drops, the running estimate was inside its 95% band at a fraction 0.999 of the stages. That is not 95% of independent trials: neighbouring stages share their drops, so they move together.

Drops 2 and 3 of the five crossed and drop 5 lay clear, which is what the narration says, and the script asserts it.

Generalising

Any width. The proof never used d=1. Scale the plank and the needle together and nothing changes, because only the ratio ℓ/d matters: the claim is 2π·ℓd.

Any wire. The expected number of crossings of a wire of length L is 2Lπd whatever its shape. The verifier drops five wires, 250,000 times each:

WireLengthExpected crossings, 2L/πAverage found
Needle10.63660.6373
Squiggle10.63660.6377
L21.27321.273
Zigzag31.90991.9092
Circle3.14159322

Every average lands on 2L/π for its own length, whatever the shape. What the shape does change is the spread of the count: 0.4808 for the needle, 0.7873 for the squiggle of the same length, and 0.021 for the circle. The circle's count barely varies (a true circle meets the lines exactly twice on every drop; the script's circle is drawn as a fine polygon, which on a very few drops grazes a line, and that is the small spread), which is what made it the easy shape to use.

Seeing a wire. Turn the claim around and it measures length. Lay a grid of parallel lines over a map, count the places a path crosses, and L≈πd2× (crossings) is an estimate of the path's length, with the same 1/N trade-off.

Checking it

scripts/needle.mjs writes this page's numbers and asserts them first.

Route one. The probability for needles of 14, 12, 34 and 1 plank is found three independent ways and compared with 2ℓ/π: a midpoint-rule integral over the (x,θ) box, Simpson's rule on 1π∫min(1,ℓsinθ)dθ (matches to 10−8), and a seeded simulation of 2,000,000 drops. For ℓ=d the simulation gave 0.636948 from 1,273,896 crossings, against 0.63662. The script also asserts that for ℓ=1.5 the probability is no longer 2ℓ/πd while the expected number of crossings still is.

Route two. A wire is bent by interpolating its tangent angles, and the script asserts its length stays exact at every stage of the bend. The circle closes and is one plank across in both directions. Cutting a wire in two adds the counts, checked on every one of 20,000 random drops per shape. Every drop of the circle meets the lines in exactly two places, in 250,000 drops and in all 200 of the film's.

The run. The film's 1000 drops are generated by a seeded generator inside the script, with seeds fixed before looking and never changed. The script recomputes every verdict from the rounded coordinates the film uses, and checks that each drop is inside the sine lobe exactly when it crossed. The spread formula is tested against repeated runs: 6000 runs of 100 needles had a spread of 0.243 (predicted 0.2374), and 4000 runs of 1000 had 0.0763 (predicted 0.0751). The 95% interval covered π in a fraction 0.9442 and 0.9425 of those runs, and the script requires it to be within a point and a half of 95%.

What is not checked. The step from polygons to curves in Barbier's argument is a standard limit and is neither proved on this page nor tested by the script. The closed form for ℓ>d is derived here and not asserted: the script only simulates that case. The delta-method formula is tested by experiment, not proved to hold exactly. The historical points below are outside the script.

Where this shows up

  • The history. Georges-Louis Leclerc, Comte de Buffon, posed the needle problem in the eighteenth century. Barbier's argument is from 1860: it is the one that makes the circle do the work.
  • Lazzarini's needle. In 1901 a result was reported of 3408 tosses with a needle five sixths of the line spacing, 1808 of them crossing. With ℓ=56d the estimate is 2ℓNdC=5N3C, and 5×34083×1808=355113, which is within a part in a million of π. That is far closer than the spread of an honest run of that size would allow, and it is widely suspected that the experiment was stopped when the count came out right. Treat it as a cautionary tale. It is a published claim, not something this page checks.
  • Integral geometry. The wire argument is the simplest case of the Cauchy–Crofton formula, which relates the length of a curve to the average number of times random lines cross it.
  • Monte Carlo. Estimating a number by random sampling gives the error 1/N seen here. It is why simulation is good for a rough answer and expensive for a precise one.

Try it yourself

1. What is the probability for a needle half a plank long?

2ℓπd=1π, or 0.31831. Half the needle, half the chance of 2/π.

2. A circle of diameter d/2 is dropped. What is the expected number of crossings, and the chance of crossing at all?

Its length is πd/2, so the expected number of crossings is 2πd·πd2=1. The circle spans a height of d/2. It has a seam inside that span with probability 12, and then it crosses twice; otherwise it crosses nowhere. So it crosses at all with probability 12, and 12×2+12×0=1, as it should.

3. A bent wire of length 2 planks is dropped. What is the expected number of crossings, and how can it be that many?

2Lπd with L=2 planks is 1.2732. Nothing says the count has to be at most one: the wire can meet several lines on one drop. The verifier's L-shaped wire of that length averaged 1.273.

4. How many drops would you need to be 95% sure of 3.14, and why a hundred times more than for 3.1?

865,672 by the film's rule, about 870,000. The spread falls like 1/N, so a tenfold smaller spread needs a hundredfold more drops, and each new digit is a tenfold smaller target.