File: combinatorics.man

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (108 lines) | stat: -rw-r--r-- 2,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin math::combinatorics n 1.2.3]
[moddesc   {Tcl Math Library}]
[titledesc {Combinatorial functions in the Tcl Math Library}]
[category  Mathematics]
[require Tcl 8.2]
[require math [opt 1.2.3]]
[description]
[para]

The [package math] package contains implementations of several
functions useful in combinatorial problems.

[section COMMANDS]
[list_begin definitions]

[call [cmd ::math::ln_Gamma] [arg z]]

Returns the natural logarithm of the Gamma function for the argument
[arg z].

[para]

The Gamma function is defined as the improper integral from zero to
positive infinity of

[example {
  t**(x-1)*exp(-t) dt
}]

[para]

The approximation used in the Tcl Math Library is from Lanczos,
[emph {ISIAM J. Numerical Analysis, series B,}] volume 1, p. 86.
For "[var x] > 1", the absolute error of the result is claimed to be
smaller than 5.5*10**-10 -- that is, the resulting value of Gamma when

[example {
  exp( ln_Gamma( x) )
}]

is computed is expected to be precise to better than nine significant
figures.

[call [cmd ::math::factorial] [arg x]]

Returns the factorial of the argument [arg x].

[para]

For integer [arg x], 0 <= [arg x] <= 12, an exact integer result is
returned.

[para]

For integer [arg x], 13 <= [arg x] <= 21, an exact floating-point
result is returned on machines with IEEE floating point.

[para]

For integer [arg x], 22 <= [arg x] <= 170, the result is exact to 1
ULP.

[para]

For real [arg x], [arg x] >= 0, the result is approximated by
computing [term Gamma(x+1)] using the [cmd ::math::ln_Gamma]
function, and the result is expected to be precise to better than nine
significant figures.

[para]

It is an error to present [arg x] <= -1 or [arg x] > 170, or a value
of [arg x] that is not numeric.

[call [cmd ::math::choose] [arg {n k}]]

Returns the binomial coefficient [term {C(n, k)}]

[example {
   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.

[para]

Integer results are exact up to at least [arg n] = 34.  Floating point
results are precise to better than nine significant figures.

[call [cmd ::math::Beta] [arg {z w}]]

Returns the Beta function of the parameters [arg z] and [arg w].

[example {
   Beta(z,w) = Beta(w,z) = Gamma(z) * Gamma(w) / Gamma(z+w)
}]

Results are returned as a floating point number precise to better than
nine significant digits provided that [arg w] and [arg z] are both at
least 1.

[list_end]

[vset CATEGORY math]
[include ../common-text/feedback.inc]
[manpage_end]