On 16 June 2010 05:28, Tom Coates <t.coa...@imperial.ac.uk> wrote:
>
> As ddrake pointed out in Trac #9248, even when x is in the symbolic
> ring, factorial(x) is not simply calling gamma(x+1):
>
> sage: x=I; factorial(x)
> 0.498015668118356 - 0.154949828301811*I
> sage: gamma(x+1)
> gamma(I + 1)
>
> So something strange is going on.  I think that the first example here
> is probably a bug.  I am happy to fix whatever is wrong, but we need
> to decide what the correct behaviour should be.
>
>
> On 15 June, 17:02, rjf <fate...@gmail.com> wrote:
>> factorial(n+1)/factorial(n)  is generally believed to be n+1.
>> It is proper treatment of matters like this that make simplification
>> interesting.
>>
>> It is fairly pointless to raise an error for factorial for any number
>> except possibly explicit negative integers.
>
> I have not thought seriously about the issues involved, so my opinion
> should be regarded as tentative.  But right now my view is that the
> symbolic expressions factorial(x) and gamma(x+1) should not be
> identified, and that factorial(x) should raise an error for explicit
> numerical values of x other than 0, 1, 2, ... .  This is for the
> following reason.
>
> factorial(n) is an object from concrete mathematics (the number of
> arrangements of n objects; here n is a natural number) whereas the
> gamma function is not in any sense an elementary object.  So
> factorial(x) should not be identified with gamma(x+1), because the
> domains of the two functions
>
> x \mapsto factorial(x)
> x \mapsto gamma(x+1)
>
> are different.  Since the domain of x \mapsto factorial(x) is the
> natural numbers, factorial(x) should raise an error for explicit
> numerical values of x other than 0,1,2,3,...
> The symbolic expression
>
> factorial(n+1)/factorial(n)
>
> should still be equal to n+1, because the expression n could be a
> natural number.
>
> As I said, though, this might be contrary to the philosophy behind the
> symbolics module.  Please let me know what you think.
>
>> And by the way, if you do decide to provide an explicit numeric
>> integer, there are much better ways of computing n! than
>> multiplying n by n-1 by ....  .
>> for largish n.
>
> I agree.  But my understanding is that Sage computes n! (where n is an
> explicit non-negative integer) in an intelligent way.
>
> Best,
>
> Tom
>
> --
> To post to this group, send an email to sage-devel@googlegroups.com
> To unsubscribe from this group, send an email to 
> sage-devel+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

FWIW, here is how Mathematica 7 handles Factorial:

In[1]:= Factorial[1/2]

        Sqrt[Pi]
Out[1]= --------
           2

In[2]:= Factorial[-10]

Out[2]= ComplexInfinity

In[3]:= Factorial[2 + I 4]

Out[3]= (2 + 4 I)!

In[4]:= Factorial[-2 -I 4]

Out[4]= (-2 - 4 I)!

In[5]:= Gamma[-11]

Out[5]= ComplexInfinity

In[6]:= Gamma [3/2]

        Sqrt[Pi]
Out[6]= --------
           2

In[7]:= Gamma[10]

Out[7]= 362880

In[8]:= Gamma[10.0]

Out[8]= 362880.

Here's how Maple 12 handles similar

> factorial(-12);
Error, numeric exception: division by zero
> factorial(12);
                                   479001600


> factorial(-2-I4);
                                  (-2 - I4)!

MATLAB 7.2.0.283 (R2006a)

>> factorial(2  - i*4)
??? Error using ==> factorial
N must be a matrix of non-negative integers.

>> factorial(-12)
??? Error using ==> factorial
N must be a matrix of non-negative integers.


I've no idea how logical those choices are.

My maths background led me to believe factorial was only defined for
non-negative integers, but clearly I'm not a mathematician.

I certainly feel for non-mathematicians, the use of the gamma function
to place of factorial for non-negative integers would be a bad step.

It would be interesting to see how Maple, MATLAB and

Dave

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to