sph_bessel.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Spherical Bessel Functions of the First and Second Kinds</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="../bessel.html" title="Bessel Functions">
  9. <link rel="prev" href="mbessel.html" title="Modified Bessel Functions of the First and Second Kinds">
  10. <link rel="next" href="bessel_derivatives.html" title="Derivatives of the Bessel Functions">
  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="mbessel.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bessel.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="bessel_derivatives.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.bessel.sph_bessel"></a><a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">Spherical Bessel Functions
  28. of the First and Second Kinds</a>
  29. </h3></div></div></div>
  30. <h5>
  31. <a name="math_toolkit.bessel.sph_bessel.h0"></a>
  32. <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.synopsis"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.synopsis">Synopsis</a>
  33. </h5>
  34. <p>
  35. <code class="computeroutput"><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">bessel</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
  36. </p>
  37. <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>
  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">sph_bessel</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</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">sph_bessel</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</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">,</span> <span class="keyword">class</span> <span class="identifier">T2</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">sph_neumann</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</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> <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>
  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">sph_neumann</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">x</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. </pre>
  46. <h5>
  47. <a name="math_toolkit.bessel.sph_bessel.h1"></a>
  48. <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.description"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.description">Description</a>
  49. </h5>
  50. <p>
  51. The functions <a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">sph_bessel</a>
  52. and <a class="link" href="sph_bessel.html" title="Spherical Bessel Functions of the First and Second Kinds">sph_neumann</a> return
  53. the result of the Spherical Bessel functions of the first and second kinds
  54. respectively:
  55. </p>
  56. <div class="blockquote"><blockquote class="blockquote"><p>
  57. sph_bessel(v, x) = j<sub>v</sub>(x)
  58. </p></blockquote></div>
  59. <div class="blockquote"><blockquote class="blockquote"><p>
  60. sph_neumann(v, x) = y<sub>v</sub>(x) = n<sub>v</sub>(x)
  61. </p></blockquote></div>
  62. <p>
  63. where:
  64. </p>
  65. <div class="blockquote"><blockquote class="blockquote"><p>
  66. <span class="inlinemediaobject"><img src="../../../equations/sbessel2.svg"></span>
  67. </p></blockquote></div>
  68. <p>
  69. 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
  70. type calculation rules</em></span></a> for the single argument type T.
  71. </p>
  72. <p>
  73. 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
  74. be used to control the behaviour of the function: how it handles errors,
  75. 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
  76. documentation for more details</a>.
  77. </p>
  78. <p>
  79. The functions return the result of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
  80. whenever the result is undefined or complex: this occurs when <code class="computeroutput"><span class="identifier">x</span> <span class="special">&lt;</span> <span class="number">0</span></code>.
  81. </p>
  82. <p>
  83. The j<sub>v</sub> function is cyclic like J<sub>v</sub> but differs in its behaviour at the origin:
  84. </p>
  85. <div class="blockquote"><blockquote class="blockquote"><p>
  86. <span class="inlinemediaobject"><img src="../../../graphs/sph_bessel.svg" align="middle"></span>
  87. </p></blockquote></div>
  88. <p>
  89. Likewise y<sub>v</sub> is also cyclic for large x, but tends to -&#8734;
  90. for small <span class="emphasis"><em>x</em></span>:
  91. </p>
  92. <div class="blockquote"><blockquote class="blockquote"><p>
  93. <span class="inlinemediaobject"><img src="../../../graphs/sph_neumann.svg" align="middle"></span>
  94. </p></blockquote></div>
  95. <h5>
  96. <a name="math_toolkit.bessel.sph_bessel.h2"></a>
  97. <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.testing"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.testing">Testing</a>
  98. </h5>
  99. <p>
  100. There are two sets of test values: spot values calculated using <a href="http://functions.wolfram.com/" target="_top">functions.wolfram.com</a>,
  101. and a much larger set of tests computed using a simplified version of this
  102. implementation (with all the special case handling removed).
  103. </p>
  104. <h5>
  105. <a name="math_toolkit.bessel.sph_bessel.h3"></a>
  106. <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.accuracy"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.accuracy">Accuracy</a>
  107. </h5>
  108. <div class="table">
  109. <a name="math_toolkit.bessel.sph_bessel.table_sph_bessel"></a><p class="title"><b>Table&#160;8.48.&#160;Error rates for sph_bessel</b></p>
  110. <div class="table-contents"><table class="table" summary="Error rates for sph_bessel">
  111. <colgroup>
  112. <col>
  113. <col>
  114. <col>
  115. <col>
  116. <col>
  117. </colgroup>
  118. <thead><tr>
  119. <th>
  120. </th>
  121. <th>
  122. <p>
  123. GNU C++ version 7.1.0<br> linux<br> long double
  124. </p>
  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. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  134. </p>
  135. </th>
  136. <th>
  137. <p>
  138. Microsoft Visual C++ version 14.1<br> Win32<br> double
  139. </p>
  140. </th>
  141. </tr></thead>
  142. <tbody><tr>
  143. <td>
  144. <p>
  145. Bessel j: Random Data
  146. </p>
  147. </td>
  148. <td>
  149. <p>
  150. <span class="blue">Max = 243&#949; (Mean = 13.3&#949;)</span><br> <br>
  151. (<span class="emphasis"><em>&lt;cmath&gt;:</em></span> Max = 1.91e+06&#949; (Mean = 1.09e+05&#949;))
  152. </p>
  153. </td>
  154. <td>
  155. <p>
  156. <span class="blue">Max = 0.978&#949; (Mean = 0.0445&#949;)</span><br>
  157. <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 1.79e+03&#949; (Mean = 107&#949;))
  158. </p>
  159. </td>
  160. <td>
  161. <p>
  162. <span class="blue">Max = 243&#949; (Mean = 33.7&#949;)</span>
  163. </p>
  164. </td>
  165. <td>
  166. <p>
  167. <span class="blue">Max = 245&#949; (Mean = 16.3&#949;)</span>
  168. </p>
  169. </td>
  170. </tr></tbody>
  171. </table></div>
  172. </div>
  173. <br class="table-break"><div class="table">
  174. <a name="math_toolkit.bessel.sph_bessel.table_sph_neumann"></a><p class="title"><b>Table&#160;8.49.&#160;Error rates for sph_neumann</b></p>
  175. <div class="table-contents"><table class="table" summary="Error rates for sph_neumann">
  176. <colgroup>
  177. <col>
  178. <col>
  179. <col>
  180. <col>
  181. <col>
  182. </colgroup>
  183. <thead><tr>
  184. <th>
  185. </th>
  186. <th>
  187. <p>
  188. GNU C++ version 7.1.0<br> linux<br> long double
  189. </p>
  190. </th>
  191. <th>
  192. <p>
  193. GNU C++ version 7.1.0<br> linux<br> double
  194. </p>
  195. </th>
  196. <th>
  197. <p>
  198. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  199. </p>
  200. </th>
  201. <th>
  202. <p>
  203. Microsoft Visual C++ version 14.1<br> Win32<br> double
  204. </p>
  205. </th>
  206. </tr></thead>
  207. <tbody><tr>
  208. <td>
  209. <p>
  210. y: Random Data
  211. </p>
  212. </td>
  213. <td>
  214. <p>
  215. <span class="blue">Max = 234&#949; (Mean = 19.5&#949;)</span><br> <br>
  216. (<span class="emphasis"><em>&lt;cmath&gt;:</em></span> Max = 1.6e+06&#949; (Mean = 1.4e+05&#949;))
  217. </p>
  218. </td>
  219. <td>
  220. <p>
  221. <span class="blue">Max = 0.995&#949; (Mean = 0.0665&#949;)</span><br>
  222. <br> (<span class="emphasis"><em>GSL 2.1:</em></span> Max = 8.5e+04&#949; (Mean = 5.33e+03&#949;))
  223. </p>
  224. </td>
  225. <td>
  226. <p>
  227. <span class="blue">Max = 234&#949; (Mean = 19.8&#949;)</span>
  228. </p>
  229. </td>
  230. <td>
  231. <p>
  232. <span class="blue">Max = 281&#949; (Mean = 31.1&#949;)</span>
  233. </p>
  234. </td>
  235. </tr></tbody>
  236. </table></div>
  237. </div>
  238. <br class="table-break"><h5>
  239. <a name="math_toolkit.bessel.sph_bessel.h4"></a>
  240. <span class="phrase"><a name="math_toolkit.bessel.sph_bessel.implementation"></a></span><a class="link" href="sph_bessel.html#math_toolkit.bessel.sph_bessel.implementation">Implementation</a>
  241. </h5>
  242. <p>
  243. Other than error handling and a couple of special cases these functions are
  244. implemented directly in terms of their definitions:
  245. </p>
  246. <div class="blockquote"><blockquote class="blockquote"><p>
  247. <span class="inlinemediaobject"><img src="../../../equations/sbessel2.svg"></span>
  248. </p></blockquote></div>
  249. <p>
  250. The special cases occur for:
  251. </p>
  252. <div class="blockquote"><blockquote class="blockquote"><p>
  253. j<sub>0</sub>= <a class="link" href="../sinc/sinc_pi.html" title="sinc_pi">sinc_pi</a>(x) = sin(x)
  254. / x
  255. </p></blockquote></div>
  256. <p>
  257. and for small <span class="emphasis"><em>x &lt; 1</em></span>, we can use the series:
  258. </p>
  259. <div class="blockquote"><blockquote class="blockquote"><p>
  260. <span class="inlinemediaobject"><img src="../../../equations/sbessel5.svg"></span>
  261. </p></blockquote></div>
  262. <p>
  263. which neatly avoids the problem of calculating 0/0 that can occur with the
  264. main definition as x &#8594; 0.
  265. </p>
  266. </div>
  267. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  268. <td align="left"></td>
  269. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  270. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  271. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  272. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  273. 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="mbessel.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bessel.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="bessel_derivatives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  282. </div>
  283. </body>
  284. </html>