C6 10


6.10 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 < 0.0) *si = -(*si);
}
CITED REFERENCES AND FURTHER READING:
Stegun, I.A., 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, I.A. 1964, Handbook of Mathematical Functions, Applied Mathe-
matics Series, Volume 55 (Washington: National Bureau of Standards; reprinted 1968 by
Dover Publications, New York), Chapters 5 and 7.
6.10 Dawson s Integral
Dawson s Integral F (x) is defined by

x
2 2
F (x) =e-x et dt (6.10.1)
0
The function can also be related to the complex error function by
"
i Ä„ 2
F (z) = e-z [1 - erfc(-iz)] . (6.10.2)
2
[1]
A remarkable approximation for F (z), due to Rybicki , is
2

1 e-(z-nh)
F (z) = lim " (6.10.3)
h0 Ä„ n
n odd
What makes equation (6.10.3) 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 (6.10.3) later, in ż13.11, as
an interesting application of Fourier methods. Here we simply implement a routine
for real values of x 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 a" n0h, x a" x - x0, and n a" n - n0, so that

N
-n h)2
1 e-(x
F (x) H" " , (6.10.4)
Ä„ n + n0
n =-N
n odd
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine-
Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software.
Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)
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

n
2
e-(x -n h)2 = e-x e-(n h)2 e2x h . (6.10.5)
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
-(n h)2
evaluated. Advantage is also taken of the symmetry of the coefficients e by

breaking the summation up into positive and negative values of n separately.
In the following routine, the choices h =0.4 and N =11 are made. Because
of the symmetry of the summations and the restriction to odd values of n, the limits
on theforloops are 1 to 6. The accuracy of the result in thisfloatversion is about
2 × 10-7. In order to maintain relative accuracy near x =0, where F (x) vanishes,
[2]
the program branches to the evaluation of the power series for F (x), for |x| < 0.2.
#include
#include "nrutil.h"
#define NMAX 6
#define H 0.4
#define A1 (2.0/3.0)
#define A2 0.4
#define A3 (2.0/7.0)
float dawson(float x)

x
Returns Dawson s integral F (x) =exp(-x2) exp(t2)dt for any real x.
0
{
int i,n0;
float d1,d2,e1,e2,sum,x2,xp,xx,ans;
static float c[NMAX+1];
static int init = 0; Flag is 0 if we need to initialize, else 1.
if (init == 0) {
init=1;
for (i=1;i<=NMAX;i++) c[i]=exp(-SQR((2.0*i-1.0)*H));
}
if (fabs(x) < 0.2) { Use series expansion.
x2=x*x;
ans=x*(1.0-A1*x2*(1.0-A2*x2*(1.0-A3*x2)));
} else { Use sampling theorem representation.
xx=fabs(x);
n0=2*(int)(0.5*xx/H+0.5);
xp=xx-n0*H;
e1=exp(2.0*xp*H);
e2=e1*e1;
d1=n0+1;
d2=d1-2.0;
sum=0.0;
for (i=1;i<=NMAX;i++,d1+=2.0,d2-=2.0,e1*=e2)
sum += c[i]*(e1/d1+1.0/(d2*e1));
"
ans=0.5641895835*SIGN(exp(-xp*xp),x)*sum; Constant is 1/ Ä„.
}
return ans;
}
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine-
Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software.
Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)
6.11 Elliptic Integrals and Jacobian Elliptic Functions 261
[2,3]
Other methods for computing Dawson s integral are also known .
CITED REFERENCES AND FURTHER READING:
Rybicki, G.B. 1989, Computers in Physics, vol. 3, no. 2, pp. 85 87. [1]
Cody, W.J., Pociorek, K.A., and Thatcher, H.C. 1970, Mathematics of Computation, vol. 24,
pp. 171 178. [2]
McCabe, J.H. 1974, Mathematics of Computation, vol. 28, pp. 811 816. [3]
6.11 Elliptic Integrals and Jacobian Elliptic
Functions
Elliptic integrals occur in many applications, because any integral of the form

R(t, s) dt (6.11.1)
where R is a rational function of t and s, and s is the square root of a cubic or
quartic polynomial in t, can be evaluated in terms of elliptic integrals. Standard
[1]
references describe how to carry out the reduction, which was originally done
by Legendre. Legendre showed that only three basic elliptic integrals are required.
The simplest of these is

x
dt
I1 = (6.11.2)
(a1 + b1t)(a2 + b2t)(a3 + b3t)(a4 + b4t)
y
[2]
where we have written the quartic s2 in factored form. In standard integral tables ,
one of the limits of integration is always a zero of the quartic, while the other limit
lies closer than the next zero, so that there is no singularity within the interval. To
evaluate I1, we simply break the interval [y, x] into subintervals, each of which either
begins or ends on a singularity. The tables, therefore, need only distinguish the eight
cases in which each of the four zeros (ordered according to size) appears as the upper
or lower limit of integration. In addition, when one of the b s in (6.11.2) tends to
zero, the quartic reduces to a cubic, with the largest or smallest singularity moving
to Ä…"; this leads to eight more cases (actually just special cases of the first eight).
The sixteen cases in total are then usually tabulated in terms of Legendre s standard
elliptic integral of the 1st kind, which we will define below. By a change of the
variable of integration t, the zeros of the quartic are mapped to standard locations
on the real axis. Then only two dimensionless parameters are needed to tabulate
Legendre s integral. However, the symmetry of the original integral (6.11.2) under
permutation of the roots is concealed in Legendre s notation. We will get back to
Legendre s notation below. But first, here is a better way:
[3]
Carlson has given a new definition of a standard elliptic integral of the first kind,

"
1 dt
RF (x, y, z) = (6.11.3)
2
(t + x)(t + y)(t + z)
0
http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).
readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website
Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machine-
Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software.
Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)


Wyszukiwarka

Podobne podstrony:
WSM 10 52 pl(1)
VA US Top 40 Singles Chart 2015 10 10 Debuts Top 100
10 35
c6
401 (10)
173 21 (10)

więcej podobnych podstron