[SciPy-Dev] Fixing a bug with scipy's hypergeometric function hyp2f1

Adam Former at physicist.net
Wed Oct 18 19:47:42 EDT 2017


Hello guys,

I've found a small region in the complex plane where scipy's implementation of the hypergeometric function hyp2f1 fails. I've documented this error in issue 8054 on github. 

I am willing to submit a PR that fixes this issue. My PR would basically implement the analytic continuation formula given in this paper: (Buhring, An Analytic Continuation of the Hypergeometric Series). I've already implemented this series in some prototype code written in Fortran and it agrees well with the values returned by mpmath's implementation of hyp2f1.
Before I attempt a PR, I just wanted to touch base and ask the group the following:

1) Does this sound like a worthwhile PR? The failure region is somewhat small and I don't know with what urgency people would want this fixed.

2) Does the implementation sound reasonable? My background is physics and so I haven't done a complete literature search looking for the *fastest* algorithm. All I can say that the Buhring's formula works and my implementation only seems to be about %50 slower than the current hyp2f1 (at points in the complex plane where both methods converge). I would only apply Buhring's series in the region where hyp2f1 currently diverges.

3) Can the PR implement formulas/methods that don't appear in the literature? Buhring's paper *only* gives the analytic continuation for the case where the difference between the a/b parameters is NOT an integer. When a-b=m, the limit case of his series can be derived using a method described in "The Special Functions and Their Approximations" by Y. Luke (as Buhling mentions in his paper). I've derived the formula for this limit case and have an implementation of it that produces values in agreement with mpmath.  Is it going to be a problem if I implement this limit case in the PR? I ask because I don't what reference I would place hyp2f1's doc string. I would be wiling to maybe add a latex doc to the PR (placed somewhere in the doc folder?) that contains the formula so that future scipy devs have something to reference when reviewing hyp2f1's source code.

Anyways, let me know if my idea for a PR sounds like a good idea! I apologize for the longish email, but this is my first time trying to contribute to scipy...

--Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20171018/3a54121a/attachment.html>


More information about the SciPy-Dev mailing list