binomial -- binomial
coefficients
Introductionbinomial(n, k) represents the binomial
coefficient n!/k!/(n-k)!.
Call(s)binomial(n, k)
Parametersn, k |
- | arithmetical expressions |
Returnsan arithmetical expression.
Side
EffectsWhen called with floating point arguments, the function is sensitive
to the environment variable DIGITS which determines the numerical
working precision.
Related
Functions
Detailsgamma 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.
Type::Numeric. However, for
k=0, k=1, k=n-1, and k=n,
simplified results are returned for any n.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.
Example
1We 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
2The 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