algorithm 914

5
6 Algorithm 914: Parabolic Cylinder Function W(a, x) and Its Derivative AMPARO GIL and JAVIER SEGURA, University de Cantabria NICO M. TEMME, CWI A Fortran 90 program for the computation of the real parabolic cylinder functions W(a, ±x), x 0 and their derivatives is presented. The code also computes scaled functions for a > 50. The functions W(a, ±x) are a numerically satisfactory pair of solutions of the parabolic cylinder equation y + ( x 2 /4 a ) y = 0, x 0. Using Wronskian tests, we claim a relative accuracy better than 5 10 13 in the computable range of unscaled functions, while for scaled functions the aimed relative accuracy is better than 5 10 14 . This code, together with the algorithm and related software described in Gil et al. [2006a, 2006b], completes the set of software for Parabolic Cylinder Functions (PCFs) for real arguments. Categories and Subject Descriptors: G.4 [Mathematics of Computing]: Mathematical Software General Terms: Algorithms Additional Key Words and Phrases: Parabolic cylinder functions, ODE integration, asymptotic expansions ACM Reference Format: Gil, A., Segura, J., and Temme, N. M. 2011. Algorithm 914: Parabolic cylinder function W(a, x) and its derivative. ACM Trans. Math. Softw. 38, 1, Article 6 (November 2011), 5 pages. DOI = 10.1145/2049662.2049668 http://doi.acm.org/10.1145/2049662.2049668 1. INTRODUCTION We present a Fortran 90 code for computing the Weber parabolic cylinder function W (a, x) and its derivative. The parabolic cylinder function W (a, x) [Temme 2010, Section 12.14] is a solution of the differential equation y + 1 4 x 2 a y = 0 , x 0 (1) which also has W (a, x) as a solution, the pair {W (a, x), W (a, x)} being a numerically satisfactory pair of solutions in the sense of Miller [1950, 1952]. The algorithm is based on the use, in different regions, of different methods of com- putation: Maclaurin series, local Taylor series, uniform asymptotic expansions in terms of elementary functions, and Airy-type asymptotic expansions. All these methods are described in detail in Gil et al. [2010]. The code gives as output the values of W (a, x), W (a, x), W (a, x) and W (a, x) for real a and x 0. Notice that W (a, x) is not exactly the derivative of W (a, x), but W (a x) =− d dx W (a, x). The authors acknowledge support from Ministerio de Ciencia e Innovaci´ on, project MTM2009-11686. N. M. Temme acknowledges financial support from Gobierno of Navarra, Res. 07/05/2008. Authors’ addresses: A. Gil (corresponding author), J. Segura, Departamento de Matem´ aticas, Estad´ ıstica y Computaci´ on, University de Cantabria, 39005 Santander, Spain; email: [email protected]; N. M. Temme, CWI, Science Park 123, 1098 XG Amsterdam, The Netherlands. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies show this notice on the first page or initial screen of a display along with the full citation. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, to redistribute to lists, or to use any component of this work in other works requires prior specific permission and/or a fee. Permissions may be requested from Publications Dept., ACM, Inc., 2 Penn Plaza, Suite 701, New York, NY 10121-0701 USA, fax +1 (212) 869-0481, or [email protected]. c 2011 ACM 0098-3500/2011/11-ART6 $10.00 DOI 10.1145/2049662.2049668 http://doi.acm.org/10.1145/2049662.2049668 ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.

Upload: nico-m

Post on 27-Jan-2017

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Algorithm 914

6

Algorithm 914: Parabolic Cylinder Function W(a, x) and Its Derivative

AMPARO GIL and JAVIER SEGURA, University de CantabriaNICO M. TEMME, CWI

A Fortran 90 program for the computation of the real parabolic cylinder functions W (a,±x), x ≥ 0 and theirderivatives is presented. The code also computes scaled functions for a > 50. The functions W (a,±x) area numerically satisfactory pair of solutions of the parabolic cylinder equation y′′ + (

x2/4 − a)

y = 0, x ≥ 0.Using Wronskian tests, we claim a relative accuracy better than 5 10−13 in the computable range of unscaledfunctions, while for scaled functions the aimed relative accuracy is better than 5 10−14. This code, togetherwith the algorithm and related software described in Gil et al. [2006a, 2006b], completes the set of softwarefor Parabolic Cylinder Functions (PCFs) for real arguments.

Categories and Subject Descriptors: G.4 [Mathematics of Computing]: Mathematical Software

General Terms: Algorithms

Additional Key Words and Phrases: Parabolic cylinder functions, ODE integration, asymptotic expansions

ACM Reference Format:Gil, A., Segura, J., and Temme, N. M. 2011. Algorithm 914: Parabolic cylinder function W (a, x) and itsderivative. ACM Trans. Math. Softw. 38, 1, Article 6 (November 2011), 5 pages.DOI = 10.1145/2049662.2049668 http://doi.acm.org/10.1145/2049662.2049668

1. INTRODUCTION

We present a Fortran 90 code for computing the Weber parabolic cylinder functionW(a, x) and its derivative. The parabolic cylinder function W(a, x) [Temme 2010,Section 12.14] is a solution of the differential equation

y′′ +(

14 x2 − a

)y = 0 , x ≥ 0 (1)

which also has W(a,−x) as a solution, the pair {W(a, x), W(a,−x)} being a numericallysatisfactory pair of solutions in the sense of Miller [1950, 1952].

The algorithm is based on the use, in different regions, of different methods of com-putation: Maclaurin series, local Taylor series, uniform asymptotic expansions in termsof elementary functions, and Airy-type asymptotic expansions. All these methods aredescribed in detail in Gil et al. [2010].

The code gives as output the values of W(a, x), W(a,−x), W ′(a, x) and W ′(a,−x) forreal a and x ≥ 0. Notice that W ′(a,−x) is not exactly the derivative of W(a,−x), butW ′(a − x) = − d

dx W(a,−x).

The authors acknowledge support from Ministerio de Ciencia e Innovacion, project MTM2009-11686. N. M.Temme acknowledges financial support from Gobierno of Navarra, Res. 07/05/2008.Authors’ addresses: A. Gil (corresponding author), J. Segura, Departamento de Matematicas, Estadıstica yComputacion, University de Cantabria, 39005 Santander, Spain; email: [email protected]; N. M. Temme,CWI, Science Park 123, 1098 XG Amsterdam, The Netherlands.Permission to make digital or hard copies of part or all of this work for personal or classroom use is grantedwithout fee provided that copies are not made or distributed for profit or commercial advantage and thatcopies show this notice on the first page or initial screen of a display along with the full citation. Copyrights forcomponents of this work owned by others than ACM must be honored. Abstracting with credit is permitted.To copy otherwise, to republish, to post on servers, to redistribute to lists, or to use any component of thiswork in other works requires prior specific permission and/or a fee. Permissions may be requested fromPublications Dept., ACM, Inc., 2 Penn Plaza, Suite 701, New York, NY 10121-0701 USA, fax +1 (212)869-0481, or [email protected]© 2011 ACM 0098-3500/2011/11-ART6 $10.00

DOI 10.1145/2049662.2049668 http://doi.acm.org/10.1145/2049662.2049668

ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.

Page 2: Algorithm 914

6:2 A. Gil et al.

2. DEFINITION OF SCALED FUNCTIONS

For large (positive) values of the parameter a the functions W(a, x), W(a,−x) are verylarge or very small. To avoid overflow or underflow in numerical computations it isquite useful to define scaled values with the dominant exponential behavior factoredout [Gil et al. 2007, Section 12.1.3]. This scaling factor can be also factored out fromthe uniform asymptotic expansions.

We define the scaling factor as eχ(a,x) where χ (a, x) is given by

χ (a, x) ={

a(arcsin t + t√

1 − t2), if t ≤ 1 (Monotonic Region)aπ/2, if t > 1 (Oscillating Region)

(2)

with t = x/(2√

a) > 0. For a < 0 scaling is not needed. We consider only positive valuesof x, which is not a restriction because we compute the pair {W(a, x), W(a,−x)} and itsderivatives.

The scaled functions are defined asW (a, x) = eχ(a,x)W(a, x), W ′(a, x) = eχ(a,x)W ′(a, x),

W (a,−x) = W(a,−x)eχ(a,x) , W ′(a,−x) = W ′(a,−x)

eχ(a,x) .(3)

Scaling factors can be directly factored out from the expressions used for the asymp-totic expansions but not from the differential Eq. (1), which is the starting point of thelocal Taylor series method; because of this and in order to avoid introducing numericalerrors due to the exponential terms of the scaling, scaled functions are computed fora > 50.

In particular and in the case of the Airy-type asymptotic expansions in the monotonicregion (t ≤ 1), the scaled functions W(a,±x) can be written in terms of scaled Airy-functions

W (a, x) ∼ π12 μ

13 �(μ)φ(ζ )

212

(Bi(−z)Aμ(ζ ) + Bi

′(−z)

μ83

Bμ(ζ )

), (4)

W ′(a, x) ∼ −π12 μ

23 �(μ)

2e12 φ(ζ )

(− Bi(−z)

μ43

Cμ(ζ ) + Bi′(−z)Dμ(ζ )

), (5)

W(a,−x) ∼ π12 μ

13 �(μ)φ(ζ )

2− 12

(Ai(−z)Aμ(ζ ) + Ai

′(−z)

μ83

Bμ(ζ )

), (6)

W ′(a,−x) ∼ π12 μ

23 �(μ)

φ(ζ )

(− Ai(−z)

μ43

Cμ(ζ ) + Ai′(−z)Dμ(ζ )

), (7)

where a = 12μ2, z = μ

43 ζ , and for ζ we have the relation⎧⎪⎨⎪⎩

23 (−ζ )

32 = 1

2 arccos t − 12 t

√1 − t2, −1 < t ≤ 1, ζ ≤ 0,

23ζ

32 = 1

2 t√

t2 − 1 − 12 ln(t + √

t2 − 1), 1 ≤ t, ζ ≥ 0.

(8)

The function φ(ζ ) is given by φ(ζ ) = ( ζ

t2−1 )14 and �(μ) is computed by means of the

asymptotic expansion

�(μ) ∼ 214

μ12

∞∑s=0

�s

μ4s , (9)

ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.

Page 3: Algorithm 914

Algorithm 914: Parabolic Cylinder Function W (a, x) and Its Derivative 6:3

0 5 10 15 20 25 30 350

20

40

60

80

100

120

140

160

180

200

x

a

f1

f2

f3

f4

a=x2/4

D

A

B

C

E

Fig. 1. Regions in the (a, x)-plane (a > 0) where different methods of computation are considered. The curvea = x2/4, frontier between the monotonic (a > x2/4) and the oscillatory (a < x2/4) behavior of the functions,is also shown. The methods used are: (A) Maclaurin series; (B) Local Taylor series; (C) Airy expansions;(D) and (E) Expansions in terms of elementary functions.

where the first few coefficients are �0 = 1, �1 = − 11152 , �2 = − 16123

398 13120 , �3 =− 26954 47331

481 57949 95200 , �4 = − 3759 87489 96091221 91183 33788 .

Also, the computation of the functions Aμ(ζ ), Bμ(ζ ), Cμ(ζ ), and Dμ(ζ ) appearingin Eqs. (4), (5), (6), and (7) is performed by using asymptotic expansions of theform

Aμ(ζ ) ∼∞∑

s=0

(−1)s as(ζ )μ4s , Bμ(ζ ) ∼

∞∑s=0

(−1)s bs(ζ )μ4s ,

Cμ(ζ ) ∼∞∑

s=0

(−1)s cs(ζ )μ4s , Dμ(ζ ) ∼

∞∑s=0

(−1)s ds(ζ )μ4s .

(10)

Details on the coefficients as, bs, cs, and ds can be found in Temme [2000, Section 3.1].Scaled Airy functions [Gil et al. 2002] are defined for x > 0 as

Ai(x) = e23 x3/2

Ai(x), Ai′(x) = e23 x3/2

Ai′(x),

Bi(x) = e− 2

3 x3/2

Bi(x), Bi′(x) = e− 2

3 x3/2

Bi′(x),(11)

while Ai(x) = Ai(x) when x < 0 and the same applies for the derivative and for Bi(x)and its derivative.

The module for the computation of Airy functions uses a Fortran 90 version of thecode by Fullerton [1977] (the Fortran 77 code is available at Netlib).

3. REGIONS OF APPLICABILITY OF THE METHODS AND TESTING

The curves fi, i = 1, . . . , 6 appearing in Figures 1 and 2 correspond to the fitting curvesseparating regions of applicability of the methods. Explicit expressions for these curvesare given as follows.

f1 : a = 7(x − 2)2 + 2.5 if x < 2; x = 2 and 0 ≤ a ≤ 2.5f2 : a = 1.1x2 + 30.5,

f3 : a = 0.2(x − 12)2 + 33,

f4 : a = 0.22x2 − 40,

ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.

Page 4: Algorithm 914

6:4 A. Gil et al.

0 2 4 6 8 10 12 14−50

−45

−40

−35

−30

−25

−20

−15

−10

−5

0

x

a

f5

f6

A

B

F

Fig. 2. Regions in the (a, x)-plane (a < 0) where different methods of computation are considered. Themethods used are: (A) Maclaurin series; (B) Local Taylor series; (F) Asymptotic expansions for a < 0.

f5 : a = −2(x − 4.6)2 − 3 if f5 > f6 and x < 3.8;a = −4 and 3.8 ≤ x ≤ 4.5; x = 4.5 and − 4 < a ≤ 0

f6 : a = 0.13x2 − 25

3.1. Wronskian Tests

We test the Wronskian relation between W(a, x) and W(a,−x), which is given by

W[W(a, x), W(a,−x)] = 1. (12)

This relation means that

W(a, x)W ′(a,−x) + W ′(a, x)W(a,−x) = −1. (13)

We compute the maximum relative errors for the Wronskian test using 107 randompoints in selected regions of the (x, a)-plane. For unscaled functions we obtain

(1) [0, 100] × [0, 200]: 1.5 10−13,(2) [0, 10000] × [0, 200]: 1.22 10−13,(3) [0, 100] × [−1000, 0]: 1.7 10−13,(4) [0, 1000] × [−10000, 0]: 1.4 10−13,(5) [0, 10000] × [−100000, 0]: 5.5 10−14.

For scaled functions, the results for the Wronskian test are

(1) [0, 100] × [50.01, 1000]: 1.1 10−14,(2) [0, 1000] × [50.01, 10000]: 9 10−15.

Based on these Wronskian tests, we claim an accuracy better than 5 × 10−13 in thecomputable range of unscaled functions and a relative accuracy better than 5 × 10−14

for scaled functions.

4. COMPARISON WITH EXISTING SOFTWARE

To our knowledge, no reliable (refereed) software is available for computing the func-tions W(a,±x). A few algorithms have been described in Blanchard and Newman [1989]and Schulten et al. [1981] with a claimed accuracy not better than eight digits. Butaccording to the Digital Library of Mathematical Functions [Olver et al. 2010], theonly existing routines are those included in the book Zhang and Jin [1996]. However,these routines are built for a very limited range of validity (only 0 < a < 5, 0 < x < 5).

ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.

Page 5: Algorithm 914

Algorithm 914: Parabolic Cylinder Function W (a, x) and Its Derivative 6:5

Complex variable computations for the W(a,±x) functions are available in Maple (orMathematica) through complex confluent hypergeometric functions, but for large val-ues of the parameters, and particularly for computing W(a, x) for large a > 0, theseare very inefficient in comparison with the Fortran 90 calculations provided, becausethe representation of W(a, x) in terms of confluent hypergeometric functions becomesunstable [Gil et al. 2010].

ACKNOWLEDGMENTS

The authors thank the anonymous referees for useful comments.

REFERENCES

BLANCHARD, J. AND NEWMAN, E. H. 1989. Numerical evaluation of parabolic cylinder functions. IEEE Trans.Antennas Propagat. 37, 519–522.

FULLERTON, L. 1977. Portable special function routines. In W. R. Cowell Ed., Portability of Numerical Software,Lecture Notes in Computer Science, Springer, 452–483.

GIL, A., SEGURA, J., AND TEMME, N. 2010. Fast and accurate computation of the Weber parabolic cylinderfunction W (a, x). IMA J. Numer. Anal. doi:10.1093/imanum/drq012.

GIL, A., SEGURA, J., AND TEMME, N. M. 2002. Algorithm 819: AIZ, BIZ: two Fortran 77 routines for thecomputation of complex Airy functions. ACM Trans. Math. Softw. 28, 3, 325–336.

GIL, A., SEGURA, J., AND TEMME, N. M. 2006a. Algorithm 850: Real parabolic cylinder functions U (a, x), V (a, x).ACM Trans. Math. Softw. 32, 1, 102–112.

GIL, A., SEGURA, J., AND TEMME, N. M. 2006b. Computing the real parabolic cylinder functions U (a, x), V (a, x).ACM Trans. Math. Softw. 32, 1, 70–101.

GIL, A., SEGURA, J., AND TEMME, N. M. 2007. Numerical Methods for Special Functions. SIAM, Philadelphia,PA.

MILLER, J. C. P. 1950. On the choice of standard solutions for a homogeneous linear differential equation ofthe second order. Quart. J. Mech. Appl. Math. 3, 225–235.

MILLER, J. C. P. 1952. On the choice of standard solutions to Weber’s equation. Proc. Cambridge Philos.Soc. 48, 428–435.

OLVER, F., LOZIER, D., BOISVERT, R., AND CLARK, C. 2010. NIST Handbook of Mathematical Functions. CambridgeUniversity Press, Cambridge, UK. http://dlfm.nist.gov.

SCHULTEN, Z., GORDON, R. G., AND ANDERSON, D. G. M. 1981. A numerical algorithm for the evaluation of Weberparabolic cylinder functions U (a, x), V (a, x), and W (a, ±x). J. Comput. Phys. 42, 2, 213–237.

TEMME, N. M. 2000. Numerical and asymptotic aspects of parabolic cylinder functions. J. Comput. Appl.Math. 121, 1-2, 221–246.

TEMME, N. M. 2010. Parabolic cylinder functions. In NIST Handbook of Mathematical Functions. U.S.Department Commerce, Washington, DC, 303–319.

ZHANG, S. AND JIN, J. 1996. Computation of Special Functions. A Wiley-Interscience Publication. John Wiley& Sons Inc., New York. With 1 IBM-PC floppy disk (3.5 inch; DD).

Received September 2010; accepted April 2011

ACM Transactions on Mathematical Software, Vol. 38, No. 1, Article 6, Publication date: November 2011.