help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Numerical integration QAGS cannot reach tolerance and aborts


From: Vipin K. Varma
Subject: [Help-gsl] Numerical integration QAGS cannot reach tolerance and aborts
Date: Sat, 04 Oct 2014 18:19:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2

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

[Prev in Thread] Current Thread [Next in Thread]