Advertisement
krasi1105

Untitled

Aug 6th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. We draw a square whose side is 2cm long and inside it a circle with r=1cm. The square is defined by [-1,-1] and [1,1] in a cartesian coordinate system.
  2. Obviously the area of the square is 2x2 = 4cm.
  3.  
  4. We begin generating random points which are inside the square but may not be inside the circle.
  5. The point dimensions ∈[0, 1] but they may as well be negative because the hypotenuse is independent of sign of either of sides.
  6. The square area to circle area ratio is equal to the points inside square to points inside circle ratio.
  7. So by generating more points we keep getting closer to the circle area.
  8.  
  9. When we find it we divide by the squared radius(1*1, which turns out to be a no-op) to get PI.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement