]>
Commit | Line | Data |
---|---|---|
0795afa3 | 1 | #include "isajet/pilot.h" |
2 | DOUBLE PRECISION FUNCTION DINCGM(A,X,EPS) | |
3 | C*********************************************************************** | |
4 | C* Series expansion of incomplete gamma function, from Abramowitz and * | |
5 | C* Stegun. A and X are the two arguments, while EPS is the relative * | |
6 | C* precision. More accurately, if X > 0, EPS is the ratio of the last * | |
7 | C* term in the series and the sum; note that for X > 0, the series is * | |
8 | C* alternating. For X < 0, this ratio is required to be < EPS/100. * | |
9 | C*********************************************************************** | |
10 | ||
11 | DOUBLE PRECISION A,X,EPS,SUM,TERM,XN | |
12 | C IF(DABS(A).LT.1.D-10) THEN | |
13 | C WRITE(*,*) ' Function diverges for A = 0!' | |
14 | C DINCGM = 1.D50 | |
15 | C RETURN | |
16 | C ENDIF | |
17 | SUM = 1.D0/A | |
18 | TERM = 1.D0 !Term for n = 0 | |
19 | H = 1.D0 | |
20 | XN = 1.D0 | |
21 | ||
22 | 1 H = -H*X/XN | |
23 | TERM = H/(A+XN) | |
24 | XN = XN+1.D0 | |
25 | SUM = SUM+TERM | |
26 | IF((DABS(TERM/SUM).GT.EPS.AND.X.GE.0.D0).OR. | |
27 | & (DABS(TERM/SUM).GT.1.D-2*EPS.AND.X.LE.0.D0)) GOTO 1 | |
28 | ||
29 | DINCGM = SUM*(X**A) | |
30 | RETURN | |
31 | END |