1math::combinatorics(n)         Tcl Math Library         math::combinatorics(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       math::combinatorics - Combinatorial functions in the Tcl Math Library
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require math  ?1.2.3?
14
15       ::math::ln_Gamma z
16
17       ::math::factorial x
18
19       ::math::choose n k
20
21       ::math::Beta z w
22
23_________________________________________________________________
24

DESCRIPTION

26       The  math  package contains implementations of several functions useful
27       in combinatorial problems.
28

COMMANDS

30       ::math::ln_Gamma z
31              Returns the natural logarithm of  the  Gamma  function  for  the
32              argument z.
33
34              The Gamma function is defined as the improper integral from zero
35              to positive infinity of
36
37                t**(x-1)*exp(-t) dt
38
39
40              The approximation used in the Tcl Math Library is from  Lanczos,
41              ISIAM  J. Numerical Analysis, series B, volume 1, p. 86.  For "x
42              > 1", the absolute error of the result is claimed to be  smaller
43              than 5.5*10**-10 -- that is, the resulting value of Gamma when
44
45                exp( ln_Gamma( x) )
46
47              is  computed  is expected to be precise to better than nine sig‐
48              nificant figures.
49
50       ::math::factorial x
51              Returns the factorial of the argument x.
52
53              For integer x, 0  <=  x  <=  12,  an  exact  integer  result  is
54              returned.
55
56              For  integer x, 13 <= x <= 21, an exact floating-point result is
57              returned on machines with IEEE floating point.
58
59              For integer x, 22 <= x <= 170, the result is exact to 1 ULP.
60
61              For real x, x >= 0, the  result  is  approximated  by  computing
62              Gamma(x+1)  using  the ::math::ln_Gamma function, and the result
63              is expected to be precise to better than nine  significant  fig‐
64              ures.
65
66              It  is  an  error to present x <= -1 or x > 170, or a value of x
67              that is not numeric.
68
69       ::math::choose n k
70              Returns the binomial coefficient C(n, k)
71
72                 C(n,k) = n! / k! (n-k)!
73
74              If both parameters are integers and the result fits in 32  bits,
75              the result is rounded to an integer.
76
77              Integer results are exact up to at least n = 34.  Floating point
78              results are precise to better than nine significant figures.
79
80       ::math::Beta z w
81              Returns the Beta function of the parameters z and w.
82
83                 Beta(z,w) = Beta(w,z) = Gamma(z) * Gamma(w) / Gamma(z+w)
84
85              Results are returned as a floating point number precise to  bet‐
86              ter  than nine significant digits provided that w and z are both
87              at least 1.
88
89
90
91math                                 1.2.3              math::combinatorics(n)
Impressum