#include
#include
int main(int argc, char *argv[]){
double maxdiff = 0.0;
double diff = 1.0;
double highx0 = 0.0;
double highy0 = 0.0;
double highx = 0.0;
double highy = 0.0;
double highxdiff = 0.0;
double highydiff = 0.0;
double x0d;
double y0d;
double x0start = 1000.0;
double y0start = 1000.0;
double x0max = 10000.0;
double y0max = 10000.0;
double xd;
double yd;
double xstart = 0.011;
double ystart = 0.011;
double xdmax = 1000.0;
double ydmax = 1000.0;
double md = 0.0;
float x0f, y0f, xf, yf;
float mf = 0.0;
long int count1=0;
long int count2=0;
long int count3=0;
long int count4=0;
long int umcount=0;
for(xd=xstart; xd < xdmax; xd += 10.233){
count1++;
for(yd=ystart; yd < ydmax; yd += 10.123){
count2++;
for(x0d=x0start; x0d < x0max; x0d += 10.531){
count3++;
for(y0d=y0start; y0d < y0max; y0d += 10.011){
count4++;
md = sqrt((xd-x0d)*(xd-x0d) + (yd-y0d)*(yd-y0d));
xf = (float)xd;
yf = (float)yd;
x0f = (float)x0d;
y0f = (float)y0d;
mf = sqrt((xf-x0f)*(xf-x0f) + (yf-y0f)*(yf-y0f));
diff = fabs(md - (double)mf);
if(diff>0.001){
umcount++;
}
if(diff>maxdiff){
maxdiff=diff;
highx0 = x0d;
highy0 = y0d;
highx = xd;
highy = yd;
highxdiff = x0d-xd;
highydiff = y0d-yd;
}
}
}
}
}
printf("maxdiff is %1.9f\n", maxdiff);
printf("highx is %1.9f\n", highx);
printf("highy is %1.9f\n", highy);
printf("highx0 is %1.9f\n", highx0);
printf("highy0 is %1.9f\n", highy0);
printf("highxdiff is %1.9f\n", highxdiff);
printf("highydiff is %1.9f\n", highydiff);
printf("count1 was %ld\n", count1);
printf("count2 was %ld\n", count2);
printf("count3 was %ld\n", count3);
printf("number of iterations was %ld\n", count4);
printf("fraction of iterations with > 1um error %f\n", (float)umcount/(float)count4);
return 0;
}
/* HIGHEST REGISTERED
maxdiff is 1.398712036
a is 9000.988000000
b is 9000.988000000
highx0 is 6.441000000
highy0 is 8.814000000
highx0diff is -8994.547000000
highy0diff is -8992.174000000
maxdiff is 0.002292558
a is 8205.567000000
b is 8992.653000000
highx0 is 10.062000000
highy0 is 5.979000000
highx0diff is -8195.505000000
highy0diff is -8986.674000000
High numbers generally loose some when small numbers are subtracted from them.
*/