:

## C code for the hypergeometric function 2F1 using an idea of Gosper

In a posting posting at http://www.math.utexas.edu/pipermail/maxima/2006/000126.html Fateman cites Gosper with an interesting approach to compute the hypergeometric function 2F1. I used that to produce a compiled version (double precision only), which can be achieved from Excel for example. The approach however can be used within Maple as well. The idea is, that with his way the linear transformations given in A&S need to be applied only once to cover the whole complex plane: up to 1 transformation one can use either Gosper's recursion or even lives in the unit circle with radius 1/2 (where the hypergeometric series already converges quite fast). Most troubles are given for exceptional parameters, where the transformations in A&S are not applicable and would involve expensive (and less exact) series in 4 Digamma functions. However choosing some appropriate presentation (which can be found by reading the proof in Lebedev's book and massaging them in Maple) one can treat this by numerical differentiating w.r.t. parameters. And choosing enough points one can take a stepsize large enough to keep errors small. Doing all that Maple is of real help, it would be a mess to make all things by hand. And of course it is the very tool for testing (but here: not for generating the actual code). I enclose a short overview (as sheet), the compiled DLL with a test sheet and the complete C(++) source as VC2005 project. Feed back is welcome for both more testing and porting it to a non-proprietary compiler (had problems to use Dev-C++ for all that). PS: Forrey's article cited in the intro can be downloaded from here. PPS: values in the branch cut (Reals greater than 1) are treated as in Maple (counter-clock wise w.r.t. the branching point), which means coming from the lower half plane (we had a discussion here these days about that). Download 102_hypergeometric 2F1 using an idea of Gosper.mws