Expand description
The upper incomplete gamma function Gamma(n, z) of integer and half-integer degree.
upper_gamma takes whichever of the continued fraction, power series, Kummer sum and
degree recurrence (DLMF 8) keeps relative accuracy at the argument.
ScaledGammaLadder steps through the scaled values Gamma(d, a) / a^d at
descending degrees, which the Kambe series sums.
Upstream: incgamma of treams/special/_integrals.pyx, which runs the degree
recurrence only. The choice of method and the scaled ladder are treams-rs extensions.
Structsยง
- Scaled
Gamma ๐Ladder - Scaled incomplete gamma functions
R(d) = Gamma(d, a) / a^dof one argument at descending degreesd = n, n-1, ...: downward byR(d) = (a R(d+1) - e^-a) / d, which is stable once|d| >= |a|, and above that upward from oneupper_gammaevaluation up toLADDER_RUNdegrees lower. Ata = 0every value is the limit-1/d.reflectedselects the branch-sqrt(a)for half-integer degrees.
Constantsยง
- GAMMA_
SERIES_ ๐RADIUS - Largest
|z|at whichgamma_seriesis used. It needs about2|z|terms of size up toe^|z|; with the powerz^nsplit in two factors every intermediate stays representable for|n| <=MAX_DEGREE. - LADDER_
RUN ๐ - Degrees per upward run of
ScaledGammaLadder. Short runs keep the seed far below|a|in degree magnitude, where the continued fraction converges quickly, and avoid evaluating degrees that a short series never reaches. - RECURRENCE_
GROWTH ๐ - Largest growth of the relative rounding error accepted from one method without trying another (one digit).
- SERIES_
PARABOLA ๐ - Bound on
|z| + Re zof the parabola around the negative real axis inside which the power series terms share a phase: their cancellation stays belowe.
Functionsยง
- continued_
fraction ๐ - The continued fraction
hof DLMF 8.9.2,Gamma(n, z) = z^n e^-z hon the principal branch, with whether it converged. - downward_
unstable ๐ - Whether the rounding error of the downward recurrence from
basetongrows beyondRECURRENCE_GROWTH: the step to degreedamplifies it bymax(1, |z|/|d|). - exp1 ๐
- The exponential integral
E1(z) = Gamma(0, z), the start of the integer-degree recurrence. The power series cancels by aboute^(|z| + Re z), while the continued fraction converges slowly next to the negative real axis; beyond|z| = 40the fraction converges there too. - gamma_
derivative ๐ - The argument derivative
dGamma(n, z)/dz = -z^(n-1) e^-z, with its limits-1(n = 1) and0(n > 1) atz = 0. - gamma_
fraction ๐ Gamma(n, z)from DLMF 8.9.2 by modified Lentz iteration, which keeps relative accuracy for negative degree and large|z|away from the negative real axis, and whether it converged.- gamma_
kummer ๐ - The Kummer sum of DLMF 8.7.1 with 8.2.7,
Gamma(a, z) = Gamma(a) - z^a e^-z sum_k z^k / (a (a+1) ... (a+k)), whose terms fall at any phase ofzfor0 < |z| < a, with the magnitude of the terms as the absolute error bound in units of epsilon. - gamma_
recurrence ๐ - The degree recurrence DLMF 8.8.2 from
E1(integer degree) orsqrt(pi) erfc(sqrt z)(half-integer degree), with powers ofzupdated by one multiplication per step (integer degrees stay real on the real axis), and a first-order bound on the absolute error in units of epsilon from the start value and each endpoint term.modulusis|z|. - gamma_
series ๐ - The power series of DLMF 8.7.3,
Gamma(a,z) = Gamma(a) - z^a sum_k (-z)^k / (k! (a+k)), whose terms share a phase near the negative real axis; fora = -m, DLMF 8.4.15 replaces theGamma(a)pole pair by(-1)^m (psi(m+1) - ln z) / m!. The principal logarithm and the signed zero ofIm zselect the side of the cut; the magnitude of the terms bounds the error. - half_
power ๐ z^degreeon the principal branch for an integer or half-integer degree. Integer degrees stay exactly real on the real axis, unlikeexp(degree ln z).- inverse ๐
1/zwithout squaring|z|:num_complexโsinv()divides by|z|^2, which loses precision below|z| = 1e-154and underflows to NaN results below1e-162.- normal ๐
- Whether
1e-290 <= |x| < 1e290, from the larger component of a finitexunless|x|lies near either end (|x|is at mostsqrt 2times that component). - upper_
gamma ๐ - The upper incomplete gamma function
Gamma(n, z)of integer or half-integern.