14 int main(int argc,char **argv) {
15 double R12,R22,D2,D_2,YZ2;
16 double x[4],hlp[4],var[4];
17 double vol,vol_exakt,a1,a2;
25 a2=(R22+D*D-R12)/(2*D);
27 y_z_max=2*sqrt(R12-a1*a1);
28 vol=y_z_max*y_z_max*x_max;
29 vol_exakt=M_PI*(R1-a1)*(R1-a1)*(3*R1-(R1-a1))/3;
30 vol_exakt+=M_PI*(R2-a2)*(R2-a2)*(3*R2-(R2-a2))/3;
35 for(i=0;i<4;i++) x[i]=0;
39 hlp[1]=1.*rand()/RAND_MAX*x_max+D-R2;
40 hlp[2]=1.*rand()/RAND_MAX*y_z_max-(y_z_max/2);
41 hlp[3]=1.*rand()/RAND_MAX*y_z_max-(y_z_max/2);
43 printf("%f %f %f %f\n",hlp[0],hlp[1],hlp[2],hlp[3]);
45 YZ2=hlp[2]*hlp[2]+hlp[3]*hlp[3];
46 D2=(hlp[1]*hlp[1])+YZ2;
47 D_2=(D-hlp[1])*(D-hlp[1])+YZ2;
49 if((D2<=R12)&&(D_2<=R22)) {
53 var[i]+=hlp[i]*hlp[i];
59 var[i]=sqrt((var[i]/N-x[i]*x[i])/N)*vol;
61 if(i>0) x[i]/=vol_exakt;
62 printf("x[%d] = %f +/- %f\n",i,x[i],var[i]);
64 printf("vol_exakt = %f\n",vol_exakt);