bugGNU Scientific Library - Bugs: bug #58066, Digamma function returning...

 
 

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

bug #58066: Digamma function returning incorrect values for (most) negative integers

Submitter:  Jackson Vanover <jacksonvanover>
Submitted:  Sat 28 Mar 2020 05:27:05 PM UTC
   
 
Category:  Accuracy problem Severity:  3 - Normal
Priority:  5 - Normal Operating System:  Ubuntu 18.04
Status:  None Assigned to:  None
Open/Closed:  Open Release:  2.6

Discussion

Mon 10 Nov 2025 02:27:40 PM UTC, comment #1: 

he implementation in the function psi_x() in the file psi.c
checks only 0, -1 and -2 for poles and fails to do this for
other negative integers. So instead of

   if(x == 0.0 || x == -1.0 || x == -2.0) {
    DOMAIN_ERROR(result);
  }

one would have to write

   if(x <= 0.0 && round(x) == x) {
    DOMAIN_ERROR(result);
  }


R. J. Mathar <rjmathar>
Sat 28 Mar 2020 05:27:05 PM UTC, original submission:  

Using version 2.6 of GSL from ftp://ftp.gnu.org ... sl/gsl-2.6.tar.gz

OS is Ubuntu 18.04.2 LTS

Hardware is a Dell workstation with a 3.60 GHz Intel i7-4790 and 32 GB
of RAM

Compiler is gcc 7.4.0 with the -w option

Though the digamma function has poles at all negative integer values,
once the magnitude of the input is larger than 2,
GSL does not complain and returns incorrect values. For the inputs -1
and -2, the error handler is invoked with a domain error as might be
expected.

#include <gsl/gsl_sf.h>
#include <stdio.h>
#include <gsl/gsl_math.h>
#include <float.h>

int main (void){
        double out;
        out = gsl_sf_psi(-3);

        printf("%.*f\n", DBL_DIG-1, out);
        printf("%.21e\n", out);
        return 0;
}

Jackson Vanover <jacksonvanover>

 

Attached Files

Attached Files
file #57857:  psi.c.patch added by rjmathar (353B - text/x-patch)

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by rjmathar (Posted a comment)
  • -email is unavailable- added by jacksonvanover (Submitted the item)
  •  

    History

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-11-24 rjmathar Attached File- Added psi.c.patch, #57857

    Back to the top

    Powered by Savane 3.16-a7ba.
    Corresponding source code