#include
#include
double func(double x) {
return x*x-2.0;
}
int main() {
double x, x0, f;
int i,status;
double func(double);
fplotxy(func, 0, 3, 50, "f = x*x-2", "x", "y");
x0=2.0;
status=fzero(&x, func, x0);
f=func(x);
if (!status<0)
printf("Fitting failure.\n");
printf(" %6s %12s\n","x","f");
printf("%10.6f %12.6f\n",x,f);
}
x f
1.414213 -0.000000