public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Richard Mathar <mathar@strw.leidenuniv.nl>
To: gsl-discuss@sourceware.org
Cc: mathar@mail.strw.leidenuniv.nl
Subject: Hypergeometric 2F1() specfunc: cases x=1
Date: Tue, 11 Dec 2007 21:16:00 -0000	[thread overview]
Message-ID: <200712112114.lBBLERNe005280@amer.strw.leidenuniv.nl> (raw)


It would be nice if the implementation of the Gaussian hypergeometric
functions would catch the special case of unit argument and compute it
via the standard formula with the Gamma functions (Abramowitz & Stegun 15.1.20).
Currently, all x>0.995 are rejects as being too close to the limit where
the branch cut prohibits the standard series to converge. So my proposal is
to implement in gsl_sf_hyperg_2F1_e() in specfunc/hyperg_2F1.c just
at the start of the function a trap for this case:

....
  const int c_neg_integer = ( c < 0.0  &&  fabs(c - rintc) < locEPS );

  result->val = 0.0;
  result->err = 0.0;

/* start proposed handling of x=1.0 RJM */
   if ( fabs(x - 1.0) < locEPS && c-a-b > 0. && c != 0. && ! c_neg_integer )
   {
        gsl_sf_result lnGamc, lnGamcab, lnGamca, lnGamcb  ;
        int stat = gsl_sf_lngamma_e(c, & lnGamc);
        if ( stat != GSL_SUCCESS )
        {
                DOMAIN_ERROR(result);
        }
        stat = gsl_sf_lngamma_e(c-a-b, & lnGamcab);
        if ( stat != GSL_SUCCESS )
        {
                DOMAIN_ERROR(result);
        }
        stat = gsl_sf_lngamma_e(c-a, & lnGamca);
        if ( stat != GSL_SUCCESS )
        {
                DOMAIN_ERROR(result);
        }
        stat = gsl_sf_lngamma_e(c-b, & lnGamcb);
        if ( stat != GSL_SUCCESS )
        {
                DOMAIN_ERROR(result);
        }
        return gsl_sf_exp_err_e(lnGamc.val+lnGamcab.val-lnGamca.val
                -lnGamcb.val,lnGamc.err+lnGamcab.err+lnGamca.err+lnGamcb.err,result) ;
   }
/*end proposed handling of x=1.0 RJM */

  if(x < -1.0 || 1.0 <= x) {
....

Richard Mathar, http://www.strw.leidenuniv.nl/~mathar

             reply	other threads:[~2007-12-11 21:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11 21:16 Richard Mathar [this message]
2007-12-12 16:28 ` 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=200712112114.lBBLERNe005280@amer.strw.leidenuniv.nl \
    --to=mathar@strw.leidenuniv.nl \
    --cc=gsl-discuss@sourceware.org \
    --cc=mathar@mail.strw.leidenuniv.nl \
    /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).