public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Brian Gough <bjg@gnu.org>
To: Thanh Vo <vo@ucdavis.edu>
Cc: gsl-discuss@sourceware.org, bug-gsl@gnu.org,
	"Earl T. Barr" <etbarr@ucdavis.edu>
Subject: Re: [Bug-gsl] Potential Bugs?
Date: Tue, 17 Aug 2010 20:38:00 -0000	[thread overview]
Message-ID: <43mxsl6klg.wl%bjg@gnu.org> (raw)
In-Reply-To: <AANLkTinA0Bo1tS-AuqeE62O=SqcDSMffHWKbxh5G4a1V@mail.gmail.com>

At Wed, 11 Aug 2010 17:14:34 -0700,
Thanh Vo wrote:
> My name's Thanh Vo. My research group is developing a tool to detect
> floating point exceptions in numerical code. We've found inputs that
> cause some of
> the GSL 1.14 functions to throw floating-point exceptions.  I've written
> this post to see if you consider any of them to be real bugs.

Hi,

Thanks for your email.  I have made some comments below.  This sounds
like a useful tool, I hope you will be able to release it as free
software.

> 
> 1.  The function airy_aie throws a divide by zero exception when its
> input x = 0 at line 618 in file gsl/specfunc/airy.c : double z   =
> 2.0/(x*sqx) - 1.0;.  It throws an invalid exception when x = -1 at
> line 617:  double sqx = sqrt(x);.
> 
> 2.  The function airy_bie throws a divide by zero exception when its
> input x = 0 at line 635 in file gsl/specfunc/airy.c: double z   =
> ATR/(x*sqx) + BTR;. It throws an invalid exception when x=-1 at line
> 634: double sqx = sqrt(x);.

These would be bugs but the functions are static and only called with
x > 1 or x > 2 so the exceptions cannot occur in practice.

> 3.  The function gsl_sf_asymp_thetanu_corr_e throws a divide by zero
> exception when its input x = 0 and nu != 0 at the line 181 in file
> gsl/specfunc/bessel_amp_phase.c: const double r  = 2.0*nu/x;. It
> throws an invalid exception when x=0 and nu=0 at line 181: const
> double r  = 2.0*nu/x;.
>
> 4.  The function gsl_sf_bessel_asymp_Mnu_e throws a divide by zero
> exception when its input x=0 and nu !=0 at the line 167 in file
> gsl/specfunc/bessel_amp_phase.c: const double r  = 2.0*nu/x;. It
> throws an invalid exception when x=0 and nu=0 at line 167: const
> double r  = 2.0*nu/x;.

It's a valid warning. The functions are publicly accessible, but not
documented.  Within the library they are only called with large values
of x >= 1000 so the exception does not occur in practice.  Ideally
they should be static functions.
 
> 5.  The function gsl_sf_bessel_J0 throws a overflow exception when its
> input x = 5.85177e+145 at the line 88 in the file
> gsl/specfunc/bessel_J0.c: const double z = 32.0/(y*y) - 1.0;. It
> throws an underflow exception when x = 6.8481e-155 at the line 81:
> result->err = y*y;.

The overflow exception is a valid warning.  It's also a bug in the
sense that it is avoidable (although the end result is correct, z=-1
since 1/inf=0).  It would be better written as (32/y)/y.

For the underflow it's a valid warning.  There isn't really any
alternative to returning zero in that case though.

-- 
Brian Gough

       reply	other threads:[~2010-08-17 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTinA0Bo1tS-AuqeE62O=SqcDSMffHWKbxh5G4a1V@mail.gmail.com>
2010-08-17 20:38 ` Brian Gough [this message]
2010-08-17 20:47   ` Brian Gough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43mxsl6klg.wl%bjg@gnu.org \
    --to=bjg@gnu.org \
    --cc=bug-gsl@gnu.org \
    --cc=etbarr@ucdavis.edu \
    --cc=gsl-discuss@sourceware.org \
    --cc=vo@ucdavis.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).