Qu

gammainc

Builtin index · Core maths

gammainc(x, a, [tail])

Input: x, a, tail · Output: no output

What it is

Regularized incomplete gamma function: P(a, x) = γ(a, x) / Γ(a) for tail = "lower" (the default) or Q(a, x) = 1 - P(a, x) for tail = "upper", with P(1, x) = 1 - exp(-x) and P(1/2, x) = erf(sqrt(x)). x >= 0 and a >= 0 are real numbers or same-shape Vec/Mats (a number pairs with every element). Power series for x < a + 1, continued fraction beyond, with the x^a e^-x / Γ(a) prefactor in Loader's saddle-point form for a >= 10; the tail asked for is computed directly, so gammainc(40, 2, "upper") keeps its relative accuracy. Accuracy: a 12-point table checked against mpmath at 40 digits (including a = 1e5) agrees to 2e-14; against 2800 random points with a up to 1e4 the median error is 2e-16, 99% are within 5e-13 and the worst seen is 7e-12 (a near 7e3). The cost grows like sqrt(a). P(0, x) = 1, x = 0 gives 0/1, x = inf gives 1/0; a negative x or a, or NaN, gives NaN. Errors: a tail other than "lower"/"upper", mismatched shapes, complex input.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
gammainc(x, a, [tail])
x number, Vec, or Matx >= 0 and a >= 0 are real numbers or same-shape Vec/Mats (a number pairs with every element).
a —a negative x or a, or NaN, gives NaN.
tail optionalRegularized incomplete gamma function: P(a, x) = γ(a, x) / Γ(a) for tail = "lower" (the default) or Q(a, x) = 1 - P(a, x) for tail = "upper", with P(1, x) = 1 - exp(-x) and P(1/2, x) = erf(sqrt(x)).
not documented yet—

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.