expint_n.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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.79.1">
  7. <link rel="home" href="../../index.html" title="Math Toolkit 2.11.0">
  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">&lt;</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">&gt;</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. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
  37. <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>
  38. <span class="keyword">template</span> <span class="special">&lt;</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&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
  39. <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&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
  40. <span class="special">}}</span> <span class="comment">// namespaces</span>
  41. </pre>
  42. <p>
  43. 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
  44. 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.
  45. </p>
  46. <p>
  47. The final <a class="link" href="../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
  48. be used to control the behaviour of the function: how it handles errors,
  49. what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">policy
  50. documentation for more details</a>.
  51. </p>
  52. <h5>
  53. <a name="math_toolkit.expint.expint_n.h1"></a>
  54. <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>
  55. </h5>
  56. <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
  57. <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>
  58. <span class="keyword">template</span> <span class="special">&lt;</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&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
  59. <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&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
  60. </pre>
  61. <p>
  62. Returns the <a href="http://mathworld.wolfram.com/En-Function.html" target="_top">exponential
  63. integral En</a> of z:
  64. </p>
  65. <div class="blockquote"><blockquote class="blockquote"><p>
  66. <span class="inlinemediaobject"><img src="../../../equations/expint_n_1.svg"></span>
  67. </p></blockquote></div>
  68. <div class="blockquote"><blockquote class="blockquote"><p>
  69. <span class="inlinemediaobject"><img src="../../../graphs/expint2.svg" align="middle"></span>
  70. </p></blockquote></div>
  71. <h5>
  72. <a name="math_toolkit.expint.expint_n.h2"></a>
  73. <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>
  74. </h5>
  75. <p>
  76. The following table shows the peak errors (in units of epsilon) found on
  77. various platforms with various floating point types, along with comparisons
  78. to other libraries. Unless otherwise specified any floating point type that
  79. is narrower than the one shown will have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
  80. zero error</a>.
  81. </p>
  82. <div class="table">
  83. <a name="math_toolkit.expint.expint_n.table_expint_En_"></a><p class="title"><b>Table&#160;8.77.&#160;Error rates for expint (En)</b></p>
  84. <div class="table-contents"><table class="table" summary="Error rates for expint (En)">
  85. <colgroup>
  86. <col>
  87. <col>
  88. <col>
  89. <col>
  90. <col>
  91. </colgroup>
  92. <thead><tr>
  93. <th>
  94. </th>
  95. <th>
  96. <p>
  97. GNU C++ version 7.1.0<br> linux<br> double
  98. </p>
  99. </th>
  100. <th>
  101. <p>
  102. GNU C++ version 7.1.0<br> linux<br> long double
  103. </p>
  104. </th>
  105. <th>
  106. <p>
  107. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  108. </p>
  109. </th>
  110. <th>
  111. <p>
  112. Microsoft Visual C++ version 14.1<br> Win32<br> double
  113. </p>
  114. </th>
  115. </tr></thead>
  116. <tbody>
  117. <tr>
  118. <td>
  119. <p>
  120. Exponential Integral En
  121. </p>
  122. </td>
  123. <td>
  124. <p>
  125. <span class="blue">Max = 0.589&#949; (Mean = 0.0331&#949;)</span><br>
  126. <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 58.5&#949; (Mean = 17.1&#949;))
  127. </p>
  128. </td>
  129. <td>
  130. <p>
  131. <span class="blue">Max = 9.97&#949; (Mean = 2.13&#949;)</span>
  132. </p>
  133. </td>
  134. <td>
  135. <p>
  136. <span class="blue">Max = 9.97&#949; (Mean = 2.13&#949;)</span>
  137. </p>
  138. </td>
  139. <td>
  140. <p>
  141. <span class="blue">Max = 7.16&#949; (Mean = 1.85&#949;)</span>
  142. </p>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td>
  147. <p>
  148. Exponential Integral En: small z values
  149. </p>
  150. </td>
  151. <td>
  152. <p>
  153. <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
  154. 2.1:</em></span> Max = 115&#949; (Mean = 23.6&#949;))
  155. </p>
  156. </td>
  157. <td>
  158. <p>
  159. <span class="blue">Max = 1.99&#949; (Mean = 0.559&#949;)</span>
  160. </p>
  161. </td>
  162. <td>
  163. <p>
  164. <span class="blue">Max = 1.99&#949; (Mean = 0.559&#949;)</span>
  165. </p>
  166. </td>
  167. <td>
  168. <p>
  169. <span class="blue">Max = 2.62&#949; (Mean = 0.531&#949;)</span>
  170. </p>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td>
  175. <p>
  176. Exponential Integral E1
  177. </p>
  178. </td>
  179. <td>
  180. <p>
  181. <span class="blue">Max = 0.556&#949; (Mean = 0.0625&#949;)</span><br>
  182. <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 0.988&#949; (Mean = 0.469&#949;))
  183. </p>
  184. </td>
  185. <td>
  186. <p>
  187. <span class="blue">Max = 0.965&#949; (Mean = 0.414&#949;)</span>
  188. </p>
  189. </td>
  190. <td>
  191. <p>
  192. <span class="blue">Max = 0.965&#949; (Mean = 0.408&#949;)</span>
  193. </p>
  194. </td>
  195. <td>
  196. <p>
  197. <span class="blue">Max = 0.988&#949; (Mean = 0.486&#949;)</span>
  198. </p>
  199. </td>
  200. </tr>
  201. </tbody>
  202. </table></div>
  203. </div>
  204. <br class="table-break"><h5>
  205. <a name="math_toolkit.expint.expint_n.h3"></a>
  206. <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>
  207. </h5>
  208. <p>
  209. The tests for these functions come in two parts: basic sanity checks use
  210. spot values calculated using <a href="http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=ExpIntegralE" target="_top">Mathworld's
  211. online evaluator</a>, while accuracy checks use high-precision test values
  212. calculated at 1000-bit precision with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL::RR</a>
  213. and this implementation. Note that the generic and type-specific versions
  214. of these functions use differing implementations internally, so this gives
  215. us reasonably independent test data. Using our test data to test other "known
  216. good" implementations also provides an additional sanity check.
  217. </p>
  218. <h5>
  219. <a name="math_toolkit.expint.expint_n.h4"></a>
  220. <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>
  221. </h5>
  222. <p>
  223. The generic version of this function uses the continued fraction:
  224. </p>
  225. <div class="blockquote"><blockquote class="blockquote"><p>
  226. <span class="inlinemediaobject"><img src="../../../equations/expint_n_3.svg"></span>
  227. </p></blockquote></div>
  228. <p>
  229. for large <span class="emphasis"><em>x</em></span> and the infinite series:
  230. </p>
  231. <div class="blockquote"><blockquote class="blockquote"><p>
  232. <span class="inlinemediaobject"><img src="../../../equations/expint_n_2.svg"></span>
  233. </p></blockquote></div>
  234. <p>
  235. for small <span class="emphasis"><em>x</em></span>.
  236. </p>
  237. <p>
  238. Where the precision of <span class="emphasis"><em>x</em></span> is known at compile time and
  239. 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
  240. by JM</a> are used for the <code class="computeroutput"><span class="identifier">n</span>
  241. <span class="special">==</span> <span class="number">1</span></code>
  242. case.
  243. </p>
  244. <p>
  245. For <code class="computeroutput"><span class="identifier">x</span> <span class="special">&lt;</span>
  246. <span class="number">1</span></code> the approximating form is a minimax
  247. approximation:
  248. </p>
  249. <div class="blockquote"><blockquote class="blockquote"><p>
  250. <span class="inlinemediaobject"><img src="../../../equations/expint_n_4.svg"></span>
  251. </p></blockquote></div>
  252. <p>
  253. and for <code class="computeroutput"><span class="identifier">x</span> <span class="special">&gt;</span>
  254. <span class="number">1</span></code> a Chebyshev interpolated approximation
  255. of the form:
  256. </p>
  257. <div class="blockquote"><blockquote class="blockquote"><p>
  258. <span class="inlinemediaobject"><img src="../../../equations/expint_n_5.svg"></span>
  259. </p></blockquote></div>
  260. <p>
  261. is used.
  262. </p>
  263. </div>
  264. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  265. <td align="left"></td>
  266. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  267. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  268. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  269. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  270. Daryle Walker and Xiaogang Zhang<p>
  271. Distributed under the Boost Software License, Version 1.0. (See accompanying
  272. 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>)
  273. </p>
  274. </div></td>
  275. </tr></table>
  276. <hr>
  277. <div class="spirit-nav">
  278. <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>
  279. </div>
  280. </body>
  281. </html>