The regularized upper incomplete Gamma integral

View versions (1)

Interface

#include <codecogs/maths/special/gamma/gamma_upper_reg.h>

using namespace Maths::Special::Gamma;

This function returns the regularized "upper" incomplete Gamma Integral. Regularization is equivalent to normalisation, ensuring the result always lies between 0 and 1. Thus

\frac{\Gamma_{x,\infty}(a)}{\Gamma(a)} = \frac{1}{\Gamma(a)} \int_x^{\infty} e^{-t} t^{a-1}\ dt
(1)

When x < 1 or x < a the solution is calculated using 1 - Gamma_Lower_Reg .

Accuracy

Tested at random a, x. <pre> Relative error: domain(a,x) domain # trials peak rms 0.5,100 0,100 200000 1.9e-14 1.7e-15 0.01,0.5 0,100 200000 1.4e-13 1.6e-15 </pre>

Parameters

a
argument. Must be positive.
x
lower, positive, limit of the integral.

In this implementation both arguments must be positive. The integral is evaluated by either a power series or continued fraction expansion, depending on the relative values of a and x.

Example:

#include <stdio.h>
#include <codecogs/maths/special/gamma/gamma_upper_reg.h>
void main
{
  for(double a=0; a<3; a+=0.25)
  {
    double y=Maths::Special::Gamma::gammaUpper_reg(a, 2);
    printf("\n gammaUpper_reg(%lf, 2)=%lf", a,y);
  }
}

Output:

gammaUpper_reg(0.000000, 2)=0.000000
gammaUpper_reg(0.250000, 2)=0.017286
gammaUpper_reg(0.500000, 2)=0.045500
gammaUpper_reg(0.750000, 2)=0.085056
gammaUpper_reg(1.000000, 2)=0.135335
gammaUpper_reg(1.250000, 2)=0.194847
gammaUpper_reg(1.500000, 2)=0.261464
gammaUpper_reg(1.750000, 2)=0.332706
gammaUpper_reg(2.000000, 2)=0.406006
gammaUpper_reg(2.250000, 2)=0.478944
gammaUpper_reg(2.500000, 2)=0.549416
gammaUpper_reg(2.750000, 2)=0.615734

References

Cephes Math Library Release 2.8: June, 2000

GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

a
x
Result