Skip to content

Extending binomial(n,k) to negative integers n, k. #17123

@PeterLuschny

Description

@PeterLuschny

A simple and coherent extension of the binomial function
to negative integers n, k was outlined by M. J. Kronenburg in
The Binomial Coefficient for Negative Arguments,
http://arxiv.org/abs/1105.3689
(Thanks to John Palmieri for the reference.)

This extension amounts to define

def BINOMIAL(n, k):
    if n in ZZ and k in ZZ: 
        if n >= 0 and k >= 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)

Here 'BINOMIAL' is the targeted version, 'binomial' the
implemented version. The targeted behaviour is identical
to the behaviour of the Maple and Mathematica function
for negative integers n, k.

CC: @rwst

Component: combinatorics

Keywords: binomial

Branch/Commit: u/chapoton/17123 @ 0c99437

Issue created by migration from https://trac.sagemath.org/ticket/17123

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions