[Haskell-cafe] approximating pi
ry dahl
ry at tinyclouds.org
Sun Apr 27 20:31:45 EDT 2008
By picking points randomly from a square one can calculate pi. Keep
track of how many points from the square you pick lay in the inscribed
circle. Supposing the square's edges are length 2, then the inscribed
circle has radius 1. Thus the area of the circle is pi*r^2 = pi. The
area of the square is 4. The ratio of points picked from the circle
to the total number of picked points will converge to pi / 4.
What is the best way to express this algorithm in Haskell?
ry
More information about the Haskell-Cafe
mailing list