s14ba computes values for the incomplete gamma functions Pa,x and Qa,x.

Syntax

C#
public static void s14ba(
	double a,
	double x,
	double tol,
	out double p,
	out double q,
	out int ifail
)
Visual Basic
Public Shared Sub s14ba ( _
	a As Double, _
	x As Double, _
	tol As Double, _
	<OutAttribute> ByRef p As Double, _
	<OutAttribute> ByRef q As Double, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void s14ba(
	double a, 
	double x, 
	double tol, 
	[OutAttribute] double% p, 
	[OutAttribute] double% q, 
	[OutAttribute] int% ifail
)
F#
static member s14ba : 
        a : float * 
        x : float * 
        tol : float * 
        p : float byref * 
        q : float byref * 
        ifail : int byref -> unit 

Parameters

a
Type: System..::..Double
On entry: the argument a of the functions.
Constraint: a>0.0.
x
Type: System..::..Double
On entry: the argument x of the functions.
Constraint: x0.0.
tol
Type: System..::..Double
On entry: the relative accuracy required by you in the results. If s14ba is entered with tol greater than 1.0 or less than machine precision, then the value of machine precision is used instead.
p
Type: System..::..Double%
On exit: the values of the functions Pa,x and Qa,x respectively.
q
Type: System..::..Double%
On exit: the values of the functions Pa,x and Qa,x respectively.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

s14ba evaluates the incomplete gamma functions in the normalized form
Pa,x=1Γa0xta-1e-tdt,
Qa,x=1Γaxta-1e-tdt,
with x0 and a>0, to a user-specified accuracy. With this normalization, Pa,x+Qa,x=1.
Several methods are used to evaluate the functions depending on the arguments a and x, the methods including Taylor expansion for Pa,x, Legendre's continued fraction for Qa,x, and power series for Qa,x. When both a and x are large, and ax, the uniform asymptotic expansion of Temme (1987) is employed for greater efficiency – specifically, this expansion is used when a20 and 0.7ax1.4a.
Once either P or Q is computed, the other is obtained by subtraction from 1. In order to avoid loss of relative precision in this subtraction, the smaller of P and Q is computed first.
This method is derived from the method GAM in Gautschi (1979b).

References

Gautschi W (1979a) A computational procedure for incomplete gamma functions ACM Trans. Math. Software 5 466–481
Gautschi W (1979b) Algorithm 542: Incomplete gamma functions ACM Trans. Math. Software 5 482–489
Temme N M (1987) On the computation of the incomplete gamma functions for large values of the parameters Algorithms for Approximation (eds J C Mason and M G Cox) Oxford University Press

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,a0.0.
ifail=2
On entry,x<0.0.
ifail=3
Convergence of the Taylor series or Legendre continued fraction fails within 600 iterations. This error is extremely unlikely to occur; if it does, contact NAG.
ifail=-9000
An error occured, see message report.

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 18 decimal places on the achievable accuracy, because constants in the method are given to this precision.

Parallelism and Performance

None.

Further Comments

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

Example

This example reads values of the argument a and x from a file, evaluates the function and prints the results.

Example program (C#): s14bae.cs

Example program data: s14bae.d

Example program results: s14bae.r

See Also