Java Reference
In-Depth Information
Figure 6-1. Circle within a square
If you close your eyes and keep stabbing at the diagram repeatedly with a pencil, you may end up with something
like Figure 6-2 (considering only the dots that fall within the diagram).
Figure 6-2. Circle within a square after stabbing with pencil
Note that some dots fall inside the circle and some fall outside the circle. If the dots were made “at random,”
it seems reasonable to expect that the number of dots inside the circle is proportional to the area of the circle—the
larger the circle, the more dots will fall inside it.
Based on this, we have the following approximation:
area of circle
number of dots inside circle
=
area of square
number of dots inside square
Note that the number of dots inside the square also includes those inside the circle. If we imagine the entire square
filled with dots, then the previous approximation will be quite accurate. We now show how to use this idea to estimate p.
Consider Figure 6-3 .
S
(1, 1)
(0, 1)
C
(0, 0)
(1, 0)
Figure 6-3. Quarter circle and a square
C is a quarter circle of radius 1; S is a square of side 1.
π Area of S = 1.
Area of C =
4
A point (x, y) within C satisfies x
2 + y 2 £ 1, x ³ 0, y ³ 0.
A point (x, y) within S satisfies 0
£ x £ 1, 0 £ y £ 1.
 
Search WWH ::




Custom Search