// testing one function at one point // #include #include double my_sqrt( double x) { return exp(log(x)/2); } int main( void) { double x = 2; double y1 = my_sqrt(x); double y2 = sqrt(x); printf( "sqrt %g %g %g\n", x, y1, y2); // bad, duplicated code: x = 10; y1 = my_sqrt(x); y2 = sqrt(x); printf( "sqrt %g %g %g\n", x, y1, y2); } /* output: sqrt 2 1.41421 1.41421 sqrt 10 3.16228 3.16228 */