Documentation

TauCeti.Analysis.SpecialFunctions.IncompleteGamma

The lower incomplete gamma function #

For a positive shape parameter s this file introduces

Classically these are γ(s, x) and P(s, x). The regularized function is the cumulative distribution function of a Gamma law, which is where this file is headed; the two totalizations above make that cdf agree with the clamping conventions a cdf needs, below the support and outside the parameter range.

Main definitions #

Main results #

Implementation #

The guard 0 < s in the definition of regularizedGamma mirrors the one built into TauCeti.lowerIncompleteGamma, which is the definition shape the roadmap prescribes. It changes no value: γ(s, x) already vanishes for s ≤ 0, so dividing unconditionally would give the same function, and TauCeti.regularizedGamma_eq_div accordingly needs no hypothesis on s.

The limit at infinity is Mathlib's Real.GammaIntegral_convergent together with Real.Gamma_eq_integral, which state Euler's integrand as exp (-t) * t ^ (s - 1); this file uses the opposite factor order throughout, so both are applied up to mul_comm at their point of use.

The recurrence is obtained from Mathlib's Complex.partialGamma_add_one, whose proof performs the integration by parts on Set.Ioo 0 x — the endpoint 0 has to be avoided because t ^ s is not differentiable there for s < 1. The bridge is TauCeti.ofReal_lowerIncompleteGamma_eq_partialGamma, which identifies γ(s, x) with Complex.partialGamma s x for real s.

References #

Convergence of the truncated Euler integral #

theorem TauCeti.intervalIntegrable_rpow_mul_exp_neg {p : ℝ} (hp : -1 < p) (a b : ℝ) :

Euler's integrand t ^ p * exp (-t) is interval integrable, for -1 < p.

This composes Mathlib's intervalIntegral.intervalIntegrable_rpow', which carries the singularity at 0 for p < 0, with the continuous factor. The shape parameter s of TauCeti.lowerIncompleteGamma enters as p = s - 1.

The definitions #

noncomputable def TauCeti.lowerIncompleteGamma (s x : ℝ) :

The lower incomplete gamma function γ(s, x) = ∫ t in 0..x, t ^ (s - 1) * exp (-t).

It is 0 for x ≤ 0, where the truncated integral is empty, and 0 for s ≤ 0, where Euler's integral diverges at the origin.

Equations
Instances For
    noncomputable def TauCeti.regularizedGamma (s x : ℝ) :

    The regularized lower incomplete gamma function P(s, x) = γ(s, x) / Γ(s), extended by 0 outside the valid range 0 < s of the shape parameter.

    Equations
    Instances For
      theorem TauCeti.lowerIncompleteGamma_eq_integral {s x : ℝ} (hs : 0 < s) (hx : 0 ≤ x) :
      lowerIncompleteGamma s x = ∫ (t : ℝ) in 0..x, t ^ (s - 1) * Real.exp (-t)

      In the valid range, γ(s, x) is the truncated Euler integral.

      @[simp]

      Outside the valid range of the shape parameter, γ(s, x) is 0.

      @[simp]

      Below the support, γ(s, x) is 0.

      @[simp]

      Outside the valid range of the shape parameter, P(s, x) is 0.

      P(s, x) is γ(s, x) normalized by Γ(s).

      No hypothesis on the shape parameter is needed: for s ≤ 0 both sides are 0, since γ(s, ·) is.

      @[simp]

      Below the support, P(s, x) is 0.

      Positivity, monotonicity and regularity #

      γ(s, x) is nonnegative, for every parameter value.

      P(s, x) is nonnegative, for every parameter value.

      γ(s, ·) is monotone: it accumulates a nonnegative integrand.

      γ(s, ·) is continuous on all of ℝ.

      For s < 1 this includes the point x = 0, where the integrand is unbounded; the integral is nevertheless convergent there, by TauCeti.intervalIntegrable_rpow_mul_exp_neg.

      P(s, ·) is continuous on all of ℝ.

      theorem TauCeti.hasDerivAt_lowerIncompleteGamma {s x : ℝ} (hs : 0 < s) (hx : 0 < x) :

      γ(s, ·) is differentiable at every positive x, with the expected derivative.

      The hypothesis 0 < x cannot be weakened to 0 ≤ x: among the positive shapes this theorem is stated for, differentiability at 0 holds exactly for 1 < s. For s < 1 the integrand is unbounded at 0, and at s = 1 the clamped function is x ↦ 1 - exp (-max x 0), whose one-sided derivatives at 0 are 0 and 1. (For s ≤ 0 the function is identically 0, hence trivially differentiable everywhere.)

      theorem TauCeti.deriv_lowerIncompleteGamma {s x : ℝ} (hs : 0 < s) (hx : 0 < x) :

      The derivative of γ(s, ·) at a positive point is the integrand.

      theorem TauCeti.hasDerivAt_regularizedGamma {s x : ℝ} (hs : 0 < s) (hx : 0 < x) :

      P(s, ·) is differentiable at every positive x, with the expected derivative. As for TauCeti.hasDerivAt_lowerIncompleteGamma, the hypothesis 0 < x is needed at every shape 0 < s ≤ 1.

      theorem TauCeti.deriv_regularizedGamma {s x : ℝ} (hs : 0 < s) (hx : 0 < x) :

      The derivative of P(s, ·) at a positive point is the normalized integrand.

      The recurrence in the shape parameter #

      theorem TauCeti.ofReal_lowerIncompleteGamma_eq_partialGamma {s x : ℝ} (hs : 0 < s) (hx : 0 ≤ x) :

      For a positive real shape parameter s and 0 ≤ x, γ(s, x) is Mathlib's Complex.partialGamma at (s : ℂ).

      The complex partial gamma function carries the integration by parts behind TauCeti.lowerIncompleteGamma_add_one, so this identification is what lets that recurrence be imported rather than reproved.

      theorem TauCeti.lowerIncompleteGamma_add_one {s x : ℝ} (hs : 0 < s) (hx : 0 ≤ x) :

      The recurrence γ(s + 1, x) = s * γ(s, x) - x ^ s * exp (-x), for 0 < s and 0 ≤ x.

      theorem TauCeti.regularizedGamma_add_one {s x : ℝ} (hs : 0 < s) (hx : 0 ≤ x) :

      The regularized form of the recurrence, P(s + 1, x) = P(s, x) - x ^ s * exp (-x) / Γ(s + 1), for 0 < s and 0 ≤ x. The factor s of TauCeti.lowerIncompleteGamma_add_one is absorbed by Real.Gamma_add_one.

      The limit at infinity #

      γ(s, x) increases to the complete Euler integral Real.Gamma s as x → ∞.

      A truncated Euler integral is at most the complete one.

      P(s, x) increases to 1 as x → ∞: it is the cumulative distribution function of a probability law.

      P(s, x) is at most 1, for every parameter value.

      The exponential case s = 1 #

      @[simp]

      γ(1, x) = 1 - exp (-x) for 0 ≤ x.

      @[simp]
      theorem TauCeti.regularizedGamma_one {x : ℝ} (hx : 0 ≤ x) :

      P(1, x) = 1 - exp (-x) for 0 ≤ x: the regularized lower incomplete gamma function at shape 1 is the cumulative distribution function of the standard exponential law.

      Relation with the error function #

      theorem TauCeti.hasDerivAt_regularizedGamma_half_sq {x : ℝ} (hx : 0 < x) :
      HasDerivAt (fun (y : ℝ) => regularizedGamma (1 / 2) (y ^ 2)) (2 / √Real.pi * Real.exp (-x ^ 2)) x

      On the positive half-line, the regularized incomplete gamma function of shape 1 / 2, composed with squaring, has the Gaussian derivative which defines the error function.

      theorem TauCeti.Real.erf_eq_regularizedGamma_half_sq {x : ℝ} (hx : 0 ≤ x) :
      erf x = regularizedGamma (1 / 2) (x ^ 2)

      For 0 ≤ x, the error function is the regularized lower incomplete gamma function of shape 1 / 2 evaluated at x². The restriction is necessary because the right-hand side is even, whereas the error function is odd.