#include #include #include typedef double R; #define rc 10000000 R sq(R x){return x*x;} R scale = 0x1.p-30; R shine(R X, R Z){int n = rc; R lt = 0; while(n--){u: { R x = scale*random()-1, y = scale*random()-1, z = 0.5*scale*random(); if(sq(x*x+y*y+z*z) > z) goto u; R xn = (Z-1)*(x/z) + X, yn = (Z-1)*y/z; R r2 = xn*xn + yn*yn; lt += 1/((1+r2)*sqrt(1+r2)); if(0) printf("r2=%e xn=%e\n", r2, xn);}} return lt/rc;} int main(){ int j=7; while(j--) {R x=(j-1)/2., y = shine(x, 2); printf("%9.4f %9.4f %9.4f\n", x, y, 1/sq(y));} return 0;} /* 2.500000e+00 6.866293e-02 2.121072e+02 2.000000e+00 1.085296e-01 8.489913e+01 1.500000e+00 1.720450e-01 3.378436e+01 1.000000e+00 2.619808e-01 1.457006e+01 5.000000e-01 3.564462e-01 7.870676e+00 0.000000e+00 3.999277e-01 6.252261e+00 -5.000000e-01 3.565088e-01 7.867911e+00 */