// Test rf
System.out.println("Testing rf");
Ran myran = new Ran(17);
for (i=0;i<N;i++) {
x=10.0*myran.doub();
y=10.0*myran.doub();
z=10.0*myran.doub();
f1[i]=rf(x,y,z);
lambda=sqrt(x*y)+sqrt(x*z)+sqrt(y*z);
f2[i]=2.0*rf(x+lambda,y+lambda,z+lambda);
f3[i]=rf((x+lambda)/4.0,(y+lambda)/4.0,(z+lambda)/4.0);
// System.out.printf(f1[i] << " %f\n", f3[i]);
}
System.out.printf("rf: Rule 1, maximum discrepancy = %f\n", maxel(vecsub(f1,f2)));
System.out.printf("rf: Rule 2, maximum discrepancy = %f\n", maxel(vecsub(f1,f3)));
sbeps=1.e-14;
localflag = maxel(vecsub(f1,f2)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** rf: Function rf(x,y,z) does not follow duplication theorem rule 1");
}
sbeps=1.e-14;
localflag = maxel(vecsub(f1,f3)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** rf: Function rf(x,y,z) does not follow duplication theorem rule 2");
}
// Test rf(x,x,x) = 1/sqrt(x)
for (i=0;i<N;i++) {
x=myran.doub();
f1[i]=rf(x,x,x);
f2[i]=1.0/sqrt(x);
}
System.out.printf("rf: Rule 3: maximum discrepancy = %f\n", maxel(vecsub(f1,f2)));
sbeps=1.e-14;
localflag = maxel(vecsub(f1,f2)) > sbeps;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** rf: Function rf(x,x,x) is not equal to 1/sqrt(x)");
}
// Symmetry test
for (i=0;i<N;i++) {
x=10.0*myran.doub();
y=10.0*myran.doub();
z=10.0*myran.doub();
f1[i]=rf(x,y,z);
f2[i]=rf(y,x,z);
f3[i]=rf(x,z,y);
}