::math::ln_Gammaz
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 of
t**(x-1)*exp(-t) dt
The approximation used in the Tcl Math Library is from Lanczos, ISIAMJ.NumericalAnalysis,seriesB,
volume 1, p. 86. For "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
exp( ln_Gamma( x) )
is computed is expected to be precise to better than nine significant figures.
::math::factorialx
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 ::math::ln_Gamma
function, and the result is expected to be precise to better than nine significant figures.
It is an error to present x <= -1 or x > 170, or a value of x that is not numeric.
::math::choosenk
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.
::math::Betazw
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 better than nine significant digits
provided that w and z are both at least 1.
::math::combinatorics::permutationsn
Return the number of permutations of n items. The returned number is always an integer, it is not
limited by the range of 32-or 64-bits integers using the arbitrary precision integers available in
Tcl 8.5 and later.
int n The number of items to be permuted.
::math::combinatorics::variationsnk
Return the number of variations k items selected from the total of n items. The order of the
items is taken into account.
int n The number of items to be selected from.
int k The number of items to be selected in each variation.
::math::combinatorics::combinationsnk
Return the number of combinations of k items selected from the total of n items. The order of the
items is not important.
int n The number of items to be selected from.
int k The number of items to be selected in each combination.
::math::combinatorics::derangementsn
Return the number of derangements of n items. A derangement is a permutation where each item is
displaced from the original position.
int n The number of items to be rearranged.
::math::combinatorics::catalann
Return the n'th Catalan number. The number n is expected to be 1 or larger. These numbers occur
in various combinatorial problems.
int n The index of the Catalan number
::math::combinatorics::firstStirlingnm
Calculate a Stirling number of the first kind (signed version, m cycles in a permutation of n
items)
int n Number of items
int m Number of cycles
::math::combinatorics::secondStirlingnm
Calculate a Stirling number of the second kind (m non-empty subsets from n items)
int n Number of items
int m Number of subsets
::math::combinatorics::partitionPn
Calculate the number of ways an integer n can be written as the sum of positive integers.
int n Number in question
::math::combinatorics::list-permutationsn
Return the list of permutations of the numbers 0, ..., n-1.
int n The number of items to be permuted.
::math::combinatorics::list-variationsnk
Return the list of variations of k numbers selected from the numbers 0, ..., n-1. The order of
the items is taken into account.
int n The number of items to be selected from.
int k The number of items to be selected in each variation.
::math::combinatorics::list-combinationsnk
Return the list of combinations of k numbers selected from the numbers 0, ..., n-1. The order of
the items is ignored.
int n The number of items to be selected from.
int k The number of items to be selected in each combination.
::math::combinatorics::list-derangementsn
Return the list of derangements of the numbers 0, ..., n-1.
int n The number of items to be rearranged.
::math::combinatorics::list-powersetn
Return the list of all subsets of the numbers 0, ..., n-1.
int n The number of items to be rearranged.
::math::combinatorics::permutationObj new/create NAME n
Create a TclOO object for returning permutations one by one. If the last permutation has been
reached an empty list is returned.
int n The number of items to be rearranged.
$perm next
Return the next permutation of n objects.
$perm reset
Reset the object, so that the command next returns the complete list again.
$perm setElements elements
Register a list of items to be permuted, using the nextElements command.
list elements
The list of n items that will be permuted.
$perm setElements
Return the next permulation of the registered items.
::math::combinatorics::combinationObj new/create NAME nk
Create a TclOO object for returning combinations one by one. If the last combination has been
reached an empty list is returned.
int n The number of items to be rearranged.
$combin next
Return the next combination of n objects.
$combin reset
Reset the object, so that the command next returns the complete list again.
$combin setElements elements
Register a list of items to be permuted, using the nextElements command.
list elements
The list of n items that will be permuted.
$combin setElements
Return the next combination of the registered items.