Benedict Irwin added yo.tex  over 9 years ago

Commit id: b90a98600df7013d9f6a4328c1256c7221e601c3

deletions | additions      

         

#include   #include   #include   int main(){  //RAND_MAX is: 2147483647  //Draw 4 means 536870911.75 period.  srand(time(NULL));  int i,j;  long int n,col;  double a1,a2,t1,t2;  double R,r;  R=1.0;  r=(8.0/103.0)*M_LN2;  col=0;  n=0;  for(j=0; j<50; j++){  while(n<536870911){  for(i=0; i<100000; i++){  a1=((double)rand()/RAND_MAX)*(R-(r/2.0));  a2=((double)rand()/RAND_MAX)*(R-(r/2.0));  t1=((double)rand()/RAND_MAX)*M_PI*2.0;  t2=((double)rand()/RAND_MAX)*M_PI*2.0;  if( sqrt( pow(a1*sin(t1)-a2*sin(t2),2) + pow(a1*cos(t1)-a2*cos(t2),2) ) < r ){ col++; }    n++;   }  }  printf("%.16lf\n",(double)col/n);  n=0;  col=0;  }  return 0;  }