URL:
  <https://savannah.gnu.org/bugs/?65760>

                 Summary: gsl_sf_log_erfc (and gsl_sf_erc) return NaN for
infinite or very large finite arguments
                   Group: GNU Scientific Library
               Submitter: lpsinger
               Submitted: Sun 19 May 2024 11:49:02 PM UTC
                Category: Accuracy problem
                Severity: 3 - Normal
        Operating System: Debian 12.5
                  Status: None
             Assigned to: None
             Open/Closed: Open
                 Release: 2.7.1
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Sun 19 May 2024 11:49:02 PM UTC By: Leo Singer <lpsinger>
gsl_sf_log_erfc (and gsl_sf_erc) return NaN for infinite or very large finite
arguments. For such arguments, gsl_sf_log_erfc should return -inf and
gsl_sf_erc should return 0.

See minimal reproducer below.


/* test.c */
#include <gsl/gsl_math.h>
#include <gsl/gsl_sf_erf.h>
#include <stdio.h>

static const double x[] = {1e0, 1e1, 1e2, 1e20, 1e60, 1e80, GSL_POSINF};

int main(int argc, char **argv) {
        for (int i = 0; i < sizeof(x) / sizeof(x[0]); i ++) {
                double x_i = x[i];
                double y_i = gsl_sf_log_erfc(x[i]);
                printf("gsl_sf_log_erfc(%g) = %g\n", x_i, y_i);
        }
        return 0;
}


Compile and run as follows:


$ gcc test.c $(pkg-config --cflags --libs gsl)
$ ./a.out 
gsl_sf_log_erfc(1) = -1.84961
gsl_sf_log_erfc(10) = -102.88
gsl_sf_log_erfc(100) = -10005.2
gsl_sf_log_erfc(1e+20) = -1e+40
gsl_sf_log_erfc(1e+60) = -inf
gsl_sf_log_erfc(1e+80) = -nan
gsl_sf_log_erfc(inf) = -nan









    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65760>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/


Reply via email to