I'm trying to understand how to compute the value of Pi by means of the Monte Carlo simulation.I have a circle inside a square where the sides of the square are tangent to the circle. As data I have the number of random points and the ratio between the lenght of one side of the square and the diameter.$$\displaystyle \frac{l}{d} = r_{a}$$According to what I've read I have to count the number of points lying inside the circle and the total of points.The area of a circle is $A_{circle} = \pi r^2$ and the area of a square is $A_{square} = l^2$.To check if a point is inside the circle I have to check $\sqrt{x^2+y^2} <= r$I don't know how to relate the ratio $r_a$ with the radius so to check if the point is inside or outside the circle. Any suggestion?UPDATEThis has been a really frustrating stuff and is a really simple example of Monte Carlo approximation.Assuming $d=1$ then I have that $\displaystyle \frac{l}{d} = l = r_a$Therefore, to check if a random point is inside the circle I have to check only that$$\sqrt{x^2 + y^2}  \frac{1}{2}$$or it has to be related to the ratio $r_a$ ??
Monte Carlo approximation of PI
monte carlo;geometry
Suppose, that your circle have unitary radius: $r=1$, then length of square's side equal to $l = r_a \cdot d = 2\cdot r_a$.So, area of circle equals to $S_c = \pi$ and area of square equals to $S_s = 4 r_a^2$.If you throw $N_t$ random points inside of square, a part of them (say, $N_c$) will fall into the circle. Relation $\frac{N_c}{N_t}$ equals to proportions of their areas, $\frac{S_c}{S_s}$:$$\frac{N_c}{N_t} = \frac{S_c}{S_s}$$Now, to calculate $\pi$ you should divide $N_c$ to $N_t$ and multipy by $S_s$:$$\pi = 4r_a^2\cdot\frac{N_c}{N_t}$$In case of unitary $l$ you should set $r = \frac{1}{2 r_a}$.