bugGNU Scientific Library - Bugs: bug #65760, gsl_sf_log_erfc (and gsl_sf_erc)...


You are not allowed to post comments on this tracker with your current authentication level.

bug #65760: gsl_sf_log_erfc (and gsl_sf_erc) return NaN for infinite or very large finite arguments

Submitter:  Leo Singer <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

Sun 19 May 2024 11:49:02 PM UTC, original submission:  

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

Leo Singer <lpsinger>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lpsinger (Submitted the item)

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code