1. You can do one quadrant rather than four, then multiply that approximation by 4.
2. Montecarlo is good to develop an intuition about Monte carlo approximations but converges really slowly.
Ramanujan-Sato series for pi or Chudnovsky algorithm can be a scalable alternative, gives you a lot of digits.
Now... how many digits you usually need? Very few. Practical applications requiring more than 15 digits are hard to find. e.g: NASA uses 15 digits for interplanetary navigation, even for the most distant spacecraft such as the Voyager 1 which is now 20 billion kilometers from Earth.
Can just use a constant, or in the worst case, if missing, define it as:
Accuracy from one quadrant and four quadrants would be the same, though, and full circle is easier to code (no extra conditions).
To get better accuracy you would need to cut out some parts that are clearly inside or outside the circle, and only throw the points in the areas where the circle can actually be.
1. You can do one quadrant rather than four, then multiply that approximation by 4.
2. Montecarlo is good to develop an intuition about Monte carlo approximations but converges really slowly.
Ramanujan-Sato series for pi or Chudnovsky algorithm can be a scalable alternative, gives you a lot of digits.
Now... how many digits you usually need? Very few. Practical applications requiring more than 15 digits are hard to find. e.g: NASA uses 15 digits for interplanetary navigation, even for the most distant spacecraft such as the Voyager 1 which is now 20 billion kilometers from Earth.
Can just use a constant, or in the worst case, if missing, define it as: