ellint_d.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Elliptic Integral D - Legendre Form</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="../ellint.html" title="Elliptic Integrals">
  9. <link rel="prev" href="ellint_3.html" title="Elliptic Integrals of the Third Kind - Legendre Form">
  10. <link rel="next" href="jacobi_zeta.html" title="Jacobi Zeta Function">
  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="ellint_3.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ellint.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="jacobi_zeta.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.ellint.ellint_d"></a><a class="link" href="ellint_d.html" title="Elliptic Integral D - Legendre Form">Elliptic Integral D - Legendre
  28. Form</a>
  29. </h3></div></div></div>
  30. <h5>
  31. <a name="math_toolkit.ellint.ellint_d.h0"></a>
  32. <span class="phrase"><a name="math_toolkit.ellint.ellint_d.synopsis"></a></span><a class="link" href="ellint_d.html#math_toolkit.ellint.ellint_d.synopsis">Synopsis</a>
  33. </h5>
  34. <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">ellint_d</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
  35. </pre>
  36. <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>
  37. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">&gt;</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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">phi</span><span class="special">);</span>
  39. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</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>
  40. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">phi</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>
  41. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">&gt;</span>
  42. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">);</span>
  43. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</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>
  44. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</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>
  45. <span class="special">}}</span> <span class="comment">// namespaces</span>
  46. </pre>
  47. <h5>
  48. <a name="math_toolkit.ellint.ellint_d.h1"></a>
  49. <span class="phrase"><a name="math_toolkit.ellint.ellint_d.description"></a></span><a class="link" href="ellint_d.html#math_toolkit.ellint.ellint_d.description">Description</a>
  50. </h5>
  51. <p>
  52. These two functions evaluate the incomplete elliptic integral <span class="emphasis"><em>D(&#966;,
  53. k)</em></span> and its complete counterpart <span class="emphasis"><em>D(k) = D(&#960;/2, k)</em></span>.
  54. </p>
  55. <p>
  56. 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
  57. type calculation rules</em></span></a> when the arguments are of different
  58. types: when they are the same type then the result is the same type as the
  59. arguments.
  60. </p>
  61. <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">&gt;</span>
  62. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">phi</span><span class="special">);</span>
  63. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</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>
  64. <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">ellint_3</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">phi</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>
  65. </pre>
  66. <p>
  67. Returns the incomplete elliptic integral:
  68. </p>
  69. <div class="blockquote"><blockquote class="blockquote"><p>
  70. <span class="inlinemediaobject"><img src="../../../equations/ellint_d.svg"></span>
  71. </p></blockquote></div>
  72. <p>
  73. Requires <span class="emphasis"><em>k<sup>2</sup>sin<sup>2</sup>(phi) &lt; 1</em></span>, otherwise returns the result
  74. of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
  75. (outside this range the result would be complex).
  76. </p>
  77. <p>
  78. 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
  79. be used to control the behaviour of the function: how it handles errors,
  80. 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
  81. documentation for more details</a>.
  82. </p>
  83. <pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">&gt;</span>
  84. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</span><span class="special">);</span>
  85. <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T1</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>
  86. <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">ellint_d</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">k</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>
  87. </pre>
  88. <p>
  89. Returns the complete elliptic integral <span class="emphasis"><em>D(k) = D(&#960;/2, k)</em></span>
  90. </p>
  91. <p>
  92. Requires <span class="emphasis"><em>-1 &lt;= k &lt;= 1</em></span> otherwise returns the result
  93. of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
  94. (outside this range the result would be complex).
  95. </p>
  96. <p>
  97. 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
  98. be used to control the behaviour of the function: how it handles errors,
  99. 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
  100. documentation for more details</a>.
  101. </p>
  102. <h5>
  103. <a name="math_toolkit.ellint.ellint_d.h2"></a>
  104. <span class="phrase"><a name="math_toolkit.ellint.ellint_d.accuracy"></a></span><a class="link" href="ellint_d.html#math_toolkit.ellint.ellint_d.accuracy">Accuracy</a>
  105. </h5>
  106. <p>
  107. These functions are trivially computed in terms of other elliptic integrals
  108. and generally have very low error rates (a few epsilon) unless parameter
  109. &#966;
  110. is very large, in which case the usual trigonometric function argument-reduction
  111. issues apply.
  112. </p>
  113. <div class="table">
  114. <a name="math_toolkit.ellint.ellint_d.table_ellint_d_complete_"></a><p class="title"><b>Table&#160;8.66.&#160;Error rates for ellint_d (complete)</b></p>
  115. <div class="table-contents"><table class="table" summary="Error rates for ellint_d (complete)">
  116. <colgroup>
  117. <col>
  118. <col>
  119. <col>
  120. <col>
  121. <col>
  122. </colgroup>
  123. <thead><tr>
  124. <th>
  125. </th>
  126. <th>
  127. <p>
  128. GNU C++ version 7.1.0<br> linux<br> double
  129. </p>
  130. </th>
  131. <th>
  132. <p>
  133. GNU C++ version 7.1.0<br> linux<br> long double
  134. </p>
  135. </th>
  136. <th>
  137. <p>
  138. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  139. </p>
  140. </th>
  141. <th>
  142. <p>
  143. Microsoft Visual C++ version 14.1<br> Win32<br> double
  144. </p>
  145. </th>
  146. </tr></thead>
  147. <tbody>
  148. <tr>
  149. <td>
  150. <p>
  151. Elliptic Integral E: Mathworld Data
  152. </p>
  153. </td>
  154. <td>
  155. <p>
  156. <span class="blue">Max = 0.637&#949; (Mean = 0.368&#949;)</span>
  157. </p>
  158. </td>
  159. <td>
  160. <p>
  161. <span class="blue">Max = 1.27&#949; (Mean = 0.735&#949;)</span>
  162. </p>
  163. </td>
  164. <td>
  165. <p>
  166. <span class="blue">Max = 1.27&#949; (Mean = 0.735&#949;)</span>
  167. </p>
  168. </td>
  169. <td>
  170. <p>
  171. <span class="blue">Max = 0.637&#949; (Mean = 0.368&#949;)</span>
  172. </p>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td>
  177. <p>
  178. Elliptic Integral D: Random Data
  179. </p>
  180. </td>
  181. <td>
  182. <p>
  183. <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
  184. </p>
  185. </td>
  186. <td>
  187. <p>
  188. <span class="blue">Max = 1.27&#949; (Mean = 0.334&#949;)</span>
  189. </p>
  190. </td>
  191. <td>
  192. <p>
  193. <span class="blue">Max = 1.27&#949; (Mean = 0.334&#949;)</span>
  194. </p>
  195. </td>
  196. <td>
  197. <p>
  198. <span class="blue">Max = 1.27&#949; (Mean = 0.355&#949;)</span>
  199. </p>
  200. </td>
  201. </tr>
  202. </tbody>
  203. </table></div>
  204. </div>
  205. <br class="table-break"><div class="table">
  206. <a name="math_toolkit.ellint.ellint_d.table_ellint_d"></a><p class="title"><b>Table&#160;8.67.&#160;Error rates for ellint_d</b></p>
  207. <div class="table-contents"><table class="table" summary="Error rates for ellint_d">
  208. <colgroup>
  209. <col>
  210. <col>
  211. <col>
  212. <col>
  213. <col>
  214. </colgroup>
  215. <thead><tr>
  216. <th>
  217. </th>
  218. <th>
  219. <p>
  220. GNU C++ version 7.1.0<br> linux<br> double
  221. </p>
  222. </th>
  223. <th>
  224. <p>
  225. GNU C++ version 7.1.0<br> linux<br> long double
  226. </p>
  227. </th>
  228. <th>
  229. <p>
  230. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  231. </p>
  232. </th>
  233. <th>
  234. <p>
  235. Microsoft Visual C++ version 14.1<br> Win32<br> double
  236. </p>
  237. </th>
  238. </tr></thead>
  239. <tbody>
  240. <tr>
  241. <td>
  242. <p>
  243. Elliptic Integral E: Mathworld Data
  244. </p>
  245. </td>
  246. <td>
  247. <p>
  248. <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
  249. 2.1:</em></span> Max = 0.862&#949; (Mean = 0.568&#949;))
  250. </p>
  251. </td>
  252. <td>
  253. <p>
  254. <span class="blue">Max = 1.3&#949; (Mean = 0.813&#949;)</span>
  255. </p>
  256. </td>
  257. <td>
  258. <p>
  259. <span class="blue">Max = 1.3&#949; (Mean = 0.813&#949;)</span>
  260. </p>
  261. </td>
  262. <td>
  263. <p>
  264. <span class="blue">Max = 0.862&#949; (Mean = 0.457&#949;)</span>
  265. </p>
  266. </td>
  267. </tr>
  268. <tr>
  269. <td>
  270. <p>
  271. Elliptic Integral D: Random Data
  272. </p>
  273. </td>
  274. <td>
  275. <p>
  276. <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
  277. 2.1:</em></span> Max = 3.01&#949; (Mean = 0.928&#949;))
  278. </p>
  279. </td>
  280. <td>
  281. <p>
  282. <span class="blue">Max = 2.51&#949; (Mean = 0.883&#949;)</span>
  283. </p>
  284. </td>
  285. <td>
  286. <p>
  287. <span class="blue">Max = 2.51&#949; (Mean = 0.883&#949;)</span>
  288. </p>
  289. </td>
  290. <td>
  291. <p>
  292. <span class="blue">Max = 2.87&#949; (Mean = 0.805&#949;)</span>
  293. </p>
  294. </td>
  295. </tr>
  296. </tbody>
  297. </table></div>
  298. </div>
  299. <br class="table-break"><p>
  300. The following error plot are based on an exhaustive search of the functions
  301. domain, MSVC-15.5 at <code class="computeroutput"><span class="keyword">double</span></code>
  302. precision, and GCC-7.1/Ubuntu for <code class="computeroutput"><span class="keyword">long</span>
  303. <span class="keyword">double</span></code> and <code class="computeroutput"><span class="identifier">__float128</span></code>.
  304. </p>
  305. <div class="blockquote"><blockquote class="blockquote"><p>
  306. <span class="inlinemediaobject"><img src="../../../graphs/elliptic_integral_d__double.svg" align="middle"></span>
  307. </p></blockquote></div>
  308. <div class="blockquote"><blockquote class="blockquote"><p>
  309. <span class="inlinemediaobject"><img src="../../../graphs/elliptic_integral_d__80_bit_long_double.svg" align="middle"></span>
  310. </p></blockquote></div>
  311. <div class="blockquote"><blockquote class="blockquote"><p>
  312. <span class="inlinemediaobject"><img src="../../../graphs/elliptic_integral_d____float128.svg" align="middle"></span>
  313. </p></blockquote></div>
  314. <h5>
  315. <a name="math_toolkit.ellint.ellint_d.h3"></a>
  316. <span class="phrase"><a name="math_toolkit.ellint.ellint_d.testing"></a></span><a class="link" href="ellint_d.html#math_toolkit.ellint.ellint_d.testing">Testing</a>
  317. </h5>
  318. <p>
  319. The tests use a mixture of spot test values calculated using values calculated
  320. at <a href="http://www.wolframalpha.com/" target="_top">Wolfram Alpha</a>, and random
  321. test data generated using MPFR at 1000-bit precision and a deliberately naive
  322. implementation in terms of the Legendre integrals.
  323. </p>
  324. <h5>
  325. <a name="math_toolkit.ellint.ellint_d.h4"></a>
  326. <span class="phrase"><a name="math_toolkit.ellint.ellint_d.implementation"></a></span><a class="link" href="ellint_d.html#math_toolkit.ellint.ellint_d.implementation">Implementation</a>
  327. </h5>
  328. <p>
  329. The implementation for D(&#966;, k) first performs argument reduction using the
  330. relations:
  331. </p>
  332. <div class="blockquote"><blockquote class="blockquote"><p>
  333. <span class="serif_italic"><span class="emphasis"><em>D(-&#966;, k) = -D(&#966;, k)</em></span></span>
  334. </p></blockquote></div>
  335. <p>
  336. and
  337. </p>
  338. <div class="blockquote"><blockquote class="blockquote"><p>
  339. <span class="serif_italic"><span class="emphasis"><em>D(n&#960;+&#966;, k) = 2nD(k) + D(&#966;, k)</em></span></span>
  340. </p></blockquote></div>
  341. <p>
  342. to move &#966; to the range [0, &#960;/2].
  343. </p>
  344. <p>
  345. The functions are then implemented in terms of Carlson's integral R<sub>D</sub>
  346. using
  347. the relation:
  348. </p>
  349. <div class="blockquote"><blockquote class="blockquote"><p>
  350. <span class="inlinemediaobject"><img src="../../../equations/ellint_d.svg"></span>
  351. </p></blockquote></div>
  352. </div>
  353. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  354. <td align="left"></td>
  355. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  356. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  357. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  358. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  359. Daryle Walker and Xiaogang Zhang<p>
  360. Distributed under the Boost Software License, Version 1.0. (See accompanying
  361. 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>)
  362. </p>
  363. </div></td>
  364. </tr></table>
  365. <hr>
  366. <div class="spirit-nav">
  367. <a accesskey="p" href="ellint_3.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ellint.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="jacobi_zeta.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  368. </div>
  369. </body>
  370. </html>