BINOM 3CW "26 December 2009" "mathcw-1.00"

Table of contents


NAME

binom - binomial coefficient n-over-k (or n-choose-k)

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>

extern float binomf (int n, int k);

extern double binom (int n, int k);

extern long double binoml (int n, int k);

extern __float80 binomw (int n, int k);

extern __float128 binomq (int n, int k);

extern long_long_double binomll (int n, int k);

extern decimal_float binomdf (int n, int k);

extern decimal_double binomd (int n, int k);

extern decimal_long_double binomdl (int n, int k);

extern decimal_long_long_double binomdll (int n, int k);

NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.


DESCRIPTION

Find the value of binom(n,k), equivalent to n! by fast table lookup with minimal additional computation, where k >= 0 and n >= k.

This is the coefficient of x**k and y**k in the binomial expansion of (x + y)**n. It is also the number of ways of choosing k unordered elements from a set of n distinct objects, and thus, may be called either binomial-n-over-k or n-choose-k.

Near, but just below, the overflow limit, it may be possible for binom(n,k) to return a finite value, even when n! overflows.


RETURN VALUES

Return the value of binom(n,k). The value should be correctly rounded in at least the single- and double-precision data formats in decimal and binary. For other formats, and large n the relative error should be less than five ulps (units in the last place).

ERRORS

If the arguments are zero or negative, or if k > n, set errno to EDOM and return a quiet NaN.

SEE ALSO

dfact(3CW), fact(3CW).