Additional real gamma functions (real arguments only)#

Reciprocal Gamma function, \(1/\Gamma(x)\)#

ctx.real_rgamma(z)#

where ctx is math53, ctxcpp, ctxboost or ctxflint.

Returns the reciprocal of gamma function \(z\), \(1/\Gamma(z)\). See also Wikipedia [1374], MathWorld [967], Flint [805], Flint [795], Mpmath [627].

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '10.5'
>>> \mathrm{d}x = dec.rgamma(x); mx = mpm.rgamma(x); ix = ipm.rgamma(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  8.823957200203800905509402624256928377655E-7
mpm:  8.823957200203800905509402624256928377655e-7
ipm:  8.823957200203800905509402624256928377655e-7 (1.861e-39%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '10.5'
>>> fx = fpm.rgamma(x); gx = gmp.rgamma(x); ax = apm.rgamma(x)
>>> mpm.show([fx, gx, ax])
fpm:  8.82395720020380E-07
gmp:  8.823957200203800905509402624256928377655E-07
apm:  8.823957200203800905509402624256928377655e-7 (6.203e-40%)

This function evaluates to zero at the poles of the gamma function, \(z = 0, -1, -2, \ldots\).

>>> from xlcalcnet import dec, mpr, ivr, ivc
>>> ivr.dps = 25; ivr.pretty = True
>>> rgamma(1)
1.0
>>> rgamma(4)
0.1666666666666666666666667
>>> rgamma(0); rgamma(-1)
0.0
0.0
>>> rgamma(1000)
2.485168143266784862783596e-2565
>>> rgamma(inf)
0.0

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

math53.real_lgamma1p(x)#

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

See also Wikipedia [1375], MathWorld [965], BoostMath [108], Ehrhardt [309] (3.5.1.7).

An example in Python

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

An example in Visual Basic

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

Sign of the gamma function#

math53.real_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 [1364], MathWorld [957], NIST [24], BoostMath [107], Ehrhardt [309] (3.5.1.9).

An example in Python

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

An example in Visual Basic

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

Logarithm and sign of the gamma function#

math53.real_lgamma_s(x, s)#

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

See also Wikipedia [1364], MathWorld [957], NIST [24], BoostMath [107], Ehrhardt [309] (3.5.1.10).

An example in Python

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

An example in Visual Basic

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

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

math53.real_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 [1364], MathWorld [957], NIST [24], BoostMath [107], Ehrhardt [309] (3.5.1.4).

An example in Python

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

An example in Visual Basic

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

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

math53.real_logfactorial(n)#

Returns \(\log(x!) = \log(\Gamma(x+1))\). See also Wikipedia [1362], MathWorld [955], BoostMath [105], Ehrhardt [309] (3.5.4.3).

An example in Python

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

An example in Visual Basic

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

Catalan function \(C(x)\)#

ctx.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 [1045], Wikipedia [1445], Ehrhardt [309] (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%)

Logarithm of the binomial coefficient#

math53.real_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 [1359], MathWorld [954], NIST [509], BoostMath [102], Ehrhardt [309] (3.5.4.5).

An example in Python

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

An example in Visual Basic

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

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

math53.real_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 [1364], MathWorld [957], NIST [24], BoostMath [107], Ehrhardt [309] (3.5.1.3).

An example in Python

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

An example in Visual Basic

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

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

math53.real_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 [1375], MathWorld [965], BoostMath [108], Ehrhardt [309] (3.5.1.6).

An example in Python

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

An example in Visual Basic

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

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

math53.real_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 [309] (3.5.4.7).

An example in Python

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

An example in Visual Basic

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

Beta function, \(B(a,b)\)#

ctx.real_beta(a, b)#

where ctx is math53, ctxcpp, ctxboost or ctxflint.

Returns the beta function \(\displaystyle B(x,y) = \frac{\Gamma(x) \Gamma(y)}{\Gamma(x+y)} = \int_0^1 t^{x-1} (1-t)^{y-1} \, \, \mathrm{d}t\).

See also Wikipedia [1358], MathWorld [953], NIST [23], BoostMath [101], Ehrhardt [309] (3.5.3.1), Mpmath [613].

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; a = '20.4'; b = '10.4'
>>> \mathrm{d}x = dec.beta(a, b); mx = mpm.beta(a, b); ix = ipm.beta(a, b)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  2.693713532046140908251383587041524146973E-9
mpm:  2.693713532046140908251383587041524146974e-9
ipm:  2.693713532046140908251383587041524146972e-9 (2.048e-37%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; a = '20.4'; b = '10.4'
>>> fx = fpm.beta(a, b); gx = gmp.beta(a, b); ax = apm.beta(a, b)
>>> mpm.show([fx, gx, ax])
fpm:  2.69371353204614E-09
gmp:  2.693713532046140908251383587041524146974E-09
apm:  2.693713532046140908251383587041524146975e-9 (6.549e-37%)

Log-Beta function#

ctx.real_logbeta(a, b)#

where ctx is math53, ctxcpp, ctxboost or ctxflint.

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

See also Wikipedia [1358], MathWorld [953], NIST [23], BoostMath [101], Ehrhardt [309] (3.5.3.2), Mpmath [613].

An example in Python

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

An example in Visual Basic

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