bugGNU Scientific Library - Bugs: bug #66993, Bug: pow_int issues

 
 

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

bug #66993: Bug: pow_int issues

Submitter:  Fermé le Lundi <fermelelundi>
Submitted:  Sat 05 Apr 2025 09:04:13 PM UTC
   
 
Category:  Accuracy problem Severity:  3 - Normal
Priority:  5 - Normal Operating System: 
Status:  None Assigned to:  None
Open/Closed:  Open Release:  2.8

Discussion

Sat 05 Apr 2025 09:04:13 PM UTC, original submission:  

There are multiple functions in GSL which support raising a double to an int:
1- gsl_pow_int.h: has inline functions such as gsl_pow_2(const double x) { return x*x; }
2- sys/pow_int.c: functions gsl_pow_int(double x, int n) and gsl_pow_uint(double x, int n)
3- specfunc/pow_int.c: function gsl_sf_pow_int(const double x, const int n)

To reduce function duplication we could rationalise a few, ie start to mark as 'deprecated'; suggest: gsl_sf_pow_int(x, n).

There are a couple of issues with these functions:
1- Source code documentation in specfunc/pow_int.c states "Does not check for overflow/underflow.", but this should read: "Does not check for underflow, but does check for overflow when x = 0.0 and n negative."
2- All functions report the same values, and some are incorrect:

(a) Error compounding: (+0.5)^(-9) = 512.0000000000010232. Unclear how to eliminate, as this looks like the result of machine imprecision; perhaps a note in the source code and/or documentation that results are correct up to the tenth decimal for -9 <= n <= 9?
(b) Raising to power of 1: (-0.3)^1 = -0.3000000000000002. We could benefit from handling raising to 1 as a special case.
(c) Raising zero from below to a negative int: (-0.0)^(-1) = -7205759403792794.0000000000000000; where it should report "Division by zero" error, ie GSL_EZERODIV.
(d) Raising zero to a negative int: sys/gsl_pow_int(0.0, n) reports +inf for n <= -1, but this should be GSL_EZERODIV.

Note: complex functions gsl_complex_pow (gsl_complex a, gsl_complex b) and gsl_complex_pow_real (gsl_complex a, double b) probably warrant a review of their own.

Fermé le Lundi <fermelelundi>

 

Attached Files

This item currently has no attached files.

 

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 fermelelundi (Submitted the item)
  •  

    History

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.16-598c.
    Corresponding source code