B |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Let's look at the unit circle (radius=1) within a square with sides equal to 2 (see figure). Now if we pick a random point (x,y) were both x and y are between [-1,1], the probability of that this random point lies inside the unit circle is given as the proportion between the area of the unit circle and the square: |
Output: N PI Error ------------- --------- ---------- 10 3.200000 0.058407 100 3.120000 0.021593 1,000 3.156000 0.014407 10,000 3.166800 0.025207 100,000 3.138880 0.002713 1,000,000 3.141920 0.000327 10,000,000 3.140899 0.000694 100,000,000 3.141710 0.000117 1,000,000,000 3.141604 0.000012 |