]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/doc/html/math_toolkit/zetas/zeta.html
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / doc / html / math_toolkit / zetas / zeta.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Riemann Zeta Function</title>
5 <link rel="stylesheet" href="../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
7 <link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
8 <link rel="up" href="../zetas.html" title="Zeta Functions">
9 <link rel="prev" href="../zetas.html" title="Zeta Functions">
10 <link rel="next" href="../expint.html" title="Exponential Integrals">
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="../zetas.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../zetas.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.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.zetas.zeta"></a><a class="link" href="zeta.html" title="Riemann Zeta Function">Riemann Zeta Function</a>
28 </h3></div></div></div>
29 <h5>
30 <a name="math_toolkit.zetas.zeta.h0"></a>
31 <span class="phrase"><a name="math_toolkit.zetas.zeta.synopsis"></a></span><a class="link" href="zeta.html#math_toolkit.zetas.zeta.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">zeta</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
37 <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>
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">zeta</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span>
39
40 <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;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><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">zeta</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;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
42
43 <span class="special">}}</span> <span class="comment">// namespaces</span>
44 </pre>
45 <p>
46 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
47 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.
48 </p>
49 <p>
50 The final <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
51 be used to control the behaviour of the function: how it handles errors,
52 what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;15.&#160;Policies: Controlling Precision, Error Handling etc">policy
53 documentation for more details</a>.
54 </p>
55 <h5>
56 <a name="math_toolkit.zetas.zeta.h1"></a>
57 <span class="phrase"><a name="math_toolkit.zetas.zeta.description"></a></span><a class="link" href="zeta.html#math_toolkit.zetas.zeta.description">Description</a>
58 </h5>
59 <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>
60 <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">zeta</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">z</span><span class="special">);</span>
61
62 <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;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
63 <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">zeta</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;15.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>
64 </pre>
65 <p>
66 Returns the <a href="http://mathworld.wolfram.com/RiemannZetaFunction.html" target="_top">zeta
67 function</a> of z:
68 </p>
69 <p>
70 <span class="inlinemediaobject"><img src="../../../equations/zeta1.svg"></span>
71 </p>
72 <p>
73 <span class="inlinemediaobject"><img src="../../../graphs/zeta1.svg" align="middle"></span>
74 </p>
75 <p>
76 <span class="inlinemediaobject"><img src="../../../graphs/zeta2.svg" align="middle"></span>
77 </p>
78 <h5>
79 <a name="math_toolkit.zetas.zeta.h2"></a>
80 <span class="phrase"><a name="math_toolkit.zetas.zeta.accuracy"></a></span><a class="link" href="zeta.html#math_toolkit.zetas.zeta.accuracy">Accuracy</a>
81 </h5>
82 <p>
83 The following table shows the peak errors (in units of epsilon) found on
84 various platforms with various floating point types, along with comparisons
85 to the <a href="http://www.gnu.org/software/gsl/" target="_top">GSL-1.9</a> and
86 <a href="http://www.netlib.org/cephes/" target="_top">Cephes</a> libraries. Unless
87 otherwise specified any floating point type that is narrower than the one
88 shown will have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively
89 zero error</a>.
90 </p>
91 <div class="table">
92 <a name="math_toolkit.zetas.zeta.table_zeta"></a><p class="title"><b>Table&#160;6.73.&#160;Error rates for zeta</b></p>
93 <div class="table-contents"><table class="table" summary="Error rates for zeta">
94 <colgroup>
95 <col>
96 <col>
97 <col>
98 <col>
99 <col>
100 </colgroup>
101 <thead><tr>
102 <th>
103 </th>
104 <th>
105 <p>
106 Microsoft Visual C++ version 12.0<br> Win32<br> double
107 </p>
108 </th>
109 <th>
110 <p>
111 GNU C++ version 5.1.0<br> linux<br> double
112 </p>
113 </th>
114 <th>
115 <p>
116 GNU C++ version 5.1.0<br> linux<br> long double
117 </p>
118 </th>
119 <th>
120 <p>
121 Sun compiler version 0x5130<br> Sun Solaris<br> long double
122 </p>
123 </th>
124 </tr></thead>
125 <tbody>
126 <tr>
127 <td>
128 <p>
129 Zeta: Random values greater than 1
130 </p>
131 </td>
132 <td>
133 <p>
134 <span class="blue">Max = 0.836&#949; (Mean = 0.093&#949;)</span>
135 </p>
136 </td>
137 <td>
138 <p>
139 <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
140 1.16:</em></span> Max = 8.69&#949; (Mean = 1.03&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
141 <span class="red">Max = 4.49e+33&#949; (Mean = 6.85e+32&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_zeta_Cephes_Zeta_Random_values_greater_than_1">And
142 other failures.</a>)</span>
143 </p>
144 </td>
145 <td>
146 <p>
147 <span class="blue">Max = 0.846&#949; (Mean = 0.0833&#949;)</span><br>
148 <br> (<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 5.45&#949; (Mean
149 = 1&#949;))
150 </p>
151 </td>
152 <td>
153 <p>
154 <span class="blue">Max = 0.846&#949; (Mean = 0.0743&#949;)</span>
155 </p>
156 </td>
157 </tr>
158 <tr>
159 <td>
160 <p>
161 Zeta: Random values less than 1
162 </p>
163 </td>
164 <td>
165 <p>
166 <span class="blue">Max = 7.03&#949; (Mean = 2.98&#949;)</span>
167 </p>
168 </td>
169 <td>
170 <p>
171 <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
172 1.16:</em></span> Max = 137&#949; (Mean = 13.8&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
173 <span class="red">Max = +INF&#949; (Mean = +INF&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_zeta_Cephes_Zeta_Random_values_less_than_1">And
174 other failures.</a>)</span>
175 </p>
176 </td>
177 <td>
178 <p>
179 <span class="blue">Max = 7.03&#949; (Mean = 2.71&#949;)</span><br> <br>
180 (<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 538&#949; (Mean = 59.3&#949;))
181 </p>
182 </td>
183 <td>
184 <p>
185 <span class="blue">Max = 70.1&#949; (Mean = 17.1&#949;)</span>
186 </p>
187 </td>
188 </tr>
189 <tr>
190 <td>
191 <p>
192 Zeta: Values close to and greater than 1
193 </p>
194 </td>
195 <td>
196 <p>
197 <span class="blue">Max = 0.994&#949; (Mean = 0.421&#949;)</span>
198 </p>
199 </td>
200 <td>
201 <p>
202 <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
203 1.16:</em></span> Max = 7.73&#949; (Mean = 4.07&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
204 <span class="red">Max = 6.77e+15&#949; (Mean = 1.52e+15&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_zeta_Cephes_Zeta_Values_close_to_and_greater_than_1">And
205 other failures.</a>)</span>
206 </p>
207 </td>
208 <td>
209 <p>
210 <span class="blue">Max = 0.995&#949; (Mean = 0.5&#949;)</span><br> <br>
211 (<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 1.9e+06&#949; (Mean = 5.11e+05&#949;))
212 </p>
213 </td>
214 <td>
215 <p>
216 <span class="blue">Max = 0.995&#949; (Mean = 0.5&#949;)</span>
217 </p>
218 </td>
219 </tr>
220 <tr>
221 <td>
222 <p>
223 Zeta: Values close to and less than 1
224 </p>
225 </td>
226 <td>
227 <p>
228 <span class="blue">Max = 0.991&#949; (Mean = 0.375&#949;)</span>
229 </p>
230 </td>
231 <td>
232 <p>
233 <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
234 1.16:</em></span> Max = 0.991&#949; (Mean = 0.28&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
235 <span class="red">Max = 8.66e+15&#949; (Mean = 1.9e+15&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_zeta_Cephes_Zeta_Values_close_to_and_less_than_1">And
236 other failures.</a>)</span>
237 </p>
238 </td>
239 <td>
240 <p>
241 <span class="blue">Max = 0.998&#949; (Mean = 0.508&#949;)</span><br> <br>
242 (<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 8.53e+06&#949; (Mean =
243 1.87e+06&#949;))
244 </p>
245 </td>
246 <td>
247 <p>
248 <span class="blue">Max = 0.998&#949; (Mean = 0.568&#949;)</span>
249 </p>
250 </td>
251 </tr>
252 <tr>
253 <td>
254 <p>
255 Zeta: Integer arguments
256 </p>
257 </td>
258 <td>
259 <p>
260 <span class="blue">Max = 6.5&#949; (Mean = 2.17&#949;)</span>
261 </p>
262 </td>
263 <td>
264 <p>
265 <span class="blue">Max = 0&#949; (Mean = 0&#949;)</span><br> <br> (<span class="emphasis"><em>GSL
266 1.16:</em></span> Max = 3.75&#949; (Mean = 1.1&#949;))<br> (<span class="emphasis"><em>Cephes:</em></span>
267 <span class="red">Max = +INF&#949; (Mean = +INF&#949;) <a class="link" href="../logs_and_tables/logs.html#errors_GNU_C_version_5_1_0_linux_double_zeta_Cephes_Zeta_Integer_arguments">And
268 other failures.</a>)</span>
269 </p>
270 </td>
271 <td>
272 <p>
273 <span class="blue">Max = 9&#949; (Mean = 3.06&#949;)</span><br> <br>
274 (<span class="emphasis"><em>&lt;tr1/cmath&gt;:</em></span> Max = 70.3&#949; (Mean = 17.4&#949;))
275 </p>
276 </td>
277 <td>
278 <p>
279 <span class="blue">Max = 21&#949; (Mean = 7.13&#949;)</span>
280 </p>
281 </td>
282 </tr>
283 </tbody>
284 </table></div>
285 </div>
286 <br class="table-break"><h5>
287 <a name="math_toolkit.zetas.zeta.h3"></a>
288 <span class="phrase"><a name="math_toolkit.zetas.zeta.testing"></a></span><a class="link" href="zeta.html#math_toolkit.zetas.zeta.testing">Testing</a>
289 </h5>
290 <p>
291 The tests for these functions come in two parts: basic sanity checks use
292 spot values calculated using <a href="http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=Zeta" target="_top">Mathworld's
293 online evaluator</a>, while accuracy checks use high-precision test values
294 calculated at 1000-bit precision with <a href="http://shoup.net/ntl/doc/RR.txt" target="_top">NTL::RR</a>
295 and this implementation. Note that the generic and type-specific versions
296 of these functions use differing implementations internally, so this gives
297 us reasonably independent test data. Using our test data to test other "known
298 good" implementations also provides an additional sanity check.
299 </p>
300 <h5>
301 <a name="math_toolkit.zetas.zeta.h4"></a>
302 <span class="phrase"><a name="math_toolkit.zetas.zeta.implementation"></a></span><a class="link" href="zeta.html#math_toolkit.zetas.zeta.implementation">Implementation</a>
303 </h5>
304 <p>
305 All versions of these functions first use the usual reflection formulas to
306 make their arguments positive:
307 </p>
308 <p>
309 <span class="inlinemediaobject"><img src="../../../equations/zeta3.svg"></span>
310 </p>
311 <p>
312 The generic versions of these functions are implemented using the series:
313 </p>
314 <p>
315 <span class="inlinemediaobject"><img src="../../../equations/zeta6.svg"></span>
316 </p>
317 <p>
318 When the significand (mantissa) size is recognised (currently for 53, 64
319 and 113-bit reals, plus single-precision 24-bit handled via promotion to
320 double) then a series of rational approximations <a class="link" href="../sf_implementation.html#math_toolkit.sf_implementation.rational_approximations_used">devised
321 by JM</a> are used.
322 </p>
323 <p>
324 For 0 &lt; z &lt; 1 the approximating form is:
325 </p>
326 <p>
327 <span class="inlinemediaobject"><img src="../../../equations/zeta4.svg"></span>
328 </p>
329 <p>
330 For a rational approximation R(1-z) and a constant C.
331 </p>
332 <p>
333 For 1 &lt; z &lt; 4 the approximating form is:
334 </p>
335 <p>
336 <span class="inlinemediaobject"><img src="../../../equations/zeta5.svg"></span>
337 </p>
338 <p>
339 For a rational approximation R(n-z) and a constant C and integer n.
340 </p>
341 <p>
342 For z &gt; 4 the approximating form is:
343 </p>
344 <p>
345 &#950;(z) = 1 + e<sup>R(z - n)</sup>
346 </p>
347 <p>
348 For a rational approximation R(z-n) and integer n, note that the accuracy
349 required for R(z-n) is not full machine precision, but an absolute error
350 of: &#949;/R(0). This saves us quite a few digits when dealing with large z, especially
351 when &#949; is small.
352 </p>
353 <p>
354 Finally, there are some special cases for integer arguments, there are closed
355 forms for negative or even integers:
356 </p>
357 <p>
358 <span class="inlinemediaobject"><img src="../../../equations/zeta7.svg"></span>
359 </p>
360 <p>
361 <span class="inlinemediaobject"><img src="../../../equations/zeta8.svg"></span>
362 </p>
363 <p>
364 <span class="inlinemediaobject"><img src="../../../equations/zeta9.svg"></span>
365 </p>
366 <p>
367 and for positive odd integers we simply cache pre-computed values as these
368 are of great benefit to some infinite series calculations.
369 </p>
370 </div>
371 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
372 <td align="left"></td>
373 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
374 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
375 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R&#229;de, Gautam Sewani,
376 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
377 Distributed under the Boost Software License, Version 1.0. (See accompanying
378 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>)
379 </p>
380 </div></td>
381 </tr></table>
382 <hr>
383 <div class="spirit-nav">
384 <a accesskey="p" href="../zetas.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../zetas.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.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
385 </div>
386 </body>
387 </html>