GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
gami.f
Go to the documentation of this file.
1 *DECK GAMI
2  FUNCTION gami (A, X)
3 C***BEGIN PROLOGUE GAMI
4 C***PURPOSE Evaluate the incomplete Gamma function.
5 C***LIBRARY SLATEC (FNLIB)
6 C***CATEGORY C7E
7 C***TYPE SINGLE PRECISION (GAMI-S, DGAMI-D)
8 C***KEYWORDS FNLIB, INCOMPLETE GAMMA FUNCTION, SPECIAL FUNCTIONS
9 C***AUTHOR Fullerton, W., (LANL)
10 C***DESCRIPTION
11 C
12 C Evaluate the incomplete gamma function defined by
13 C
14 C GAMI = integral from T = 0 to X of EXP(-T) * T**(A-1.0) .
15 C
16 C GAMI is evaluated for positive values of A and non-negative values
17 C of X. A slight deterioration of 2 or 3 digits accuracy will occur
18 C when GAMI is very large or very small, because logarithmic variables
19 C are used. GAMI, A, and X are single precision.
20 C
21 C***REFERENCES (NONE)
22 C***ROUTINES CALLED ALNGAM, GAMIT, XERMSG
23 C***REVISION HISTORY (YYMMDD)
24 C 770701 DATE WRITTEN
25 C 890531 Changed all specific intrinsics to generic. (WRB)
26 C 890531 REVISION DATE from Version 3.2
27 C 891214 Prologue converted to Version 4.0 format. (BAB)
28 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
29 C***END PROLOGUE GAMI
30 C***FIRST EXECUTABLE STATEMENT GAMI
31  IF (a .LE. 0.0) CALL xermsg('SLATEC', 'GAMI',
32  + 'A MUST BE GT ZERO', 1, 2)
33  IF (x .LT. 0.0) CALL xermsg('SLATEC', 'GAMI',
34  + 'X MUST BE GE ZERO', 2, 2)
35 C
36  gami = 0.0
37  IF (x.EQ.0.0) RETURN
38 C
39 C THE ONLY ERROR POSSIBLE IN THE EXPRESSION BELOW IS A FATAL OVERFLOW.
40  factor = exp(alngam(a) + a*log(x) )
41 C
42  gami = factor * gamit(a, x)
43 C
44  RETURN
45  END