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