2 SUBROUTINE DBESI
(X
, ALPHA
, KODE
, N
, Y
, NZ
)
3 C***BEGIN PROLOGUE DBESI
4 C***PURPOSE Compute an N member sequence of I Bessel functions
5 C I/SUB(ALPHA+K-1)/(X), K=1,...,N or scaled Bessel functions
6 C EXP(-X)*I/SUB(ALPHA+K-1)/(X), K=1,...,N for nonnegative
10 C***TYPE DOUBLE PRECISION (BESI-S, DBESI-D)
11 C***KEYWORDS I BESSEL FUNCTION, SPECIAL FUNCTIONS
12 C***AUTHOR Amos, D. E., (SNLA)
13 C Daniel, S. L., (SNLA)
16 C Abstract **** a double precision routine ****
17 C DBESI computes an N member sequence of I Bessel functions
18 C I/sub(ALPHA+K-1)/(X), K=1,...,N or scaled Bessel functions
19 C EXP(-X)*I/sub(ALPHA+K-1)/(X), K=1,...,N for nonnegative ALPHA
20 C and X. A combination of the power series, the asymptotic
21 C expansion for X to infinity, and the uniform asymptotic
22 C expansion for NU to infinity are applied over subdivisions of
23 C the (NU,X) plane. For values not covered by one of these
24 C formulae, the order is incremented by an integer so that one
25 C of these formulae apply. Backward recursion is used to reduce
26 C orders by integer values. The asymptotic expansion for X to
27 C infinity is used only when the entire sequence (specifically
28 C the last member) lies within the region covered by the
29 C expansion. Leading terms of these expansions are used to test
30 C for over or underflow where appropriate. If a sequence is
31 C requested and the last member would underflow, the result is
32 C set to zero and the next lower order tried, etc., until a
33 C member comes on scale or all are set to zero. An overflow
34 C cannot occur with scaling.
36 C The maximum number of significant digits obtainable
37 C is the smaller of 14 and the number of digits carried in
38 C double precision arithmetic.
40 C Description of Arguments
42 C Input X,ALPHA are double precision
44 C ALPHA - order of first member of the sequence,
46 C KODE - a parameter to indicate the scaling option
48 C Y(K)= I/sub(ALPHA+K-1)/(X),
51 C Y(K)=EXP(-X)*I/sub(ALPHA+K-1)/(X),
53 C N - number of members in the sequence, N .GE. 1
55 C Output Y is double precision
56 C Y - a vector whose first N components contain
57 C values for I/sub(ALPHA+K-1)/(X) or scaled
58 C values for EXP(-X)*I/sub(ALPHA+K-1)/(X),
59 C K=1,...,N depending on KODE
60 C NZ - number of components of Y set to zero due to
62 C NZ=0 , normal return, computation completed
63 C NZ .NE. 0, last NZ components of Y set to zero,
64 C Y(K)=0.0D0, K=N-NZ+1,...,N.
67 C Improper input arguments - a fatal error
68 C Overflow with KODE=1 - a fatal error
69 C Underflow - a non-fatal error(NZ .NE. 0)
71 C***REFERENCES D. E. Amos, S. L. Daniel and M. K. Weston, CDC 6600
72 C subroutines IBESS and JBESS for Bessel functions
73 C I(NU,X) and J(NU,X), X .GE. 0, NU .GE. 0, ACM
74 C Transactions on Mathematical Software 3, (1977),
76 C F. W. J. Olver, Tables of Bessel Functions of Moderate
77 C or Large Orders, NPL Mathematical Tables 6, Her
78 C Majesty's Stationery Office, London, 1962.
79 C***ROUTINES CALLED D1MACH, DASYIK, DLNGAM, I1MACH, XERMSG
80 C***REVISION HISTORY (YYMMDD)
82 C 890531 Changed all specific intrinsics to generic. (WRB)
83 C 890911 Removed unnecessary intrinsics. (WRB)
84 C 890911 REVISION DATE from Version 3.2
85 C 891214 Prologue converted to Version 4.0 format. (BAB)
86 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
87 C 900326 Removed duplicate information from DESCRIPTION section.
89 C 920501 Reformatted the REFERENCES section. (WRB)
90 C***END PROLOGUE DBESI
92 INTEGER I
, IALP
, IN
, INLIM
, IS
, I1
, K
, KK
, KM
, KODE
, KT
,
95 DOUBLE PRECISION AIN
,AK
,AKM
,ALPHA
,ANS
,AP
,ARG
,ATOL
,TOLLN
,DFN
,
96 1 DTM
, DX
, EARG
, ELIM
, ETX
, FLGIK
,FN
, FNF
, FNI
,FNP1
,FNU
,GLN
,RA
,
97 2 RTTPI
, S
, SX
, SXO2
, S1
, S2
, T
, TA
, TB
, TEMP
, TFN
, TM
, TOL
,
98 3 TRX
, T2
, X
, XO2
, XO2L
, Y
, Z
99 DOUBLE PRECISION D1MACH
, DLNGAM
100 DIMENSION Y
(*), TEMP
(3)
102 DATA RTTPI
/ 3.98942280401433D
-01/
104 C***FIRST EXECUTABLE STATEMENT DBESI
107 C I1MACH(15) REPLACES I1MACH(12) IN A DOUBLE PRECISION CODE
108 C I1MACH(14) REPLACES I1MACH(11) IN A DOUBLE PRECISION CODE
110 TOL
= MAX
(RA
,1.0D
-15)
113 ELIM
= 2.303D0*
(I1*GLN
-3.0D0
)
116 TOLLN
= 2.303D0*GLN*I1
117 TOLLN
= MIN
(TOLLN
,34.5388D0
)
121 IF (KODE
.LT
.1 .OR
. KODE
.GT
.2) GO TO 570
123 30 IF (ALPHA
) 580, 40, 50
134 IF (ALPHA
.LT
.0.0D0
) GO TO 580
147 C DECISION TREE FOR REGION WHERE SERIES, ASYMPTOTIC EXPANSION FOR X
148 C TO INFINITY AND ASYMPTOTIC EXPANSION FOR NU TO INFINITY ARE
151 IF (SXO2
.LE
.(FNU
+1.0D0
)) GO TO 90
152 IF (X
.LE
.12.0D0
) GO TO 110
155 IF (X
.GE
.FN
) GO TO 430
156 ANS
= MAX
(36.0D0
-FNU
,0.0D0
)
169 IF (X
.LE
.0.5D0
) GO TO 230
176 IF (N
-1+NS
.GT
.0) IS
= 3
183 C OVERFLOW TEST ON UNIFORM ASYMPTOTIC EXPANSION
185 IF (KODE
.EQ
.2) GO TO 130
186 IF (ALPHA
.LT
.1.0D0
) GO TO 150
189 GLN
= LOG
((1.0D0
+RA
)/Z
)
190 T
= RA*
(1.0D0
-ETX
) + ETX
/(Z
+RA
)
192 IF (ARG
.GT
.ELIM
) GO TO 610
193 IF (KM
.EQ
.0) GO TO 140
196 C UNDERFLOW TEST ON UNIFORM ASYMPTOTIC EXPANSION
200 GLN
= LOG
((1.0D0
+RA
)/Z
)
201 T
= RA*
(1.0D0
-ETX
) + ETX
/(Z
+RA
)
203 140 IF (ARG
.LT
.(-ELIM
)) GO TO 280
205 150 IF (X
.GT
.ELIM
) GO TO 610
208 C UNIFORM ASYMPTOTIC EXPANSION FOR NU TO INFINITY
210 160 IF (KM
.NE
.0) GO TO 170
213 170 TEMP
(1) = TEMP
(3)
222 IF(I1
.EQ
.2) GO TO 350
225 GLN
= LOG
((1.0D0
+RA
)/Z
)
226 T
= RA*
(1.0D0
-ETX
) + ETX
/(Z
+RA
)
232 CALL DASYIK
(X
,FN
,KODE
,FLGIK
,RA
,ARG
,I1
,TEMP
(IS
))
233 GO TO (180, 350, 510), IS
235 C SERIES FOR (X/2)**2.LE.NU+1
239 ARG
= FN*XO2L
- GLN
- SX
240 IF (ARG
.LT
.(-ELIM
)) GO TO 300
244 IF (X
.LT
.TOL
) GO TO 260
253 IF (ABS
(T
).LT
.TOL
) GO TO 260
260 GO TO (270, 350, 500), IS
261 270 EARG
= EARG*FN
/XO2
268 C SET UNDERFLOW VALUE AND UPDATE PARAMETERS
275 IF (NN
-1) 340, 290, 130
285 IF (NN
-1) 340, 310, 320
288 320 IF (SXO2
.LE
.FNP1
) GO TO 330
290 330 ARG
= ARG
- XO2L
+ LOG
(FNP1
)
291 IF (ARG
.LT
.(-ELIM
)) GO TO 300
296 C BACKWARD RECURSION SECTION
301 IF(KT
.EQ
.2) GO TO 420
307 IF (IN
.EQ
.0) GO TO 390
308 C BACKWARD RECUR TO INDEX ALPHA+NN-1
322 C BACKWARD RECUR FROM INDEX ALPHA+NN-1 TO ALPHA
329 Y
(K
-2) = TM*Y
(K
-1) + Y
(K
)
337 C ASYMPTOTIC EXPANSION FOR X TO INFINITY
341 IF (KODE
.EQ
.2) GO TO 440
342 IF (X
.GT
.ELIM
) GO TO 610
350 IF (FNI
.EQ
.0.0D0
.AND
. ABS
(FNF
).LT
.TOL
) GO TO 460
351 TM
= 4.0D0*FNF*
(FNI
+FNI
+FNF
)
369 IF (ABS
(T
).LE
.ATOL
) GO TO 480
372 480 TEMP
(IS
) = S*EARG
373 IF(IS
.EQ
.2) GO TO 360
380 C BACKWARD RECURSION WITH NORMALIZATION BY
381 C ASYMPTOTIC EXPANSION FOR NU TO INFINITY OR POWER SERIES.
384 C COMPUTATION OF LAST ORDER FOR SERIES NORMALIZATION
385 AKM
= MAX
(3.0D0
-FN
,0.0D0
)
388 TA
= (GLN
+TFN
-0.9189385332D0
-0.0833333333D0
/TFN
)/(TFN
+0.5D0
)
390 TB
= -(1.0D0
-1.0D0
/TFN
)/TFN
391 AIN
= TOLLN
/(-TA
+SQRT
(TA*TA
-TOLLN*TB
)) + 1.5D0
396 C COMPUTATION OF LAST ORDER FOR ASYMPTOTIC EXPANSION NORMALIZATION
398 AIN
= TOLLN
/(GLN
+SQRT
(GLN*GLN
+T*TOLLN
)) + 1.5D0
400 IF (IN
.GT
.INLIM
) GO TO 160
410 C BACKWARD RECUR UNINDEXED
420 IF (KK
.NE
.1) GO TO 550
425 IF (NS
.NE
.0) GO TO 530
437 C BACKWARD RECUR INDEXED
440 Y
(K
-1) = TM*Y
(K
) + Y
(K
+1)
450 CALL XERMSG
('SLATEC', 'DBESI',
451 + 'SCALING OPTION, KODE, NOT 1 OR 2.', 2, 1)
454 CALL XERMSG
('SLATEC', 'DBESI', 'ORDER, ALPHA, LESS THAN ZERO.',
458 CALL XERMSG
('SLATEC', 'DBESI', 'N LESS THAN ONE.', 2, 1)
461 CALL XERMSG
('SLATEC', 'DBESI', 'X LESS THAN ZERO.', 2, 1)
464 CALL XERMSG
('SLATEC', 'DBESI',
465 + 'OVERFLOW, X TOO LARGE FOR KODE = 1.', 6, 1)