sqrt(x ˆ 2 + y ˆ 2) < rsince the radius is 1.0, we can square both sides and avoid a sqrt() computation:
x ˆ 2 + y ˆ 2 <= 1.0this area under the curve is (Pi * r^2)/ 4.0, and the area of the unit of square is 1.0, so Pi can be approximated by
# points with xˆ2+yˆ2 < 1 Pi =˜ -------------------------- * 4.0 total # points
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|