]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/doc/sf/expint.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / sf / expint.qbk
1 [section:expint Exponential Integrals]
2
3 [section:expint_n Exponential Integral En]
4
5 [h4 Synopsis]
6
7 ``
8 #include <boost/math/special_functions/expint.hpp>
9 ``
10
11 namespace boost{ namespace math{
12
13 template <class T>
14 ``__sf_result`` expint(unsigned n, T z);
15
16 template <class T, class ``__Policy``>
17 ``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);
18
19 }} // namespaces
20
21 The return type of these functions is computed using the __arg_promotion_rules:
22 the return type is `double` if T is an integer type, and T otherwise.
23
24 [optional_policy]
25
26 [h4 Description]
27
28 template <class T>
29 ``__sf_result`` expint(unsigned n, T z);
30
31 template <class T, class ``__Policy``>
32 ``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);
33
34 Returns the [@http://mathworld.wolfram.com/En-Function.html exponential integral En]
35 of z:
36
37 [equation expint_n_1]
38
39 [graph expint2]
40
41 [h4 Accuracy]
42
43 The following table shows the peak errors (in units of epsilon)
44 found on various platforms with various floating point types,
45 along with comparisons to other libraries.
46 Unless otherwise specified any floating point type that is narrower
47 than the one shown will have __zero_error.
48
49 [table_expint_En_]
50
51 [h4 Testing]
52
53 The tests for these functions come in two parts:
54 basic sanity checks use spot values calculated using
55 [@http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=ExpIntegralE Mathworld's online evaluator],
56 while accuracy checks use high-precision test values calculated at 1000-bit precision with
57 [@http://shoup.net/ntl/doc/RR.txt NTL::RR] and this implementation.
58 Note that the generic and type-specific
59 versions of these functions use differing implementations internally, so this
60 gives us reasonably independent test data. Using our test data to test other
61 "known good" implementations also provides an additional sanity check.
62
63 [h4 Implementation]
64
65 The generic version of this function uses the continued fraction:
66
67 [equation expint_n_3]
68
69 for large /x/ and the infinite series:
70
71 [equation expint_n_2]
72
73 for small /x/.
74
75 Where the precision of /x/ is known at compile time and is 113 bits or fewer
76 in precision, then rational approximations [jm_rationals] are used for the
77 `n == 1` case.
78
79 For `x < 1` the approximating form is a minimax approximation:
80
81 [equation expint_n_4]
82
83 and for `x > 1` a Chebyshev interpolated approximation of the form:
84
85 [equation expint_n_5]
86
87 is used.
88
89
90 [endsect]
91
92 [section:expint_i Exponential Integral Ei]
93
94 [h4 Synopsis]
95
96 ``
97 #include <boost/math/special_functions/expint.hpp>
98 ``
99
100 namespace boost{ namespace math{
101
102 template <class T>
103 ``__sf_result`` expint(T z);
104
105 template <class T, class ``__Policy``>
106 ``__sf_result`` expint(T z, const ``__Policy``&);
107
108 }} // namespaces
109
110 The return type of these functions is computed using the __arg_promotion_rules:
111 the return type is `double` if T is an integer type, and T otherwise.
112
113 [optional_policy]
114
115 [h4 Description]
116
117 template <class T>
118 ``__sf_result`` expint(T z);
119
120 template <class T, class ``__Policy``>
121 ``__sf_result`` expint(T z, const ``__Policy``&);
122
123 Returns the [@http://mathworld.wolfram.com/ExponentialIntegral.html exponential integral]
124 of z:
125
126 [equation expint_i_1]
127
128 [graph expint_i]
129
130 [h4 Accuracy]
131
132 The following table shows the peak errors (in units of epsilon)
133 found on various platforms with various floating point types,
134 along with comparisons to Cody's SPECFUN implementation and the __gsl library.
135 Unless otherwise specified any floating point type that is narrower
136 than the one shown will have __zero_error.
137
138 [table_expint_Ei_]
139
140 It should be noted that all three libraries tested above
141 offer sub-epsilon precision over most of their range.
142
143 GSL has the greatest difficulty near the positive root of En, while
144 Cody's SPECFUN along with this implementation increase their
145 error rates very slightly over the range \[4,6\].
146
147 [h4 Testing]
148
149 The tests for these functions come in two parts:
150 basic sanity checks use spot values calculated using
151 [@http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=ExpIntegralEi Mathworld's online evaluator],
152 while accuracy checks use high-precision test values calculated at 1000-bit precision with
153 [@http://shoup.net/ntl/doc/RR.txt NTL::RR] and this implementation.
154 Note that the generic and type-specific
155 versions of these functions use differing implementations internally, so this
156 gives us reasonably independent test data. Using our test data to test other
157 "known good" implementations also provides an additional sanity check.
158
159 [h4 Implementation]
160
161 For x < 0 this function just calls __expint_n(1, -x): which in turn is implemented
162 in terms of rational approximations when the type of x has 113 or fewer bits of
163 precision.
164
165 For x > 0 the generic version is implemented using the infinte series:
166
167 [equation expint_i_2]
168
169 However, when the precision of the argument type is known at compile time
170 and is 113 bits or less, then rational approximations [jm_rationals] are used.
171
172 For 0 < z < 6 a root-preserving approximation of the form:
173
174 [equation expint_i_3]
175
176 is used, where z[sub 0] is the positive root of the function, and
177 R(z/3 - 1) is a minimax rational approximation rescaled so that
178 it is evaluated over \[-1,1\]. Note that while the rational approximation
179 over \[0,6\] converges rapidly to the minimax solution it is rather
180 ill-conditioned in practice. Cody and Thacher
181 [footnote W. J. Cody and H. C. Thacher, Jr.,
182 Rational Chebyshev approximations for the exponential integral E[sub 1](x),
183 Math. Comp. 22 (1968), 641-649,
184 and W. J. Cody and H. C. Thacher, Jr., Chebyshev approximations for the
185 exponential integral Ei(x), Math. Comp. 23 (1969), 289-303.]
186 experienced the same issue and
187 converted the polynomials into Chebeshev form to ensure stable
188 computation. By experiment we found that the polynomials are just as stable
189 in polynomial as Chebyshev form, /provided/ they are computed
190 over the interval \[-1,1\].
191
192 Over the a series of intervals [a,b] and [b,INF] the rational approximation
193 takes the form:
194
195 [equation expint_i_4]
196
197 where /c/ is a constant, and R(t) is a minimax solution optimised for low
198 absolute error compared to /c/. Variable /t/ is `1/z` when the range in infinite
199 and `2z/(b-a) - (2a/(b-a) + 1)` otherwise: this has the effect of scaling z to the
200 interval \[-1,1\]. As before rational approximations over arbitrary intervals
201 were found to be ill-conditioned: Cody and Thacher solved this issue by
202 converting the polynomials to their J-Fraction equivalent. However, as long
203 as the interval of evaluation was \[-1,1\] and the number of terms carefully chosen,
204 it was found that the polynomials /could/ be evaluated to suitable precision:
205 error rates are typically 2 to 3 epsilon which is comparible to the error
206 rate that Cody and Thacher achieved using J-Fractions, but marginally more
207 efficient given that fewer divisions are involved.
208
209 [endsect]
210 [endsect]
211
212 [/
213 Copyright 2006 John Maddock and Paul A. Bristow.
214 Distributed under the Boost Software License, Version 1.0.
215 (See accompanying file LICENSE_1_0.txt or copy at
216 http://www.boost.org/LICENSE_1_0.txt).
217 ]