On 2010-Jun-16 10:24:35 -0700, Tom Coates <t.coa...@imperial.ac.uk> wrote:
>That said, if the consensus is that factorial(x) should be
>analytically continued, to allow x to be an explicit non-integral
>number (as is the case in Maple and Mathematica), then I am happy with
>this.  But then we should change the documentation of factorial() to
>make this clear.

Definitely.

>At the moment there does not seem to be a clear consensus either way.
>If you have an opinion on this, please vote!  Let x be an explicit
>numerical value such that x is not a non-negative integer (e.g. x=2/3,
>x=1.5, or x=i).  The options are:
>
>A)  factorial(x) should raise an error;
>
>B)  factorial(x) should return gamma(x+1).

I would prefer A.

'Factorial' has a specific mathematical meaning.  If Sage implements a
function that looks like a well-defined mathematical operation, it
should implement that mathematical operation unless there is good reason
not to.  And the documentation should make that clear.

At least locally, factorial is part of yr10 high school maths and can
be easily explained in terms of subtraction and multiplication,
whereas gamma is uni-level maths and requires calculus to define.  I
realise Sage is not aimed at high-school use but given that Sage
provides both gamma and factorial, restricting factorial's domain to
non-negative integers would be more consistent with the mathematical
definition.

OTOH:

APL explicitly defines its '!' operator to calculate gamma(arg-1)
(though it has no distinct gamma operator).

Using the "restrict the domain to prevent surprises" argument runs
into problems with (eg) arccos & arcsin - which are restricted to a
domain of [-1..1] for real numbers (giving a real range) but have no
domain restriction for complex numbers - so an similar case could
potentially be made for having arccos & arcsin raise an error when the
argument is a real number outside the range [-1..1], whilst allowing
any complex argument.  [The counter-counter-argument here is that
'gamma' and 'factorial' are distinct mathematical functions that
happen to be related for some arguments].

-- 
Peter Jeremy

Attachment: pgpef814lGIeF.pgp
Description: PGP signature

Reply via email to