In an attempt to analyze the accuracy of hyp2f1,
Different cases mentioned in Abramowitz (http://people.math.sfu.ca/~cbm/aands/page_561.htm)
and also in the Thesis on 'Computation of Hypergeometric functions"
(http://people.maths.ox.ac.uk/porterm/research/pearson_final.pdf, pg 65-66)
were tried out, and the function fails without warning when:
    c<0, c is not integral
   |c|>>|a| and |b|
 
For example:
sp.hyp2f1(10,5,-300.5,0.5)
>>-6.5184949735e+156
while the answer is
    -3.8520770815e+32
this case appears to filter down to hys2f1 in the source code (scipy.special.cephes.hyp2f1)

I tried the same input in mpmath to check if it works there:
hyp2f1(10,5,-300.5,0.5)
>>mpf('0.9211827166328477893913199888')
which is the solution when we apply power series expansion.

however MATLAB succeeds in giving the required solution.
Another interesting fact is that of the methods mentioned in the thesis:
Taylor series expansion, fraction method with double precision,
Gauss-Jacobi method and RK4), none succeeds in the given case.


I don't have any idea how the function itself is evaluated in the given case.
Any leads on how it is done and how MATLAB executes it?



On Thu, Feb 20, 2014 at 1:16 AM, Jennifer stone <jenny.stone125@gmail.com> wrote:

If you are interested in the hypergeometric numerical evaluation, it's
probably a good idea to take a look at this recent master's thesis
written on the problem:

http://people.maths.ox.ac.uk/porterm/research/pearson_final.pdf

The thesis is really comprehensive and detailed with quite convincing
conclusions on the methods to be used with varying a,b,x (though I am
yet to read the thesis properly enough understand and validate each
of the multitude of the cases for the boundaries for the parameters).
It seems to be an assuring and reliable walk through for the project.
  
This may give some systematic overview on the range of methods
available. (Note that for copyright reasons, it's not a good idea to
look closely at the source codes linked from that thesis, as they are
not available under a compatible license.)

It may well be that the best approach for evaluating these functions,
if accuracy in the whole parameter range is wanted, in the end turns
out to require arbitrary-precision computations.  In that case, it
would be a very good idea to look at how the problem is approached in
mpmath. There are existing multiprecision packages written in C, and
using one of them in scipy.special could bring better evaluation
performance even if the algorithm is the same.
 
Yeah, this seems to be brilliant idea. mpmath too, I assume, must have
used some of the methods mentioned in the thesis. I ll look through the
code and get back.

I am still unaware of the complexity of project expected at GSoC. This project
looks engaging to me. Will an attempt to improve both Spherical harmonic
functions ( improving the present algorithm to avoid the calculation for
lower n's and m's) and hypergeometric functions be too ambitious or
is it doable?

Regards
Jennifer
--
Pauli Virtanen