hermite.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Hermite Polynomials</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="../sf_poly.html" title="Polynomials">
  9. <link rel="prev" href="laguerre.html" title="Laguerre (and Associated) Polynomials">
  10. <link rel="next" href="chebyshev.html" title="Chebyshev Polynomials">
  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="laguerre.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_poly.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="chebyshev.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.sf_poly.hermite"></a><a class="link" href="hermite.html" title="Hermite Polynomials">Hermite Polynomials</a>
  28. </h3></div></div></div>
  29. <h5>
  30. <a name="math_toolkit.sf_poly.hermite.h0"></a>
  31. <span class="phrase"><a name="math_toolkit.sf_poly.hermite.synopsis"></a></span><a class="link" href="hermite.html#math_toolkit.sf_poly.hermite.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">hermite</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">hermite</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">x</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">hermite</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">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>
  40. <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> <span class="identifier">T3</span><span class="special">&gt;</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">hermite_next</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">Hn</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">Hnm1</span><span class="special">);</span>
  42. <span class="special">}}</span> <span class="comment">// namespaces</span>
  43. </pre>
  44. <h5>
  45. <a name="math_toolkit.sf_poly.hermite.h1"></a>
  46. <span class="phrase"><a name="math_toolkit.sf_poly.hermite.description"></a></span><a class="link" href="hermite.html#math_toolkit.sf_poly.hermite.description">Description</a>
  47. </h5>
  48. <p>
  49. 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
  50. type calculation rules</em></span></a>: note than when there is a single
  51. template argument the result is the same type as that argument or <code class="computeroutput"><span class="keyword">double</span></code> if the template argument is an integer
  52. type.
  53. </p>
  54. <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>
  55. <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">hermite</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">x</span><span class="special">);</span>
  56. <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>
  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">hermite</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">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>
  58. </pre>
  59. <p>
  60. Returns the value of the Hermite Polynomial of order <span class="emphasis"><em>n</em></span>
  61. at point <span class="emphasis"><em>x</em></span>:
  62. </p>
  63. <div class="blockquote"><blockquote class="blockquote"><p>
  64. <span class="inlinemediaobject"><img src="../../../equations/hermite_0.svg"></span>
  65. </p></blockquote></div>
  66. <p>
  67. 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
  68. be used to control the behaviour of the function: how it handles errors,
  69. 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
  70. documentation for more details</a>.
  71. </p>
  72. <p>
  73. The following graph illustrates the behaviour of the first few Hermite Polynomials:
  74. </p>
  75. <div class="blockquote"><blockquote class="blockquote"><p>
  76. <span class="inlinemediaobject"><img src="../../../graphs/hermite.svg" align="middle"></span>
  77. </p></blockquote></div>
  78. <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">,</span> <span class="keyword">class</span> <span class="identifier">T3</span><span class="special">&gt;</span>
  79. <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">hermite_next</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">Hn</span><span class="special">,</span> <span class="identifier">T3</span> <span class="identifier">Hnm1</span><span class="special">);</span>
  80. </pre>
  81. <p>
  82. Implements the three term recurrence relation for the Hermite polynomials,
  83. this function can be used to create a sequence of values evaluated at the
  84. same <span class="emphasis"><em>x</em></span>, and for rising <span class="emphasis"><em>n</em></span>.
  85. </p>
  86. <div class="blockquote"><blockquote class="blockquote"><p>
  87. <span class="inlinemediaobject"><img src="../../../equations/hermite_1.svg"></span>
  88. </p></blockquote></div>
  89. <p>
  90. For example we could produce a vector of the first 10 polynomial values using:
  91. </p>
  92. <pre class="programlisting"><span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">0.5</span><span class="special">;</span> <span class="comment">// Abscissa value</span>
  93. <span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">;</span>
  94. <span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">hermite</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="identifier">x</span><span class="special">)).</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">hermite</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">x</span><span class="special">));</span>
  95. <span class="keyword">for</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">l</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">l</span> <span class="special">&lt;</span> <span class="number">10</span><span class="special">;</span> <span class="special">++</span><span class="identifier">l</span><span class="special">)</span>
  96. <span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">hermite_next</span><span class="special">(</span><span class="identifier">l</span><span class="special">,</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">v</span><span class="special">[</span><span class="identifier">l</span><span class="special">],</span> <span class="identifier">v</span><span class="special">[</span><span class="identifier">l</span><span class="special">-</span><span class="number">1</span><span class="special">]));</span>
  97. </pre>
  98. <p>
  99. Formally the arguments are:
  100. </p>
  101. <div class="variablelist">
  102. <p class="title"><b></b></p>
  103. <dl class="variablelist">
  104. <dt><span class="term">n</span></dt>
  105. <dd><p>
  106. The degree <span class="emphasis"><em>n</em></span> of the last polynomial calculated.
  107. </p></dd>
  108. <dt><span class="term">x</span></dt>
  109. <dd><p>
  110. The abscissa value
  111. </p></dd>
  112. <dt><span class="term">Hn</span></dt>
  113. <dd><p>
  114. The value of the polynomial evaluated at degree <span class="emphasis"><em>n</em></span>.
  115. </p></dd>
  116. <dt><span class="term">Hnm1</span></dt>
  117. <dd><p>
  118. The value of the polynomial evaluated at degree <span class="emphasis"><em>n-1</em></span>.
  119. </p></dd>
  120. </dl>
  121. </div>
  122. <h5>
  123. <a name="math_toolkit.sf_poly.hermite.h2"></a>
  124. <span class="phrase"><a name="math_toolkit.sf_poly.hermite.accuracy"></a></span><a class="link" href="hermite.html#math_toolkit.sf_poly.hermite.accuracy">Accuracy</a>
  125. </h5>
  126. <p>
  127. The following table shows peak errors (in units of epsilon) for various domains
  128. of input arguments. Note that only results for the widest floating point
  129. type on the system are given as narrower types have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
  130. zero error</a>.
  131. </p>
  132. <div class="table">
  133. <a name="math_toolkit.sf_poly.hermite.table_hermite"></a><p class="title"><b>Table&#160;8.37.&#160;Error rates for hermite</b></p>
  134. <div class="table-contents"><table class="table" summary="Error rates for hermite">
  135. <colgroup>
  136. <col>
  137. <col>
  138. <col>
  139. <col>
  140. <col>
  141. </colgroup>
  142. <thead><tr>
  143. <th>
  144. </th>
  145. <th>
  146. <p>
  147. GNU C++ version 7.1.0<br> linux<br> double
  148. </p>
  149. </th>
  150. <th>
  151. <p>
  152. GNU C++ version 7.1.0<br> linux<br> long double
  153. </p>
  154. </th>
  155. <th>
  156. <p>
  157. Sun compiler version 0x5150<br> Sun Solaris<br> long double
  158. </p>
  159. </th>
  160. <th>
  161. <p>
  162. Microsoft Visual C++ version 14.1<br> Win32<br> double
  163. </p>
  164. </th>
  165. </tr></thead>
  166. <tbody><tr>
  167. <td>
  168. <p>
  169. Hermite Polynomials
  170. </p>
  171. </td>
  172. <td>
  173. <p>
  174. <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span>
  175. </p>
  176. </td>
  177. <td>
  178. <p>
  179. <span class="blue">Max = 6.24&#949; (Mean = 2.07&#949;)</span>
  180. </p>
  181. </td>
  182. <td>
  183. <p>
  184. <span class="blue">Max = 6.24&#949; (Mean = 2.07&#949;)</span>
  185. </p>
  186. </td>
  187. <td>
  188. <p>
  189. <span class="blue">Max = 4.46&#949; (Mean = 1.41&#949;)</span>
  190. </p>
  191. </td>
  192. </tr></tbody>
  193. </table></div>
  194. </div>
  195. <br class="table-break"><p>
  196. Note that the worst errors occur when the degree increases, values greater
  197. than ~120 are very unlikely to produce sensible results, especially in the
  198. associated polynomial case when the order is also large. Further the relative
  199. errors are likely to grow arbitrarily large when the function is very close
  200. to a root.
  201. </p>
  202. <h5>
  203. <a name="math_toolkit.sf_poly.hermite.h3"></a>
  204. <span class="phrase"><a name="math_toolkit.sf_poly.hermite.testing"></a></span><a class="link" href="hermite.html#math_toolkit.sf_poly.hermite.testing">Testing</a>
  205. </h5>
  206. <p>
  207. A mixture of spot tests of values calculated using functions.wolfram.com,
  208. and randomly generated test data are used: the test data was computed using
  209. <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL::RR</a> at 1000-bit
  210. precision.
  211. </p>
  212. <h5>
  213. <a name="math_toolkit.sf_poly.hermite.h4"></a>
  214. <span class="phrase"><a name="math_toolkit.sf_poly.hermite.implementation"></a></span><a class="link" href="hermite.html#math_toolkit.sf_poly.hermite.implementation">Implementation</a>
  215. </h5>
  216. <p>
  217. These functions are implemented using the stable three term recurrence relations.
  218. These relations guarantee low absolute error but cannot guarantee low relative
  219. error near one of the roots of the polynomials.
  220. </p>
  221. </div>
  222. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  223. <td align="left"></td>
  224. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  225. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  226. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  227. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  228. Daryle Walker and Xiaogang Zhang<p>
  229. Distributed under the Boost Software License, Version 1.0. (See accompanying
  230. 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>)
  231. </p>
  232. </div></td>
  233. </tr></table>
  234. <hr>
  235. <div class="spirit-nav">
  236. <a accesskey="p" href="laguerre.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../sf_poly.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="chebyshev.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  237. </div>
  238. </body>
  239. </html>