Skip to content

GammaRegularized ​

The regularized upper incomplete gamma function Q(a,z)=Γ(a,z)/Γ(a)Q(a, z) = \Gamma(a, z)/\Gamma(a), the survival function of the Gamma(a, 1) distribution.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageGammaRegularized!
GammaRegularized(a, z)the regularized upper incomplete gamma Q(a,z)=Γ(a,z)/Γ(a)Q(a, z) = \Gamma(a, z)/\Gamma(a).
Juliaenumeratio_ball(gamma_regularized, a, z)Rustgamma_regularized(a, z)
GammaRegularized(a, z0, z1)the regularized difference (Γ(a,z0)−Γ(a,z1))/Γ(a)(\Gamma(a, z_0) - \Gamma(a, z_1))/\Gamma(a); at z0=0z_0 = 0 the LOWER regularized P(a,z1)=1−Q(a,z1)P(a, z_1) = 1 - Q(a, z_1).
Juliaenumeratio_ball((a, z0, z1) -> gamma_regularized(a, z0) - gamma_regularized(a, z1), a, z0, z1)
Typed signatures
TypePackageApplies
(complex | infinity, complex | infinity) -> numbercompute-enginealways
(complex | infinity, complex | infinity, (complex | infinity)?) -> numberanalyticreplaces compute-enginealways

Domain: Special functions

Details
  • Complementary to the lower regularized P(a,z)=1−Q(a,z)P(a, z) = 1 - Q(a, z), which is the three-argument Q(a,0,z)Q(a, 0, z) (@enumeratio/analytic) -- the Gamma-distribution CDF, and with a=k/2a = k/2, z=x/2z = x/2 the χk2\chi^2_k CDF.
  • Q(a,0)=1Q(a, 0) = 1 for any a>0a > 0: all the mass sits to the right of 0.
  • For a positive integer n it has a closed polynomial form, Q(n,z)=e−z∑k=0n−1zk/k!Q(n, z) = e^{-z}\sum_{k=0}^{n-1} z^k/k!, which compute-engine uses to evaluate exactly, even for negative z.
  • Gives the Poisson CDF tail and the Gamma-distribution survival function, so it shows up throughout reliability and queueing models. See Gamma.
  • The three-argument form divides the difference by Γ(a)\Gamma(a) rather than subtracting two QQ values, so Q(a,0,z)=1−Q(a,z)Q(a, 0, z) = 1 - Q(a, z) holds for negative aa too, where Γ(a,0)\Gamma(a, 0) and Γ(a)\Gamma(a) are separately infinite but their ratio is 1. That is Wolfram's convention.
  • A genuinely complex aa or zz, which the built-in handler declines, is evaluated as Γ(a,z)/Γ(a)\Gamma(a, z)/\Gamma(a) (@enumeratio/analytic) -- Gamma itself takes complex arguments. So is a non-integer real aa with z<0z < 0, whose value is complex (principal branch, ln⁡z=ln⁡∣z∣+iπ\ln z = \ln|z| + i\pi): Q(5/2,−1)=1−0.628 iQ(5/2, -1) = 1 - 0.628\,i. Computed in doubles from Q=1−R eiπaQ = 1 - R\,e^{i\pi a} with a positive series for RR; it stays unevaluated past what doubles hold, and where Re⁡Q\operatorname{Re} Q would lose digits to cancellation (an order near an even integer or near 0).

Plot

the complex plot cannot lower GammaRegularized

Examples

8 more kept as data, checked against the oracles
Basic #

Q(a,0)=1Q(a, 0) = 1 for any aa

live ↗
InGammaRegularized⁡(1,0)\operatorname{GammaRegularized}(1, 0)Out11

Q(1,z)=e−zQ(1, z) = e^{-z}, here at z=1z = 1

live ↗
InGammaRegularized⁡(1,1)\operatorname{GammaRegularized}(1, 1)Out1e\frac{1}{e}

Floating-point arguments evaluate directly to a high-precision decimal

live ↗
InGammaRegularized⁡(2.5,1.5)\operatorname{GammaRegularized}(2.5, 1.5)Out0.699 985 835 878 627 509 10.699\,985\,835\,878\,627\,509\,1

Q(1,z)=e−zQ(1, z) = e^{-z} at z=1.5z = 1.5

live ↗
InGammaRegularized⁡(1,1.5)\operatorname{GammaRegularized}(1, 1.5)Out0.223 130 160 148 429 828 9330.223\,130\,160\,148\,429\,828\,933

Q(2,3.3)=4.3 e−3.3Q(2, 3.3) = 4.3\,e^{-3.3}

live ↗
InGammaRegularized⁡(2,3.3)\operatorname{GammaRegularized}(2, 3.3)Out0.158 597 619 825 332 023 416 080.158\,597\,619\,825\,332\,023\,416\,08

Threads element-wise over a list, as Wolfram's Listable heads do

live ↗
InGammaRegularized⁡([1,2],1)\operatorname{GammaRegularized}(\bigl\lbrack1, 2\bigr\rbrack, 1)Out[1e,2e]\bigl\lbrack\frac{1}{e}, \frac{2}{e}\bigr\rbrack

Complex order, under N()

live ↗
InN(GammaRegularized⁡(1+i,2.5))N(\operatorname{GammaRegularized}(1+i, 2.5))Out0.007 947 060 620 119 186 222 373 870 025 622 117 84+0.152 536 778 541 018 44i0.007\,947\,060\,620\,119\,186\,222\,373\,870\,025\,622\,117\,84+0.152\,536\,778\,541\,018\,44i

Three arguments: Q(a,z0)−Q(a,z1)Q(a, z_0) - Q(a, z_1), the Gamma(5/2) mass between 1/21/2 and 3/23/2

live ↗
InGammaRegularized⁡(2.5,0.5,1.5)\operatorname{GammaRegularized}(2.5, 0.5, 1.5)Out0.262 579 937 368 668 970.262\,579\,937\,368\,668\,97

...which at an integer order equally evaluates, to 32e−1/2−52e−3/2\frac32e^{-1/2} - \frac52e^{-3/2}

live ↗
InGammaRegularized⁡(2,0.5,1.5)\operatorname{GammaRegularized}(2, 0.5, 1.5)Out0.351 970 589 197 875 550.351\,970\,589\,197\,875\,55

Listable over its limits: Q(1,−∞)=∞Q(1, -\infty) = \infty, Q(1,∞)=0Q(1, \infty) = 0

live ↗
InGammaRegularized⁡(1,[−∞,∞])\operatorname{GammaRegularized}(1, \bigl\lbrack-∞, ∞\bigr\rbrack)Out[∞,0]\bigl\lbrack∞, 0\bigr\rbrack

Listable: threads elementwise over a matrix

live ↗
InGammaRegularized⁡(2,[[3.5,0],[0,6.5]])\operatorname{GammaRegularized}(2, \bigl\lbrack\bigl\lbrack3.5, 0\bigr\rbrack, \bigl\lbrack0, 6.5\bigr\rbrack\bigr\rbrack)Out[[0.135 888 225 400 433 24,1],[1,0.011 275 793 947 331 794]]\bigl\lbrack\bigl\lbrack0.135\,888\,225\,400\,433\,24, 1\bigr\rbrack, \bigl\lbrack1, 0.011\,275\,793\,947\,331\,794\bigr\rbrack\bigr\rbrack

Interval arithmetic: QQ is decreasing in zz

live ↗
InGammaRegularized⁡(25,Interval(0.21,0.22))\operatorname{GammaRegularized}(\frac{2}{5}, \mathrm{Interval}(0.21, 0.22))OutInterval(0.421 244 895 791 953 23,0.430 390 666 940 599 5)\mathrm{Interval}(0.421\,244\,895\,791\,953\,23, 0.430\,390\,666\,940\,599\,5)

To 30 significant digits, the last one correctly rounded

live ↗
InN(GammaRegularized⁡(2,1),30)N(\operatorname{GammaRegularized}(2, 1), 30)Out0.735 758 882 342 884 643 191 047 540 3230.735\,758\,882\,342\,884\,643\,191\,047\,540\,323

Q(s,z)Q(s, z) at a complex order ss — beyond what the native two-argument handler covers

live ↗
InN(GammaRegularized⁡(2+i,1.5))N(\operatorname{GammaRegularized}(2+i, 1.5))Out0.617 652 231 045 064 133 665 033 103 829 741 524 6+0.333 481 540 658 552 3i0.617\,652\,231\,045\,064\,133\,665\,033\,103\,829\,741\,524\,6+0.333\,481\,540\,658\,552\,3i

The CDF of a Poisson(λ=2\lambda=2) random variable at k=2k=2 is Q(3,2)=5/e2Q(3, 2) = 5/e^2

live ↗
InGammaRegularized⁡(3,2)\operatorname{GammaRegularized}(3, 2)Out5e2\frac{5}{e^2}

Three arguments: P(5/2,3/2)=Q(5/2,0,3/2)P(5/2, 3/2) = Q(5/2, 0, 3/2), the Gamma(5/2, 1) distribution's CDF at 3/23/2

live ↗
InGammaRegularized⁡(2.5,0,1.5)\operatorname{GammaRegularized}(2.5, 0, 1.5)Out0.300 014 164 121 371 940.300\,014\,164\,121\,371\,94

Known value · mpmath 1.3.0 gammainc

The χ12\chi^2_1 CDF, P(1/2,x/2)P(1/2, x/2), at the familiar critical value x=3.8415x = 3.8415: 95%

live ↗
In1−GammaRegularized⁡(0.5,1.920 729 410 347 042 5)1-\operatorname{GammaRegularized}(0.5, 1.920\,729\,410\,347\,042\,5)Out0.949 999 999 999 998 778 643 70.949\,999\,999\,999\,998\,778\,643\,7

The polynomial closed form for an integer order extends validly to negative zz too, following the analytic continuation

live ↗
InGammaRegularized⁡(5,−1)\operatorname{GammaRegularized}(5, -1)Out3e8\frac{3e}{8}

Q(a,0,z)=1−Q(a,z)Q(a, 0, z) = 1 - Q(a, z) even for negative aa, where Γ(a,0)\Gamma(a, 0) and Γ(a)\Gamma(a) are each infinite but their ratio is 1

live ↗
InGammaRegularized⁡(−1.5,0,1.5)\operatorname{GammaRegularized}(-1.5, 0, 1.5)Out0.985 260 074 360 347 20.985\,260\,074\,360\,347\,2

Known value · Wolfram 15.0.0 GammaRegularized

Q(a,0)=1Q(a, 0) = 1 for symbolic aa

live ↗
InGammaRegularized⁡(a,0)\operatorname{GammaRegularized}(a, 0)Out11

Q(a,∞)=0Q(a, \infty) = 0

live ↗
InGammaRegularized⁡(a,∞)\operatorname{GammaRegularized}(a, ∞)Out00

Q(1,x)=e−xQ(1, x) = e^{-x} symbolically

live ↗
InGammaRegularized⁡(1,x)\operatorname{GammaRegularized}(1, x)Oute−xe^{-x}

Q(2,x)=(1+x)e−xQ(2, x) = (1 + x)e^{-x}, through Q(s,x)=Γ(s,x)/Γ(s)Q(s,x) = \Gamma(s,x)/\Gamma(s) now that Γ(2,x)\Gamma(2,x) has a closed form

live ↗
InGammaRegularized⁡(2,x)\operatorname{GammaRegularized}(2, x)Out(x+1)e−x(x+1)e^{-x}

Q(1/2,x)=erfc⁡(x)Q(1/2, x) = \operatorname{erfc}(\sqrt x). See Erfc

live ↗
InGammaRegularized⁡(12,x)\operatorname{GammaRegularized}(\frac{1}{2}, x)Outerfc⁡(x)\operatorname{erfc}(\sqrt{x})

A non-integer order combined with negative z is complex, on the principal branch of the logarithm

live ↗
InGammaRegularized⁡(2.5,−1)\operatorname{GammaRegularized}(2.5, -1)Out1−0.628 008 230 288 381 4i1-0.628\,008\,230\,288\,381\,4i
Possible issues #

Q(0,0)Q(0, 0): both Γ(0,0)\Gamma(0, 0) and Γ(0)\Gamma(0) diverge at the same rate — Indeterminate, not NaN

live ↗
InGammaRegularized⁡(0,0)\operatorname{GammaRegularized}(0, 0)OutIndeterminate⁡\operatorname{Indeterminate}
About
Examples34
Checked againstWolfram Language 31 agree3 differSageMath 19 agree1 unevaluated1 errorSymPy 19 agree1 differ2 unevaluatedJulia 25 agree3 errorRust 8 agree5 error
CrosswalkWolfram LanguageJulia ×2Rust

Implementation

mappedsympypackages/oracle/src/mappings.ts

SymPy has no regularized incomplete gamma; it is written out as its definition, Gamma(a, z) / Gamma(a).

mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts

a, z > 0 only.

See also: Gamma, BetaRegularized