## `binomial` -- binomial coefficients

#### Introduction

`binomial``(n, k)` represents the binomial coefficient n!/k!/(n-k)!.

#### Call(s)

`binomial(n, k)`

#### Parameters

`n, k` | - | arithmetical expressions

#### Returns

an arithmetical expression.

#### Side Effects

When called with floating point arguments, the function is sensitive to the environment variable `DIGITS` which determines the numerical working precision.

#### Related Functions

`fact`, `gamma`

#### Details

- Binomial coefficients are defined for complex arguments via the `gamma` function:

      binomial(n,k)=gamma(n+1)/gamma(k+1)/gamma(n-k+1).

  With gamma(n+1)=n!, this coincides with the usual binomial coefficients for integer arguments satisfying 0<=k<=n.
- A symbolic function call is returned if one of the arguments cannot be evaluated to a number of type `Type::Numeric`. However, for k=0, k=1, k=n-1, and k=n, simplified results are returned for any n.
- Let n be a number of type `Type::Numerical`. If k evaluates to a nonnegative integer, then n*(n-1)*..*(n-k+1)/k! is returned. If k evaluates to a negative integer, then 0 is returned. If k evaluates to a floating point number, then a floating point value is returned. In all other cases, a symbolic call of `binomial` is returned.
- A floating point value is returned if both arguments are numerical and at least one of them is a floating point value.

#### Example 1

We demonstrate some calls with exact and symbolic input data:

    >> binomial(10, k) $ k=-2..12

             0, 0, 1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0, 0

    >> binomial(-23/12, 3), binomial(1 + I, 3)

                               -37835/10368, - 1/3 I

    >> binomial(n, k), binomial(n, 1), binomial(n, 4)

                         binomial(n, k), n, binomial(n, 4)

Floating point values are computed for floating point arguments:

    >> binomial(-235/123, 3.0), binomial(3.0, 1 + I)

                     -3.624343742, 4.411293493 + 2.205646746 I

#### Example 2

The `expand` function handles expressions involving `binomial`:

    >> binomial(n, 3) = expand(binomial(n, 3))

                                                 2    3
                                            n   n    n
                           binomial(n, 3) = - - -- + --
                                            3   2    6

    >> binomial(2, k) = expand(binomial(2, k))

                                                  2
             binomial(2, k) = - -------------------------------------
                                 2
                                k  gamma(k) gamma(-k) (1 - k) (2 - k)

The `float` attribute handles `binomial` if all arguments can be converted to floating point numbers:

    >> binomial(sin(3), 5/4), float(binomial(sin(3), 5/4))

                       binomial(sin(3), 5/4), -0.08360571366

#### Changes

- The `expand` attribute now rewrites the result in terms of `gamma`, not in terms of `fact`.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000