Hi,

I'm trying to perform a simple integration using GSL's QAGS (and other
variants like QAGP, QNG, QAG) but the error handler is invoked for the
following code with "ERROR: cannot reach tolerance because of roundoff
error":

<CODE>

/#include <stdio.h>//
//#include <gsl/gsl_math.h>//
//#include <gsl/gsl_integration.h>//
//
//struct my_f_params { int n; double a; };//
//
//double f (double x, void * p) {//
//  struct my_f_params * params = (struct my_f_params *)p;//
//  int n = (params->n);//
//  double a = (params->a);//
//  double f = cos(n*x)*log((cos(a) - cos(x))/(x - a));//
//  return f;//
//}//
//
//int main (void)//
//{//
//  gsl_integration_workspace * w//
//    = gsl_integration_workspace_alloc (1000);//
//
//  int n(1);//
//  size_t neval;//
//  double result, result_int, error;//
//  double alpha = 0.993*M_PI/2;//
//  struct my_f_params params = {n, alpha};//
//
//  gsl_function F;//
//  F.function = &f;//
//  F.params = &params;//
//
//  gsl_integration_qags (&F, 0, M_PI, 0, 1e-12, 1000, w, &result,
&error);//
//
//  printf ("result          = % .18f\n", result);//
//
//  gsl_integration_workspace_free (w);//
//
//  return 0;//
//}//
/
<CODE>

However if I change the variable "alpha" to 0.992*M_PI (or any value
below that), then the program goes through and gives the correct result
(as compared with other libraries which always give the correct result
for any value of "alpha" between 0 and pi). Could someone please mention
what might be wrong given that the function f is not singular in the
integration range?

Thanks,
Vipin

Reply via email to