Probabilistic Determination of Value of Pi from Square-Inscribed Circle

C code for simulating Signature Method to determine the value of Pi

int main(void){
    float x, y, p=0, n=10000;
    int i, r=50;
        if(x*x+y*y-r*r<=0) p++;
    printf("%f", 4*p/n);
    return 0;

This code can be run here. It simulates the approximate value of pi with 10000 signatures (note line 6). You can change the input number and see what happens to the approximation.

Above figure illustrates an example where among a total of 9 signatures within the square, one fell clearly outside the inscribed circle and one fell on the circle. Therefore, 7 out of 9 signatures are counted as being inside the circle. So, in this example, π is approximated as (7/9)x4 = 3.11.

This C code is cited in the following work(s) by Saumitra Chakravarty:

  1. Praner Majhe Gonit Baje: Jyamitir Jonyo Bhalobasa (BOOK) > Chapter 9 > Appendix 1
  2. Music of Pi Resonates Within Probability (ARTICLE)
  3. Goniter Sathe Bosobas (BOOK) > Chapter 2