#17123: Extending binomial(n,k) to negative integers n, k.
---------------------------------+------------------------
       Reporter:  pluschny       |        Owner:
           Type:  enhancement    |       Status:  new
       Priority:  minor          |    Milestone:  sage-6.4
      Component:  combinatorics  |   Resolution:
       Keywords:  binomial       |    Merged in:
        Authors:                 |    Reviewers:
Report Upstream:  N/A            |  Work issues:
         Branch:                 |       Commit:
   Dependencies:                 |     Stopgaps:
---------------------------------+------------------------

Comment (by rws):

 The pseudocode in the ticket description does not seem to fit the paper
 given as reference, quote:
 {{{
 For nonnegative integer n and integer k this reduces to [1]:

 (1.2) binomial(n,k) = n!/(k!(n-k)!) if 0<=k<=n, 0 otherwise

 ... This results in the following binomial coefficient identity,
 which with identity (1.2) allows computation of the binomial coefficient
 for all integer
 arguments.

 (2.1) Theorem 2.1. For negative integer n and integer k:

 binomial(n,k) = (-1)^k * binomial(-n+k-1,k) if k>0,
                 (-1)^(n-k) * binomial(-k-1,n-k) if k<=n,
                 0 otherwise
 ...
 }}}
 so in my opinion the definition should rather be
 {{{
 def BINOMIAL(n, k):
     if n in ZZ and k in ZZ:
         if n >= 0:
             return binomial(n, k)
         if k >= 0:
             return (-1)^k*binomial(-n+k-1, k)
         if k <= n:
             return (-1)^(n-k)*binomial(-k-1, n-k)
         return 0
     else:
         return binomial(n, k)
 }}}
 This leaves a discrepancy between `binomial(*,k<0)` and `BINOMIAL(*,k<0)`
 in the area `n<0, k<n` and to get to the point I would ask darij to
 provide a Knuth reference that supports the behaviour of `binomial` for
 these values.

--
Ticket URL: <http://trac.sagemath.org/ticket/17123#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to