0% found this document useful (0 votes)
22 views

S14bac cl05

This function evaluates the incomplete gamma functions P(a,x) and Q(a,x) to a specified accuracy for a>0 and x>=0. It uses different methods like Taylor expansion, Legendre's continued fraction, and asymptotic expansion depending on the values of a and x. The parameters, outputs, errors, accuracy, and an example are described.

Uploaded by

Khhg Agdds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

S14bac cl05

This function evaluates the incomplete gamma functions P(a,x) and Q(a,x) to a specified accuracy for a>0 and x>=0. It uses different methods like Taylor expansion, Legendre's continued fraction, and asymptotic expansion depending on the values of a and x. The parameters, outputs, errors, accuracy, and an example are described.

Uploaded by

Khhg Agdds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

s – Approximations of Special Functions s14bac

nag incomplete gamma (s14bac)

1. Purpose
nag incomplete gamma (s14bac) computes values for the incomplete gamma functions P (a, x) and
Q(a, x).

2. Specification
#include <nag.h>
#include <nags.h>
void nag_incomplete_gamma(double a, double x, double tol, double *p,
double *q, NagError *fail)

3. Description
This function evaluates the incomplete gamma functions in the normalised form
1
 x a−1 −t
P (a, x) = Γ(a) t e dt
1
 0∞ a−1 −t ,
Q(a, x) = Γ(a) x t e dt

with x ≥ 0 and a > 0, to a user-specified accuracy. With this normalisation, P (a, x) + Q(a, x) = 1.
Several methods are used to evaluate the functions depending on the arguments a and x, the
methods including Taylor expansion for P (a, x), Legendre’s continued fraction for Q(a, x), and
power series for Q(a, x). When both a and x are large, and a  x, the uniform asymptotic
expansion of Temme (1987) is employed for greater efficiency – specifically, this expansion is used
when a ≥ 20 and 0.7a ≤ x ≤ 1.4a.
Once either of 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 function is derived from subroutine GAM in Gautschi (1979b).

4. Parameters
a
Input: the argument a of the functions.
Constraint: a > 0.0.
x
Input: the argument x of the functions.
Constraint: x ≥ 0.0.
tol
Input: the relative accuracy required by the user in the results. If nag incomplete gamma is
entered with tol greater than 1.0 or less than machine precision, then the value of machine
precision is used instead.
p
q
Output: the values of the functions P (a, x) and Q(a, x) respectively.
fail
The NAG error parameter, see the Essential Introduction to the NAG C Library.

[NP3275/5/pdf] 3.s14bac.1
nag incomplete gamma NAG C Library Manual

5. Error Indications and Warnings


On error nag incomplete gamma returns with a value of 0.0 for p and q.
NE REAL ARG LE
On entry, a must not be less than or equal to 0.0: a = value.
NE REAL ARG LT
On entry, x must not be less than 0.0: x = value.
NE ALG NOT CONV
The algorithm has failed to converge in value iterations.
Convergence of the Taylor series or Legendre continued fraction has failed within the specified
number of iterations. This error is extremely unlikely to occur; if it does, contact NAG.

6. Further Comments
The time taken for a call of nag incomplete gamma depends on the precision requested through
tol, and also varies slightly with the input arguments a and x.
6.1. 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 function are given to this precision.
6.2. 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 J C Mason and M G Cox (ed) Oxford University
Press.

7. See Also
None.

8. Example
The following program reads values of the argument a and x from a file, evaluates the function and
prints the results.
8.1. Program Text
/* nag_incomplete_gamma(s14bac) Example Program
*
* Copyright 1990 Numerical Algorithms Group.
*
* Mark 2 revised, 1992.
*/
#include <nag.h>
#include <stdio.h>
#include <nag_stdlib.h>
#include <nags.h>
#include <nagx02.h>

main()
{
double a, p, q, tol, x;
/* Skip heading in data file */
Vscanf("%*[^\n]");

3.s14bac.2 [NP3275/5/pdf]
s – Approximations of Special Functions s14bac

Vprintf("s14bac Example Program Results\n");


tol = X02AJC;
Vprintf(" a x p q\n");
while (scanf("%lf %lf", &a, &x) != EOF)
{
s14bac(a, x, tol, &p, &q, NAGERR_DEFAULT);
Vprintf("%12.4f%12.4f%12.4f%12.4f\n", a, x, p, q);
}
exit(EXIT_SUCCESS);
}
8.2. Program Data
s14bac Example Program Data
2.0 3.0
7.0 1.0
0.5 99.0
20.0 21.0
21.0 20.0
8.3. Program Results
s14bac Example Program Results
a x p q
2.0000 3.0000 0.8009 0.1991
7.0000 1.0000 0.0001 0.9999
0.5000 99.0000 1.0000 0.0000
20.0000 21.0000 0.6157 0.3843
21.0000 20.0000 0.4409 0.5591

[NP3275/5/pdf] 3.s14bac.3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy