Scientific Computing

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*)*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
*π* ⁄ 2)*y* in the
interval *θ* 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*θ*) ⁄ 2*θ* < *π* ⁄ 2*π* ⁄ 4) = *π* ⁄ 2*π* is 2*n* ⁄ *m*, 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