*DECK CAIRY SUBROUTINE CAIRY (Z, ID, KODE, AI, NZ, IERR) C***BEGIN PROLOGUE CAIRY C***PURPOSE Compute the Airy function Ai(z) or its derivative dAi/dz C for complex argument z. A scaling option is available C to help avoid underflow and overflow. C***LIBRARY SLATEC C***CATEGORY C10D C***TYPE COMPLEX (CAIRY-C, ZAIRY-C) C***KEYWORDS AIRY FUNCTION, BESSEL FUNCTION OF ORDER ONE THIRD, C BESSEL FUNCTION OF ORDER TWO THIRDS C***AUTHOR Amos, D. E., (SNL) C***DESCRIPTION C C On KODE=1, CAIRY computes the complex Airy function Ai(z) C or its derivative dAi/dz on ID=0 or ID=1 respectively. On C KODE=2, a scaling option exp(zeta)*Ai(z) or exp(zeta)*dAi/dz C is provided to remove the exponential decay in -pi/31 and from power series when abs(z)<=1. C C In most complex variable computation, one must evaluate ele- C mentary functions. When the magnitude of Z is large, losses C of significance by argument reduction occur. Consequently, if C the magnitude of ZETA=(2/3)*Z**(3/2) exceeds U1=SQRT(0.5/UR), C then losses exceeding half precision are likely and an error C flag IERR=3 is triggered where UR=R1MACH(4)=UNIT ROUNDOFF. C Also, if the magnitude of ZETA is larger than U2=0.5/UR, then C all significance is lost and IERR=4. In order to use the INT C function, ZETA must be further restricted not to exceed C U3=I1MACH(9)=LARGEST INTEGER. Thus, the magnitude of ZETA C must be restricted by MIN(U2,U3). In IEEE arithmetic, U1,U2, C and U3 are approximately 2.0E+3, 4.2E+6, 2.1E+9 in single C precision and 4.7E+7, 2.3E+15, 2.1E+9 in double precision. C This makes U2 limiting is single precision and U3 limiting C in double precision. This means that the magnitude of Z C cannot exceed approximately 3.4E+4 in single precision and C 2.1E+6 in double precision. This also means that one can C expect to retain, in the worst cases on 32-bit machines, C no digits in single precision and only 6 digits in double C precision. C C The approximate relative error in the magnitude of a complex C Bessel function can be expressed as P*10**S where P=MAX(UNIT C ROUNDOFF,1.0E-18) is the nominal precision and 10**S repre- C sents the increase in error due to argument reduction in the C elementary functions. Here, S=MAX(1,ABS(LOG10(ABS(Z))), C ABS(LOG10(FNU))) approximately (i.e., S=MAX(1,ABS(EXPONENT OF C ABS(Z),ABS(EXPONENT OF FNU)) ). However, the phase angle may C have only absolute accuracy. This is most likely to occur C when one component (in magnitude) is larger than the other by C several orders of magnitude. If one component is 10**K larger C than the other, then one can expect only MAX(ABS(LOG10(P))-K, C 0) significant digits; or, stated another way, when K exceeds C the exponent of P, no significant digits remain in the smaller C component. However, the phase angle retains absolute accuracy C because, in complex arithmetic with precision P, the smaller C component will not (as a rule) decrease below P times the C magnitude of the larger component. In these extreme cases, C the principal phase angle is on the order of +P, -P, PI/2-P, C or -PI/2+P. C C***REFERENCES 1. M. Abramowitz and I. A. Stegun, Handbook of Mathe- C matical Functions, National Bureau of Standards C Applied Mathematics Series 55, U. S. Department C of Commerce, Tenth Printing (1972) or later. C 2. D. E. Amos, Computation of Bessel Functions of C Complex Argument and Large Order, Report SAND83-0643, C Sandia National Laboratories, Albuquerque, NM, May C 1983. C 3. D. E. Amos, A Subroutine Package for Bessel Functions C of a Complex Argument and Nonnegative Order, Report C SAND85-1018, Sandia National Laboratory, Albuquerque, C NM, May 1985. C 4. D. E. Amos, A portable package for Bessel functions C of a complex argument and nonnegative order, ACM C Transactions on Mathematical Software, 12 (September C 1986), pp. 265-273. C C***ROUTINES CALLED CACAI, CBKNU, I1MACH, R1MACH C***REVISION HISTORY (YYMMDD) C 830501 DATE WRITTEN C 890801 REVISION DATE from Version 3.2 C 910415 Prologue converted to Version 4.0 format. (BAB) C 920128 Category corrected. (WRB) C 920811 Prologue revised. (DWL) C***END PROLOGUE CAIRY