Problems with genfact and makegamma



I had a look at the function makegamma and have seen that makegamma has code to
transform the function genfact(x,z,z).

Here an example for n! = genfact(n,n,1):

(%i46) makegamma(genfact(n,n,1));
(%o46) gamma(n+1)/gamma(-floor(n)+n+1)

The definition of the factorial is n! = gamma(n+1). The formula above is wrong
for real and complex values. It is only correct for positive integers.

And this is n!! = genfact(n,n/2,2):

(%i47) makegamma(genfact(n,n/2,2));
(%o47) gamma(n/2+1)*2^floor(n/2)/gamma(-floor(n/2)+n/2+1)

This transformation is only correct for positive integers too.

Two example for the Double factorial are:

(%i48) f : makegamma(genfact(n,n/2,2));
(%o48) gamma(n/2+1)*2^floor(n/2)/gamma(-floor(n/2)+n/2+1)

(%i49) f,n:10;
(%o49) 3840

But we get wrong result for every other number.

(%i53) factorial_double(9.5);
(%o53) 1893.665159442379
(%i54) f,n:9.5;            
(%o54) 1371.562500000001 /* the wrong result */

We know that genfact is only valid for integers. Using the transformation to the
gamma function the user can produce wrong results.

I think, it is unnecessary to support a transformation to the Gamma function for
genfact. genfact should not be generalized to general numbers. Perhaps we can
cut off this code. I will try it and run the testsuite.

Instead we should implement this functionality for the function
factorial_double. This function is generalized to every real and complex number
and is definied with the Gamma function.

Dieter Kaiser