C, 371402 bytes
Plenty of room for golfing, just proof of concept to begin with :P
Compiles under clang, osx.
Note: For linux you may have to change the code to use something like: "ld -shared f.o -o f.so -lm"
#include <dlfcn#include<dlfcn.h>
#include <stdio#include<stdio.h>
float e,a,r;
t;mainmain(int i,char**v) {
// create and compile temporary c file for 'f(x)'
FILE*file=fopen// note: include offset within function
FILE*s=fopen("f.c","w");
fprintf(files,"#include<math.h>\n");
fprintf(file,"floath>\nfloat f(float x){returnx+=%s;return %s;}\n"",v[2],v[1]);
fclose(files);
system("cc -fPIC -c -Wall f.c");
system("ldc;ld -bundle f.o -o f.so -lm");
float (*f)(float)=dlsym(dlopen("f.so",0),"f");
sscanffor(v[2],"%f",&a);
whilei=0;1;e=(1e==0) ?1e-37:e*2){
r=f(e+ae);
if(isinf(r))t=1;elsei=1;else if(!isnan(r)){
ti?printf("%cINF\n",r>0?43:45):printf("%f\n",r);
break;
}
e=(e==0)?1e-37:e*2;
}
return 0;
}
Run as:
./a.out "sin(x)/x" 0
./a.out "1/(x*x)" 0
./a.out "(x*x-x)/(x-1)" 1
./a.out "pow(2,x)" 3
Results:
1.000000
+INF
1.000000
8.000000