} if (err MAXIT) nrerror("maxits exceeded in cisi"); } *si=sums; *ci=sumc+log(t)+EULER; } if (x | Dawson s Integral 259 if err EPS break odd odd if k MAXIT nrerror maxits exceeded in cisi si sums ci sumc log t EULER if x si - si CITED REFERENCES AND FURTHER READING Stegun . and Zucker R. 1976 Journal of Research of the National Bureau of Standards vol. 80B pp. 291-311 1981 op. cit vol. 86 pp. 661-686. Abramowitz M. and Stegun . 1964 Handbook of Mathematical Functions Applied Mathematics Series Volume 55 Washington National Bureau of Standards reprinted 1968 by Dover Publications New York Chapters 5 and 7. s Integral Dawson s Integral F x is defined by F x e x2 Io e 2 dt The function can also be related to the complex error function by F z e z2 1 erfc -iz . A remarkable approximation for F x due to Rybicki 1 is F z 1 e- z-nh 2 lim . h 0 D v n odd n What makes equation unusual is that its accuracy increases exponentially as h gets small so that quite moderate values of h and correspondingly quite rapid convergence of the series give very accurate approximations. We will discuss the theory that leads to equation later in as an interesting application of Fourier methods. Here we simply implement a routine based on the formula. It is first convenient to shift the summation index to center it approximately on the maximum of the exponential term. Define n0 to be the even integer nearest to x h and x0 n0h x x x0 and n n n0 so that Sample page from NUMERICAL RECIPES IN C THE ART OF SCIENTIFIC COMPUTING ISBN 0-521-43108-5 N X n0 N n0 odd e- x -n h 2 n no 260 Chapter 6. Special Functions where the approximate equality is accurate when h is sufficiently small and N is sufficiently large. The computation of this formula can be greatly speeded up if we note that e- x -n h 2 e-x 2 e- n h 2 e2x h The first factor is computed once the second is an array of constants to be stored and the third can be computed recursively so that only two exponentials need be evaluated. Advantage is also taken of the