On 14/02/2025 17:06, Sven Schreiber wrote:
Hi again,
I think the built-in hyp2f1() function needs some more documentation in
the function reference, where it basically just says that it's the Gauss
hypergeometric function with four arguments, and that the fourth
argument should be real-valued.
Wow. I didn't even remember we had this function in the first place. I
don't remember when we added it, or why, but it's good to have it. Of
course you're right, it needs better documentation.
For example, on Wikipedia (
https://en.wikipedia.org/wiki/
Hypergeometric_function) it becomes relatively clear that this fourth
argument should have modulus less than one. If this is actually correct,
then I think it wouldn't hurt to add this to the docs.
Well, in fact if you scroll down the same wikipedia page, in fact
argument 4 can be -1 (which we handle ok already) or 1 if the real part
of arg 3 is greater than the real part of the sum of args 1 and 2 (which
we don't but wouldn't be difficult to add, given that we have bincoeff()
already).
There's also more things that are not so clear: Wikipedia says
"It is
undefined (or infinite) if c equals a non-positive integer", but using a
call with a negative integer like hyp2f1(-1,-2,-3, 0.4) yields a finite
result 0.73333. I'm sure there's just a mis-interpretation on my side,
but again, that's why I think some more basic remarks in the function
ref would be needed.
What we have in the source from cephes is in fact a bit more intricate
(file cephes/hyp2f2.c, line 145).
if (c <= 0.0) {
ic = round(c); /* nearest integer to c */
if (fabs(c - ic) < EPS) { /* c is a negative integer */
/* check if termination before explosion */
if (neg_int_a && (ia > ic))
goto hypok;
if (neg_int_b && (ib > ic))
goto hypok;
goto hypdiv;
}
}
which is a case wikipedia describes a few lines below ("The series
terminates if either a or b is a nonpositive integer").
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------