Syntax

Description

nag_specfun_gamma_incomplete (s14ba) evaluates the incomplete gamma functions in the normalized form

x

P(a,x) = 1/(Γ(a))

∫

ta − 1e − tdt,

0

P(a,x)=1Γ(a)∫0xta-1e-tdt,

∞

Q(a,x) = 1/(Γ(a))

∫

ta − 1e − tdt,

x

Q(a,x)=1Γ(a)∫x∞ta-1e-tdt,

with x ≥ 0x≥0 and a > 0a>0, to a user-specified accuracy. With this normalization, P(a,x) + Q(a,x) = 1P(a,x)+Q(a,x)=1.

Several methods are used to evaluate the functions depending on the arguments aa and xx, the methods including Taylor expansion for P(a,x)P(a,x), Legendre's continued fraction for Q(a,x)Q(a,x), and power series for Q(a,x)Q(a,x). When both aa and xx are large, and a ≃ xa≃x, the uniform asymptotic expansion of Temme (1987) is employed for greater efficiency – specifically, this expansion is used when a ≥ 20a≥20 and 0.7a ≤ x ≤ 1.4a0.7a≤x≤1.4a.

Once either PP or QQ is computed, the other is obtained by subtraction from 11. In order to avoid loss of relative precision in this subtraction, the smaller of PP and QQ is computed first.

Compulsory Input Parameters

The relative accuracy required by you in the results. If nag_specfun_gamma_incomplete (s14ba) is entered with tol greater than 1.01.0 or less than machine precision, then the value of machine precision is used instead.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:
p – double scalar

2:
q – double scalar

The values of the functions P(a,x)P(a,x) and Q(a,x)Q(a,x) respectively.

Error Indicators and Warnings

Convergence of the Taylor series or Legendre continued fraction fails within 600600 iterations. This error is extremely unlikely to occur; if it does, contact NAG.

Accuracy

There are rare occasions when the relative accuracy attained is somewhat less than that specified by parameter tol. However, the error should never exceed more than one or two decimal places. Note also that there is a limit of 1818 decimal places on the achievable accuracy, because constants in the function are given to this precision.

Further Comments

The time taken for a call of nag_specfun_gamma_incomplete (s14ba) depends on the precision requested through tol, and also varies slightly with the input arguments aa and xx.