RobinHankin / gsl

an R wrapper for the Gnu Scientific Library
15 stars 9 forks source link

bug hyperg_2F1 #12

Closed stla closed 4 years ago

stla commented 4 years ago

Hello,

gsl::hyperg_2F1(-1/2,1/2,1,x) does not return the correct result:

> appell::hyp2f1(-1/2,1/2,1,0.5)
[1] 0.8598466+0i # same as Wolfram
> gsl::hyperg_2F1(-1/2,1/2,1,0.5)
[1] 0.4133929
RobinHankin commented 4 years ago

Thanks for this!

Hmm. There should be no issue with cut lines as we are inside the unit circle. Both Mathematica and the hypergeo R package both give 0.8598466. But I don't see anything wrong with gsl::hyperg_2F1(), making me think it's a GSL issue and not a gsl issue. I've been meaning to do some work on the package, I'll try to create a MWE in pure C. Best wishes, Robin

RobinHankin commented 4 years ago

Well I've just set up a MWE that uses GSL directly:

#include <stdio.h>
#include <gsl/gsl_sf_hyperg.h>
int
main (void)
{
double y = gsl_sf_hyperg_2F1 (-0.5,0.5,1,0.5);
printf ("answer = %.18e\n", y);
return 0;
}
~ % ./a.out
answer = 4.133929446329241975e-01

So it looks as though gsl is calling GSL correctly and it is indeed a GSL issue. Although I'd say on balance that this is probably a documentation issue rather than a coding issue. I'll put a bug report together for Galassi et al, crediting you.

RobinHankin commented 4 years ago

Turns out that it's a known issue:

http://savannah.gnu.org/bugs/?54998

So gsl is behaving as documented and indeed as intended (at least as intended by me). Heh.