]>
Commit | Line | Data |
---|---|---|
1 | <html> | |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Exponential Integral En</title> | |
5 | <link rel="stylesheet" href="../../math.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../../index.html" title="Math Toolkit 2.5.1"> | |
8 | <link rel="up" href="../expint.html" title="Exponential Integrals"> | |
9 | <link rel="prev" href="../expint.html" title="Exponential Integrals"> | |
10 | <link rel="next" href="expint_i.html" title="Exponential Integral Ei"> | |
11 | </head> | |
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
13 | <table cellpadding="2" width="100%"><tr> | |
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> | |
15 | <td align="center"><a href="../../../../../../index.html">Home</a></td> | |
16 | <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> | |
17 | <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> | |
18 | <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> | |
19 | <td align="center"><a href="../../../../../../more/index.htm">More</a></td> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="../expint.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../expint.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expint_i.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h3 class="title"> | |
27 | <a name="math_toolkit.expint.expint_n"></a><a class="link" href="expint_n.html" title="Exponential Integral En">Exponential Integral En</a> | |
28 | </h3></div></div></div> | |
29 | <h5> | |
30 | <a name="math_toolkit.expint.expint_n.h0"></a> | |
31 | <span class="phrase"><a name="math_toolkit.expint.expint_n.synopsis"></a></span><a class="link" href="expint_n.html#math_toolkit.expint.expint_n.synopsis">Synopsis</a> | |
32 | </h5> | |
33 | <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">expint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> | |
34 | </pre> | |
35 | <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> | |
36 | ||
37 | <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> | |
38 | <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">expint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> | |
39 | ||
40 | <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> | |
41 | <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">expint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> | |
42 | ||
43 | <span class="special">}}</span> <span class="comment">// namespaces</span> | |
44 | </pre> | |
45 | <p> | |
46 | The return type of these functions is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result | |
47 | type calculation rules</em></span></a>: the return type is <code class="computeroutput"><span class="keyword">double</span></code> if T is an integer type, and T otherwise. | |
48 | </p> | |
49 | <p> | |
50 | The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can | |
51 | be used to control the behaviour of the function: how it handles errors, | |
52 | what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy | |
53 | documentation for more details</a>. | |
54 | </p> | |
55 | <h5> | |
56 | <a name="math_toolkit.expint.expint_n.h1"></a> | |
57 | <span class="phrase"><a name="math_toolkit.expint.expint_n.description"></a></span><a class="link" href="expint_n.html#math_toolkit.expint.expint_n.description">Description</a> | |
58 | </h5> | |
59 | <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> | |
60 | <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">expint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span> | |
61 | ||
62 | <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> | |
63 | <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">expint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">z</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> | |
64 | </pre> | |
65 | <p> | |
66 | Returns the <a href="http://mathworld.wolfram.com/En-Function.html" target="_top">exponential | |
67 | integral En</a> of z: | |
68 | </p> | |
69 | <p> | |
70 | <span class="inlinemediaobject"><img src="../../../equations/expint_n_1.svg"></span> | |
71 | </p> | |
72 | <p> | |
73 | <span class="inlinemediaobject"><img src="../../../graphs/expint2.svg" align="middle"></span> | |
74 | </p> | |
75 | <h5> | |
76 | <a name="math_toolkit.expint.expint_n.h2"></a> | |
77 | <span class="phrase"><a name="math_toolkit.expint.expint_n.accuracy"></a></span><a class="link" href="expint_n.html#math_toolkit.expint.expint_n.accuracy">Accuracy</a> | |
78 | </h5> | |
79 | <p> | |
80 | The following table shows the peak errors (in units of epsilon) found on | |
81 | various platforms with various floating point types, along with comparisons | |
82 | to other libraries. Unless otherwise specified any floating point type that | |
83 | is narrower than the one shown will have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively | |
84 | zero error</a>. | |
85 | </p> | |
86 | <div class="table"> | |
87 | <a name="math_toolkit.expint.expint_n.table_expint_En_"></a><p class="title"><b>Table 6.74. Error rates for expint (En)</b></p> | |
88 | <div class="table-contents"><table class="table" summary="Error rates for expint (En)"> | |
89 | <colgroup> | |
90 | <col> | |
91 | <col> | |
92 | <col> | |
93 | <col> | |
94 | <col> | |
95 | </colgroup> | |
96 | <thead><tr> | |
97 | <th> | |
98 | </th> | |
99 | <th> | |
100 | <p> | |
101 | Microsoft Visual C++ version 12.0<br> Win32<br> double | |
102 | </p> | |
103 | </th> | |
104 | <th> | |
105 | <p> | |
106 | GNU C++ version 5.1.0<br> linux<br> double | |
107 | </p> | |
108 | </th> | |
109 | <th> | |
110 | <p> | |
111 | GNU C++ version 5.1.0<br> linux<br> long double | |
112 | </p> | |
113 | </th> | |
114 | <th> | |
115 | <p> | |
116 | Sun compiler version 0x5130<br> Sun Solaris<br> long double | |
117 | </p> | |
118 | </th> | |
119 | </tr></thead> | |
120 | <tbody> | |
121 | <tr> | |
122 | <td> | |
123 | <p> | |
124 | Exponential Integral En | |
125 | </p> | |
126 | </td> | |
127 | <td> | |
128 | <p> | |
129 | <span class="blue">Max = 7.16ε (Mean = 1.85ε)</span> | |
130 | </p> | |
131 | </td> | |
132 | <td> | |
133 | <p> | |
134 | <span class="blue">Max = 0.589ε (Mean = 0.0331ε)</span><br> | |
135 | <br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 58.5ε (Mean = 17.1ε)) | |
136 | </p> | |
137 | </td> | |
138 | <td> | |
139 | <p> | |
140 | <span class="blue">Max = 9.97ε (Mean = 2.13ε)</span> | |
141 | </p> | |
142 | </td> | |
143 | <td> | |
144 | <p> | |
145 | <span class="blue">Max = 9.97ε (Mean = 2.13ε)</span> | |
146 | </p> | |
147 | </td> | |
148 | </tr> | |
149 | <tr> | |
150 | <td> | |
151 | <p> | |
152 | Exponential Integral En: small z values | |
153 | </p> | |
154 | </td> | |
155 | <td> | |
156 | <p> | |
157 | <span class="blue">Max = 2.62ε (Mean = 0.531ε)</span> | |
158 | </p> | |
159 | </td> | |
160 | <td> | |
161 | <p> | |
162 | <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>GSL | |
163 | 1.16:</em></span> Max = 115ε (Mean = 23.6ε)) | |
164 | </p> | |
165 | </td> | |
166 | <td> | |
167 | <p> | |
168 | <span class="blue">Max = 1.99ε (Mean = 0.559ε)</span> | |
169 | </p> | |
170 | </td> | |
171 | <td> | |
172 | <p> | |
173 | <span class="blue">Max = 1.99ε (Mean = 0.559ε)</span> | |
174 | </p> | |
175 | </td> | |
176 | </tr> | |
177 | <tr> | |
178 | <td> | |
179 | <p> | |
180 | Exponential Integral E1 | |
181 | </p> | |
182 | </td> | |
183 | <td> | |
184 | <p> | |
185 | <span class="blue">Max = 0.988ε (Mean = 0.486ε)</span> | |
186 | </p> | |
187 | </td> | |
188 | <td> | |
189 | <p> | |
190 | <span class="blue">Max = 0.556ε (Mean = 0.0625ε)</span><br> | |
191 | <br> (<span class="emphasis"><em>GSL 1.16:</em></span> Max = 0.988ε (Mean = 0.469ε)) | |
192 | </p> | |
193 | </td> | |
194 | <td> | |
195 | <p> | |
196 | <span class="blue">Max = 0.965ε (Mean = 0.414ε)</span> | |
197 | </p> | |
198 | </td> | |
199 | <td> | |
200 | <p> | |
201 | <span class="blue">Max = 0.965ε (Mean = 0.409ε)</span> | |
202 | </p> | |
203 | </td> | |
204 | </tr> | |
205 | </tbody> | |
206 | </table></div> | |
207 | </div> | |
208 | <br class="table-break"><h5> | |
209 | <a name="math_toolkit.expint.expint_n.h3"></a> | |
210 | <span class="phrase"><a name="math_toolkit.expint.expint_n.testing"></a></span><a class="link" href="expint_n.html#math_toolkit.expint.expint_n.testing">Testing</a> | |
211 | </h5> | |
212 | <p> | |
213 | The tests for these functions come in two parts: basic sanity checks use | |
214 | spot values calculated using <a href="http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=ExpIntegralE" target="_top">Mathworld's | |
215 | online evaluator</a>, while accuracy checks use high-precision test values | |
216 | calculated at 1000-bit precision with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL::RR</a> | |
217 | and this implementation. Note that the generic and type-specific versions | |
218 | of these functions use differing implementations internally, so this gives | |
219 | us reasonably independent test data. Using our test data to test other "known | |
220 | good" implementations also provides an additional sanity check. | |
221 | </p> | |
222 | <h5> | |
223 | <a name="math_toolkit.expint.expint_n.h4"></a> | |
224 | <span class="phrase"><a name="math_toolkit.expint.expint_n.implementation"></a></span><a class="link" href="expint_n.html#math_toolkit.expint.expint_n.implementation">Implementation</a> | |
225 | </h5> | |
226 | <p> | |
227 | The generic version of this function uses the continued fraction: | |
228 | </p> | |
229 | <p> | |
230 | <span class="inlinemediaobject"><img src="../../../equations/expint_n_3.svg"></span> | |
231 | </p> | |
232 | <p> | |
233 | for large <span class="emphasis"><em>x</em></span> and the infinite series: | |
234 | </p> | |
235 | <p> | |
236 | <span class="inlinemediaobject"><img src="../../../equations/expint_n_2.svg"></span> | |
237 | </p> | |
238 | <p> | |
239 | for small <span class="emphasis"><em>x</em></span>. | |
240 | </p> | |
241 | <p> | |
242 | Where the precision of <span class="emphasis"><em>x</em></span> is known at compile time and | |
243 | is 113 bits or fewer in precision, then rational approximations <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised | |
244 | by JM</a> are used for the <code class="computeroutput"><span class="identifier">n</span> | |
245 | <span class="special">==</span> <span class="number">1</span></code> | |
246 | case. | |
247 | </p> | |
248 | <p> | |
249 | For <code class="computeroutput"><span class="identifier">x</span> <span class="special"><</span> | |
250 | <span class="number">1</span></code> the approximating form is a minimax | |
251 | approximation: | |
252 | </p> | |
253 | <p> | |
254 | <span class="inlinemediaobject"><img src="../../../equations/expint_n_4.svg"></span> | |
255 | </p> | |
256 | <p> | |
257 | and for <code class="computeroutput"><span class="identifier">x</span> <span class="special">></span> | |
258 | <span class="number">1</span></code> a Chebyshev interpolated approximation | |
259 | of the form: | |
260 | </p> | |
261 | <p> | |
262 | <span class="inlinemediaobject"><img src="../../../equations/expint_n_5.svg"></span> | |
263 | </p> | |
264 | <p> | |
265 | is used. | |
266 | </p> | |
267 | </div> | |
268 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
269 | <td align="left"></td> | |
270 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
271 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
272 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
273 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
274 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
275 | file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) | |
276 | </p> | |
277 | </div></td> | |
278 | </tr></table> | |
279 | <hr> | |
280 | <div class="spirit-nav"> | |
281 | <a accesskey="p" href="../expint.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../expint.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expint_i.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> | |
282 | </div> | |
283 | </body> | |
284 | </html> |