Hi List,

the function f(x)=ln(cosh(x)) is obviously symmetric, ie f(x)=f(-x),
right?

The current implementation in gsl seems to be incorrect for negative
values:
=== from version 1.5 ===
int gsl_sf_lncosh_e(const double x, gsl_sf_result * result)
{
  /* CHECK_POINTER(result) */

  if(fabs(x) < 1.0) {
    double eps;
    cosh_m1_series(x, &eps);
    return gsl_sf_log_1plusx_e(eps, result);
  }
  else if(x < -0.5*GSL_LOG_DBL_EPSILON) {
    result->val = x + log(0.5*(1.0 + exp(-2.0*x)));
    result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
    return GSL_SUCCESS;
  }
  else {
    result->val = -M_LN2 + x;
    result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
    return GSL_SUCCESS;
  }
}
===
The second elseif is met for large negative numbers, while the
correct asymptotic limit would be "f(x->-inf) = |x|-ln(2)".

Replacing x by fabs(x) everywhere should fix the problem ...

Regards

Max

_______________________________________________
Help-gsl mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to