I adjusted an older TinyCC+GMP Mandelbrot experiment to exactly match the Scheme program's evaluation (some comparisons had to be checked for really doing the same, e.g. ">=" versus ">"):
-------------------------------------------------------------------------------- (yeti@kumari:17)~/wrk/gambit$ cat mb2_tcc #!/usr/bin/env -S tcc -run -lgmp
#include <stdio.h> #include <string.h> #include <unistd.h> #include <gmp.h>
int main(int argc, char *argv[]) { if(argc!=8) { /* needs nicer usage */ fputs("args: Qxmin Qxmax Qymin Qymax Qdx Qdy Zmaxiter\n",stderr); return 1; }
mpq_t c2,c4,cx,cy,dx,dy,x,y,x2,y2,xmin,xmax,ymin,ymax,tq; mpq_inits(c2,c4,cx,cy,dx,dy,x,y,x2,y2,xmin,xmax,ymin,ymax,tq,NULL); mpz_t i,maxiter; mpz_inits(i,maxiter,NULL);
mpq_set_ui(c4,4,1);
mpq_set_str(xmin,argv[1],10); mpq_canonicalize(xmin); mpq_set_str(xmax,argv[2],10); mpq_canonicalize(xmax); mpq_set_str(ymin,argv[3],10); mpq_canonicalize(ymin); mpq_set_str(ymax,argv[4],10); mpq_canonicalize(ymax); mpq_set_str(dx,argv[5],10); mpq_canonicalize(dx); mpq_set_str(dy,argv[6],10); mpq_canonicalize(dy); mpz_set_str(maxiter,argv[7],10);
char c;
mpq_set(cy,ymin); while(mpq_cmp(cy,ymax)<=0) { mpq_set(cx,xmin); while(mpq_cmp(cx,xmax)<=0) { mpq_set_ui(x,0,1); mpq_set_ui(y,0,1); mpq_set_ui(x2,0,1); mpq_set_ui(y2,0,1); mpz_set_ui(i,0); c = 0; while(mpz_cmp(i,maxiter)<0) { if(mpq_add(tq,x2,y2),mpq_cmp(tq,c4)>0) break; mpq_mul(y,x,y); mpq_add(y,y,y); mpq_add(y,y,cy); mpq_sub(x,x2,y2); mpq_add(x,x,cx); mpz_add_ui(i,i,1); c++; mpq_mul(x2,x,x); mpq_mul(y2,y,y); } putchar(64+c); // beware too deep iteration mpq_add(cx,cx,dx); } printf("\n"); mpq_add(cy,cy,dy); }
mpz_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EEFGKIJQEDDDDCCCCBBBBBBBBBBBBBBBBBBBBBBBBAAAAAA AAAAAAABBBBBBBCCCCCCCCCCCCCCCCCDDDEGEEDDDCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAA AAAAAAAAABBBBBBBBBBBCCCCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAA AAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAA AAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (yeti@kumari:17)~/wrk/gambit$ sha1sum *.out 2afc568d51b567a515f8d8197d7606351fce9ebc mb2ce.scm.out 2afc568d51b567a515f8d8197d7606351fce9ebc mb2.scm.out 2afc568d51b567a515f8d8197d7606351fce9ebc mb2_tcc.out --------------------------------------------------------------------------------
At home all results are identical and on ~institute the C example's output matches the ones at home.
End of story for now?