17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.9 Fresnel Integrals, Cosine and Sine Integrals 255<br />

6.9 Fresnel Integrals, Cosine and Sine Integrals<br />

Fresnel Integrals<br />

The two Fresnel integrals are defined by<br />

� x<br />

C(x) =<br />

0<br />

�<br />

π<br />

cos<br />

2 t2� dt, S(x) =<br />

� x<br />

0<br />

�<br />

π<br />

sin<br />

2 t2� dt (6.9.1)<br />

The most convenient way of evaluating these functions to arbitrary precision is<br />

to use power series for small x and a continued fraction for large x. The series are<br />

�<br />

π<br />

�2 x<br />

C(x) =x −<br />

2<br />

5<br />

5 · 2! +<br />

�<br />

π<br />

�4 x<br />

2<br />

9<br />

9 · 4! −···<br />

�<br />

π<br />

� 3 x<br />

S(x) =<br />

2 3 · 1! −<br />

�<br />

π<br />

�3 x<br />

2<br />

7<br />

7 · 3! +<br />

�<br />

π<br />

�5 x<br />

2<br />

11<br />

11 · 5! −···<br />

(6.9.2)<br />

There is a complex continued fraction that yields both S(x) and C(x) simultaneously:<br />

where<br />

e z2<br />

C(x)+iS(x) = 1+i<br />

2<br />

erfc z = 1<br />

�<br />

1<br />

√<br />

π z +<br />

= 2z<br />

√ π<br />

�<br />

1/2<br />

z +<br />

1<br />

2z 2 +1−<br />

√<br />

π<br />

erf z, z = (1 − i)x (6.9.3)<br />

2<br />

1<br />

z +<br />

3/2<br />

z +<br />

1 · 2<br />

2z 2 +5−<br />

2<br />

z + ···<br />

�<br />

3 · 4<br />

2z 2 +9− ···<br />

� (6.9.4)<br />

In the last line we have converted the “standard” form of the continued fraction to<br />

its “even” form (see §5.2), which converges twice as fast. We must be careful not<br />

to evaluate the alternating series (6.9.2) at too large a value of x; inspection of the<br />

terms shows that x =1.5 is a good point to switch over to the continued fraction.<br />

Note that for large x<br />

C(x) ∼ 1 1<br />

+<br />

2 πx sin<br />

�<br />

π<br />

2 x2� , S(x) ∼ 1 1<br />

−<br />

2 πx cos<br />

�<br />

π<br />

2 x2�<br />

(6.9.5)<br />

Thus the precision of the routine frenel may be limited by the precision of the<br />

library routines for sine and cosine for large x.<br />

Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)<br />

Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by <strong>Numerical</strong> Recipes Software.<br />

Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable<br />

files (including this one) to any server computer, is strictly prohibited. To order <strong>Numerical</strong> Recipes books or CDROMs, visit website<br />

http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!