Gamma functions#

Sign of the gamma function#

math53.signgamma(x)#

Returns the sign of \(\Gamma(x)\), which is \(+1\) if \(x > 0\) or if \(\lfloor x \rfloor\) is even, \(-1\) otherwise, and meaningless for \(0\) or negative integers.

See also Wikipedia [1259], MathWorld [885], NIST [22], BoostMath [101], Ehrhardt [297] (3.5.1.9).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.SignGamma(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.SignGamma('1.51')
ereal('5.3518479027559984754E-1')

Logarithm and sign of the gamma function#

math53.lgamma_s(x, s)#

Returns (as a tuple) the logarithm and sign of the gamma function.

See also Wikipedia [1259], MathWorld [885], NIST [22], BoostMath [101], Ehrhardt [297] (3.5.1.10).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogGammaS(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.LogGammaS('1.51')
ereal('5.3518479027559984754E-1')

Logarithm of \(\Gamma(1 + x)\)#

math53.lgamma1p(x)#

Returns \(\log|\Gamma(1+x)|\) with increased accuracy for \(x\) near \(0\).

See also Wikipedia [1270], MathWorld [893], BoostMath [102], Ehrhardt [297] (3.5.1.7).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogGamma1p(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.LogGamma1p('1.51')
ereal('5.3518479027559984754E-1')

Logarithm of factorials: \(\log(x!)\)#

math53.logfactorial(n)#

Returns \(\log(x!) = \log(\Gamma(x+1))\). See also Wikipedia [1257], MathWorld [883], BoostMath [99], Ehrhardt [297] (3.5.4.3).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogFactorial(3)
ereal('5.2359877559829887307E-1')
>>> ereal.LogFactorial('0.51')
ereal('5.3518479027559984754E-1')

Logarithm of the binomial coefficient#

math53.logbinomial(n, k)#

Returns the logarithm of the binomial coefficient, \(\displaystyle \log{n \choose k} = \log\left(\frac{n!}{k!(n-k)!}\right)\,\), for \(n\ge k \ge 0\).

See also Wikipedia [1254], MathWorld [882], NIST [485], BoostMath [96], Ehrhardt [297] (3.5.4.5).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogBinomial(13, 7)
ereal('5.2359877559829887307E-1')
>>> ereal.LogBinomial(12.6, '4.51')
ereal('5.3518479027559984754E-1')

Log-Beta function#

math53.logbeta(a, b)#

where ctx is math53, ctxcpp, ctxboost or ctxflint.

Returns the logarithm of \(B(a,b)\)

See also Wikipedia [1253], MathWorld [881], NIST [21], BoostMath [95], Ehrhardt [297] (3.5.3.2), Mpmath [586].

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogBeta(3.1, 0.5)
ereal('5.2359877559829887307E-1')
>>> ereal.LogBeta(3.4, '0.51')
ereal('5.3518479027559984754E-1')

Inverse of the gamma function, \(\Gamma^{-1}(y)\)#

math53.gamma_inv(y)#

Returns \(\Gamma^{-1}(y)\), the functional inverse of the gamma function, i.e. it returns \(x\) with \(\Gamma(x)=y, \, y \ge 0.8857421875\).

See also Wikipedia [1259], MathWorld [885], NIST [22], BoostMath [101], Ehrhardt [297] (3.5.1.3).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.GammaInv(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.GammaInv('1.51')
ereal('5.3518479027559984754E-1')

Inverse of the logarithm of the gamma function, \(\log\Gamma^{-1}(y)\)#

math53.lgamma_inv(y)#

Returns the functional inverse of \(\log\Gamma(x)\), i.e. it returns \(x = \log\Gamma^{-1}(y)\) with \(\log\Gamma(x) = y\) for \(y \ge -0.12142 > y_m\) (the minimum of \(\log\Gamma(x)\) for positive arguments). The result is greater than \(x_m = 1.46163\ldots\) (the positive zero of the \(\psi\) function).

See also Wikipedia [1270], MathWorld [893], BoostMath [102], Ehrhardt [297] (3.5.1.6).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.LogGammaInv(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.LogGammaInv('1.51')
ereal('5.3518479027559984754E-1')

Temme’s regulated gamma function, \(\Gamma^{*}(x)\)#

math53.gammastar(x)#

Returns Temme’s \(\Gamma^{*}(x)\), defined by \(\Gamma(x) = \sqrt{2\pi} e^{-x} x^{x-1/2} \Gamma^{*}(x)\).

See also Wikipedia [1259], MathWorld [885], NIST [22], BoostMath [101], Ehrhardt [297] (3.5.1.4).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.GammaStar(1.5)
ereal('5.2359877559829887307E-1')
>>> ereal.GammaStar('1.51')
ereal('5.3518479027559984754E-1')

Relative Pochhammer symbol, \(((a)_x - 1)/x\)#

math53.poch1(a, x)#

Returns \(\displaystyle \frac{(a)_x - 1}{x}\), accurate also for small \(|x|\). For \(x=0\) the value \(\psi(a)\) is returned.

See also Ehrhardt [297] (3.5.4.7).

An example in Python

>>> from xlcalcnet import ereal
>>> ereal.Poch1(13, 7)
ereal('5.2359877559829887307E-1')
>>> ereal.Poch1(12.6, '4.51')
ereal('5.3518479027559984754E-1')

Catalan function \(C(x)\)#

math53.catalan_c(x)#

where ctx is math53, ctxcpp, ctxboost or ctxflint.

Returns the Catalan function \(\displaystyle C(x) = \frac{1}{x+1} \binom{2x}{x} = \frac{\Gamma(2x+1)}{(x+1)\Gamma(x+1)^2}\).

See also: MathWorld [972], Wikipedia [1339], Ehrhardt [297] (3.10.5).

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '10.5'
>>> \mathrm{d}x = dec.catalan(x); mx = mpm.catalan(x); ix = ipm.catalan(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  3.137576033650317681318411712507890972194E+4
mpm:  3.137576033650317681318411712507890972194e+4
ipm:  3.137576033650317681318411712507890972194e+4 (3.597e-39%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '10.5'
>>> fx = fpm.catalan(x); gx = gmp.catalan(x); ax = apm.catalan(x)
>>> mpm.show([fx, gx, ax])
fpm:  3.13757603365032E+04
gmp:  3.137576033650317681318411712507890972194E+04
apm:  3.137576033650317681318411712507890972194e+4 (3.597e-39%)