# Buffon Needle Problem

This module simulates the Buffon needle problem, which approximates π by a random process. In the Buffon needle problem, an approximation to π is calculated by repeatedly dropping a needle onto a plane surface ruled with equally spaced parallel lines. A hardwood floor with its dividing seams makes an appropriate surface, though for a floor, dropping toothpicks instead of needles is recommended. Given such a surface, consider an (x, y) coordinate system with the x axis parallel to the lines. The probability that a needle intersects one of the lines on the surface is independent of its x coordinate; only the y coordinate of the needle's center and the angle θ that the needle makes with the x axis affect whether the needle intersects a line. For simplicity, suppose that the length of the needle is equal to the distance between two adjacent lines on the ruled surface and take this as the unit distance. Using symmetry, we can limit our attention to values for θ in the interval [0, π ⁄ 2) and values for y in the interval [0, 1 ⁄ 2). We suppose that the values of θ and y are uniformly distributed on their respective intervals, so it suffices to determine the proportion of the θ-y rectangle for which the needle intersects a line. A needle touches a line precisely when y ≤ sin(θ) ⁄ 2. Therefore, the area under the curve sin(θ) ⁄ 2 on the interval 0 ≤ θ < π ⁄ 2 divided by the area of the entire rectangle gives the probability that the needle intersects a line. This comes out to (1 ⁄ 2) ⁄ (π ⁄ 4) = π ⁄ 2, so the approximate value for π is 2nm, where n is the number of trials and m is the number of trials for which the needle intersects a line.

Here the Buffon needle problem is simulated numerically and graphically. The left part of the display shows a surface ruled with parallel lines, and by clicking the buttons the user may drop 1, 10, or 100 unit-length needles onto the surface. Needles that intersect a line are drawn in red and needles that fail to intersect any line are drawn in blue. Counters display the current values of n and m and the corresponding approximation to π. Clicking Reset clears the surface and resets the counters to zero.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Computer Problem 13.9 on page 520.

Developers: Evan VanderZee and Michael Heath