# combinatorics(n) [osx man page]

```math::combinatorics(n)						 Tcl Math Library					    math::combinatorics(n)

__________________________________________________________________________________________________________________________________________________

NAME
math::combinatorics - Combinatorial functions in the Tcl Math Library

SYNOPSIS
package require Tcl  8.2

package require math  ?1.2.3?

::math::ln_Gamma z

::math::factorial x

::math::choose n k

::math::Beta z w

_________________________________________________________________

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

COMMANDS
::math::ln_Gamma 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 of

t**(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 "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::factorial 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  ::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::choose 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.

::math::Beta 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 better than nine significant digits provided that w and z are both at
least 1.

BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems.  Please report such in the category math	of
the  Tcllib  SF	Trackers [http://sourceforge.net/tracker/?group_id=12883].  Please also report any ideas for enhancements you may have for
either package and/or documentation.

CATEGORY
Mathematics

math								       1.2.3						    math::combinatorics(n)```

## Check Out this Related Man Page

```math(3tcl)							 Tcl Math Library							math(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
math - Tcl Math Library

SYNOPSIS
package require Tcl  8.2

package require math  ?1.2.5?

::math::cov value value ?value ...?

::math::integrate list of xy value pairs

::math::fibonacci n

::math::max value ?value ...?

::math::mean value ?value ...?

::math::min value ?value ...?

::math::product value ?value ...?

::math::random ?value1? ?value2?

::math::sigma value value ?value ...?

::math::stats value value ?value ...?

::math::sum value ?value ...?

_________________________________________________________________

DESCRIPTION
The math package provides utility math functions.

Besides a set of basic commands, available via the package math, there are more specialised packages:

o      math::bigfloat - Arbitrary-precision floating-point arithmetic

o      math::bignum - Arbitrary-precision integer arithmetic

o      math::calculus::romberg - Robust integration methods for functions of one variable, using Romberg integration

o      math::calculus - Integration of functions, solving ordinary differential equations

o      math::combinatorics - Procedures for various combinatorial functions (for instance the Gamma function and "k out of n")

o      math::complexnumbers - Complex number arithmetic

o      math::constants - A set of well-known mathematical constants, such as Pi, E, and the golden ratio

o      math::fourier - Discrete Fourier transforms

o      math::fuzzy - Fuzzy comparisons of floating-point numbers

o      math::geometry - 2D geometrical computations

o      math::interpolate - Various interpolation methods

o      math::linearalgebra - Linear algebra package

o      math::optimize - Optimization methods

o      math::polynomials - Polynomial arithmetic (includes families of classical polynomials)

o      math::rationalfunctions - Arithmetic of rational functions

o      math::roman - Manipulation (including arithmetic) of Roman numerals

o      math::special - Approximations of special functions from mathematical physics

o      math::statistics - Statistical operations and tests

BASIC COMMANDS
::math::cov value value ?value ...?
Return the coefficient of variation expressed as percent of two or more numeric values.

::math::integrate list of xy value pairs
Return the area under a "curve" defined by a set of x,y pairs and the error bound as a list.

::math::fibonacci n
Return the n'th Fibonacci number.

::math::max value ?value ...?
Return the maximum of one or more numeric values.

::math::mean value ?value ...?
Return the mean, or "average" of one or more numeric values.

::math::min value ?value ...?
Return the minimum of one or more numeric values.

::math::product value ?value ...?
Return the product of one or more numeric values.

::math::random ?value1? ?value2?
Return a random number.  If no arguments are given, the number is a floating point value between 0 and 1.  If one argument is given,
the number is an integer value between 0 and value1.  If two arguments are given, the number is an integer value between value1  and
value2.

::math::sigma value value ?value ...?
Return the population standard deviation of two or more numeric values.

::math::stats value value ?value ...?
Return the mean, standard deviation, and coefficient of variation (as percent) as a list.

::math::sum value ?value ...?
Return the sum of one or more numeric values.

BUGS, IDEAS, FEEDBACK
This  document, and the package it describes, will undoubtedly contain bugs and other problems.	Please report such in the category math of
the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883].  Please also report any ideas for enhancements you  may  have  for
either package and/or documentation.

KEYWORDS
math, statistics

CATEGORY
Mathematics

math								       1.2.5								math(3tcl)```
Man Page