Buffon's Needle Calculator

Find the chance that a dropped needle crosses a line, and estimate pi from a simulated set of drops.

Math and PercentUpdated 2026-11-183 min read
Buffon's Needle Calculator
Leave at the default if you only want the theoretical probability.
Crossing probability
...
As a percentage...
Value of pi...
Pi from your trial...

What it does

Buffon's needle is one of the oldest problems in geometric probability. It was stated in 1777 and asks a question that sounds almost trivial: if you drop a needle onto a floor marked with equally spaced parallel lines, what is the chance that it lands across a line? The surprising answer involves pi, which is why the experiment became a classic way to estimate that constant by hand.

The shortest version assumes the needle length L is no greater than the line spacing d. A drop is described by two numbers: the distance from the needle centre to the nearest line, and the angle the needle makes with the lines. The needle crosses when that distance is small enough compared with the projected half length. Averaging over all positions and angles gives the probability 2L over pi d.

When L equals d the formula reduces to 2 over pi, roughly 0.6366. The University of Illinois MSTE page walks through the geometry for this case and then discusses the other two cases. ProofWiki states the general short needle result and gives the proof by integrating the cosine of the angle over the range of possible angles.

If the needle is longer than the spacing it can cross more than one line, and the simple formula no longer applies. The correct probability for that case uses the arcsine term from the full integral. This tool implements both branches and switches automatically based on the two lengths you enter.

The experiment is also a useful lesson in sampling. If a fraction f of N drops cross a line, then f is approximately 2L over pi d, so pi is approximately 2L divided by f d. With only a few hundred drops the estimate wanders noticeably, which is exactly what you should expect from a random trial.

How to use

  1. Enter the length of the needle in any unit you like.
  2. Enter the distance between the parallel lines in the same unit.
  3. Read the theoretical crossing probability and its percentage form.
  4. If you have run a real or simulated experiment, enter the number of drops.
  5. Enter the number of those drops that crossed a line.
  6. Compare the pi estimate with the true value to see how close your trial came.

Formula

For L <= d, P = 2L / (pi d). For L > d, P = 1 + 2L/(pi d) - (2/(pi d))(sqrt(L^2 - d^2) + d asin(d/L)). The trial estimate is pi = 2 L N / (h d), where N is drops and h is crossings.
P
Probability that a single drop crosses at least one line.
L
Needle length, in any unit consistent with d.
d
Distance between adjacent parallel lines, in the same unit as L.
N
Number of drops in the trial.
h
Number of drops that crossed a line.

The short needle derivation assumes the needle centre is uniformly distributed between lines and the angle is uniform. The long needle case comes from integrating the minimum of the line spacing and the projected needle length. Because only the ratio L over d appears, you never need to convert units as long as both lengths use the same unit. Set the number of drops to 1 and crossings to 1 if you do not want an experimental estimate, and the tool will show a pi estimate based on that single idealised result.

Worked example

Example: needle length equals line spacing

Defaults: L = 1, d = 1, with 1000 simulated drops and 637 crossings.

  1. The needle is not longer than the spacing, so use the short needle formula P = 2L / (pi d).
  2. Substitute L = 1 and d = 1: P = 2 / pi = 2 / 3.14159 = 0.6366.
  3. As a percentage that is 63.66 percent, so about 637 of 1000 drops should cross a line.
  4. The observed 637 crossings give f = 637 / 1000 = 0.637.
  5. Rearrange to estimate pi: 2 x 1 x 1000 / (637 x 1) = 2000 / 637 = 3.1397.
  6. That is close to the true pi of 3.1416, with the small gap due to random sampling.
  7. The tool shows 0.6366, 63.66 %, 3.1416 and 3.1397.

Reference table

Crossing probability for different needle to spacing ratios
L / dNeedle caseCrossing probabilityEstimate quality
0.25Short0.1592Needs many drops
0.50Short0.3183Moderate
1.00Short0.6366Good
2.00Long0.8372Good, can cross twice

Limits

  • Assumes perfectly parallel, infinitely long lines and a uniformly random drop.
  • Real needles have thickness and finite floors, which add small biases to a physical experiment.
  • The pi estimate converges slowly, so small trials give noisy answers.
  • The long needle formula gives the chance of at least one crossing, not the expected number of crossings.

Common mistakes

  • Using the short needle formula when the needle is longer than the spacing.
  • Mixing units for needle length and line spacing.
  • Entering more crossings than drops, which the tool rejects with an error message.
  • Expecting a few hundred drops to give pi to several decimal places.
  • Confusing the probability of crossing with the probability of missing.

Try it yourself

Quick checks. Answers sit tucked under each question.

A needle half as long as the line spacing. What is the crossing probability?

With L / d = 0.5, P = 2 x 0.5 / pi = 1 / pi = 0.3183, or 31.83 percent.

Now the needle is twice the spacing. What is P?

The long needle branch applies. The calculation gives P = 0.8372, so roughly 84 percent of drops cross at least one line.

With L = 1, d = 2, 500 drops and 159 crossings, what pi estimate appears?

The probability is 2 / (2 pi) = 0.3183. The estimate is 2 x 1 x 500 / (159 x 2) = 3.1447.

Questions

Why does pi appear in a needle problem?

The angle of the needle is uniformly distributed over a range measured in radians, and integrating over that range introduces pi into the denominator.

What happens when the needle is longer than the spacing?

It can cross two lines in one drop. The probability uses an arcsine term and this tool applies it automatically.

Is this a good way to calculate pi?

It is a memorable demonstration of probability, but it converges slowly. Modern algorithms are far more efficient.

Do the units matter?

Only the ratio of needle length to spacing matters. Any consistent unit gives the same probability.

Should I drop the needle by hand?

You can, but a computer simulation gives far more trials with less bias. Use the same random assumptions for position and angle.

Why might my estimate be slightly off?

Random variation. With 1000 drops the estimate typically lands within a few thousandths of pi, and smaller trials wander more.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.