Sage seems to use the definition from Concrete Mathematics by Graham,
Knuth and Patashnik:

binomial(r, k) = r*(r-1)*...*(r-k+1)/(k * (k-1) *...* 1)
   if k >= 0 and r any real number, and
binomial(r, k) = 0
   if k < 0

That gives e.g.
  sage: binomial(-4, 5)
  -56

Though Peter's suggestion seems to make sense from one point of view, so
does the above I would guess. Concrete Mathematics is seen as something
of a bible in large parts of computer science, and it's unfortunate to
disagree with a basic definition in there. The book has a long chapter
devoted to convoluted identities on binomial coefficients -- I don't
know how many of them are left true by the proposed change.

Best,
Johan

Peter Luschny writes:

> Hi all,
>
> I have already reported the unsatisfactory state of the binomial
> function as implemented in Sage on 'Ask Sage' and had opened 
> a request for enhancement with ticket #17123. 
>
> Here I take up a suggestion of John Palmieri to discuss the
> issue on this list. The request is:
>
>    Extend binomial(n,k) by the reflection formula, i. e. set
>    for n>=1 and k>=1
>   
>    binomial(-k, -n) = (-1)^(n+k) binomial(n-1, k-1).
>       
> The reasons are:
>
> (1) The current behavior introduces incompatibility with
> Maple and Mathematica. This does not only question Sage as an
> alternative for the other M-systems; because of the ubiquity
> and importance of the binomial function it becomes difficult 
> to recommended Sage for implementing sequences on the OEIS. 
>
> The behaviour of Maple and Mathematica (which support the
> reflection formula) seems to be the de facto standard. Many 
> mathematicians write their formulas in the OEIS without 
> explicitly mentioning when they assume the reflection formula.
> And this extension was used by mathematicians prior to Maple
> and Mathematica. (So it is certainly not a question of 'do we
> have to mimic all the crap of other M-systems' like some 
> commentators seem to suggest.) 
>
> (2) The extension appears natural as the extended binomial
> has the same behaviour as:
>
> def limit_binomial(n,r):
>     return limit(gamma(n+x+1)/(gamma(r+x+1)*gamma(n+x-r+1)), x=0) 
>
> for n in (-5..5): print [limit_binomial(n,k) for k in (-5..5)]
>
> Indeed I find it confusing that the current implementation 
> does not exhibit this behavior.
>
> (3) Also the basic representation of Pascal's triangle in terms
> of the matrix exponential (see the Wikipedia reference below)
> makes the reflection extension appear natural as it is an extension
> from the matrix with 1, 2, 3, ... subdiagonal and zero everywhere
> else to the matrix with .., -3, -2, -1, 0, 1, 2, 3, .. as subdiagonal.
>
> (4) For a comparison of different extensions run this:
>
> def _binomial(n,k, pascal = true, reflection = true, uppernegation = true):
>     def b(n,k): return factorial(n)/(factorial(k)*factorial(n-k))
>     if pascal and n >= 0 and k >= 0 and k <= n: return b(n,k) 
>     if reflection and n < 0 and k < 0 and k <= n: return 
> (-1)^(n-k)*b(-k-1,n-k) 
>     if uppernegation and n < 0 and k >= 0: return (-1)^k*b(k-n-1,k) 
>     return 0
>
> R = [n for n in (-5..5)]
> print "(1) Pascal's triangle, for the ultra-orthodox."
> print "(cf. [BP])" 
> for n in R: print [_binomial(n,k,true,false,false) for k in R]
> print "(2) Current behavior of Sage, also Magma, extends (1)."    
> for n in R: print [_binomial(n,k,true,false,true) for k in R]
> print "(3) Suggested behavior."
> print "Also Maple and Mathematica, extends (1) and (2)."    
> print "(cf. [RS], p.5071)" 
> for n in R: print [_binomial(n,k,true,true,true) for k in R]
> print "(4) Extends (1) by reflection only."
> print "(cf. [LMMS], p.637)" 
> for n in R: print [_binomial(n,k,true,true,false) for k in R]
>
> (5) References
>
> [BP] Blaise Pascal; Traité du triangle arithmétique; G. Desprez, 1665. 
> [LMMS] Ana Luzón, Donatella Merlini, Manuel A. Morón, Renzo Sprugnoli;
> Identities induced by Riordan arrays; Linear Algebra and its Applications, 
> 436 (2012) 631-647
> [WP] Pascal's triangle
> https://en.wikipedia.org/wiki/Pascal's_triangle#Extensions
> [MJK] M. J. Kronenburg; The Binomial Coefficient for Negative Arguments; 
> arXiv:1105.3689v2
> [RS] Renzo Sprugnoli; Negation of binomial coefficients; Discrete 
> Mathematics 308 (2008) 5070–5077
> [PL] Peter Luschny; Extensions of the binomial; Blog post;
> http://oeis.org/wiki/User:Peter_Luschny/ExtensionsOfTheBinomial
> [trac] http://trac.sagemath.org/ticket/17123
>
> I'd like to hear your opinions.
>
> Peter


-- 

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

Reply via email to