NAME
combinatorics - Combinatorial functions in the Tcl Math Library
SYNOPSIS
package require TTccll 88..22 package require mmaatthh ??11..22..22?? ::::mmaatthh::::llnnGGaammmmaa z ::::mmaatthh::::ffaaccttoorriiaall x ::::mmaatthh::::cchhoooossee n k ::::mmaatthh::::BBeettaa z wDESCRIPTION
The mmaatthh package contains implementations of several functions useful in combinatorial problems. CCOOMMMMAANNDDSS ::::mmaatthh::::llnnGGaammmmaa z Returns the natural logarithm of the Gamma function for the argument z. The Gamma function is defined as the improper integral from zero to positive infinity oft**(x-1)*exp(-t) dt
The approximation used in the Tcl Math Library is from Lanczos, ISIAM J. Numerical Analysis, series B, volume 1, p. 86. For "xx > 1", the absolute error of the result is claimed to be smallerthan 5.5*10**-10 - that is, the resulting value of Gamma when
exp( lnGamma( x) )is computed is expected to be precise to better than nine sig-
nificant figures. ::::mmaatthh::::ffaaccttoorriiaall x Returns the factorial of the argument x. For integer x, 0 <= x <= 12, an exact integer result is returned.For integer x, 13 <= x <= 21, an exact floating-point result is
returned on machines with IEEE floating point. For integer x, 22 <= x <= 170, the result is exact to 1 ULP. For real x, x >= 0, the result is approximated by computing Gamma(x+1) using the ::::mmaatthh::::llnnGGaammmmaa function, and the resultis expected to be precise to better than nine significant fig-
ures.It is an error to present x <= -1 or x > 170, or a value of x
that is not numeric. ::::mmaatthh::::cchhoooossee n k Returns the binomial coefficient C(n, k)C(n,k) = n! / k! (n-k)!
If both parameters are integers and the result fits in 32 bits, the result is rounded to an integer. Integer results are exact up to at least n = 34. Floating point results are precise to better than nine significant figures. ::::mmaatthh::::BBeettaa z w Returns the Beta function of the parameters z and w. Beta(z,w) = Beta(w,z) = Gamma(z) * Gamma(w) / Gamma(z+w)Results are returned as a floating point number precise to bet-
ter than nine significant digits provided that w and z are both at least 1.math 4.2 combinatorics(n)