This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Unusual behaviour in gsl_diff_central?


Hello!

     I notice that gsl_diff_central seems to fail
for large values of the function argument (see code
below). (I am using gsl 1.3 on Redhat 6.2.) I would 
expect it to return a non-zero value in this case,
but it returns zero, in spite of trying to evaluate
the function at x=NaN.
     Am I missing something here?

Thanks,
Andrew Steiner

double testfun(double x, void *pa) {
  return sin(x);
}

int main(void) {
  void *vp=0;
  int val;
  double res, err;

  gsl_function *gslfunc=new gsl_function;
  gslfunc->function=testfun;
  gslfunc->params=vp;

  cout.setf(ios::scientific);
  cout.precision(10);

  val=gsl_diff_central(gslfunc,1.0e5,&res,&err);
  cout << val << " " << res << " " << err << " " <<
cos(1.0e5) << endl;
  val=gsl_diff_central(gslfunc,1.0e10,&res,&err);
  cout << val << " " << res << " " << err << " " <<
cos(1.0e10) << endl;
  
  return 0;

}

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://platinum.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]