// plot sign of f(x,y) = x**y - y**x in color // // R: f > 0, G: f == 0, B: f < 0 // #include #include #include #include "ppm.h" // return indication of the sign of f, avoiding overflow // // f(x,y) = exp(log(x)*y) - exp(log(y)*x) // double f( double x, double y) { if( x == 0 && y == 0) return 0; else return log(x)*y - log(y)*x; } int main( int argc, char *argv[]) { int n = 250; if( argc > 1) n = atoi( argv[1]); ppm a = ppm_new( n, n); double z; for( int i = 0; i < n; ++i) for( int j = 0; j < n; ++j) { a.r[i][j] = a.g[i][j] = a.b[i][j] = 0; z = f(j,i); if( z > 0) a.r[i][j] = 255; else if( z == 0) a.g[i][j] = 255; else a.b[i][j] = 255; } ppm_write( a); return 0; }