Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / sf / zeta.qbk
1 [section:zeta Riemann Zeta Function]
2
3 [h4 Synopsis]
4
5 ``
6 #include <boost/math/special_functions/zeta.hpp>
7 ``
8
9    namespace boost{ namespace math{
10    
11    template <class T>
12    ``__sf_result`` zeta(T z);
13    
14    template <class T, class ``__Policy``>
15    ``__sf_result`` zeta(T z, const ``__Policy``&);
16    
17    }} // namespaces
18    
19 The return type of these functions is computed using the __arg_promotion_rules:
20 the return type is `double` if T is an integer type, and T otherwise.
21
22 [optional_policy]
23
24 [h4 Description]
25
26    template <class T>
27    ``__sf_result`` zeta(T z);
28    
29    template <class T, class ``__Policy``>
30    ``__sf_result`` zeta(T z, const ``__Policy``&);
31    
32 Returns the [@http://mathworld.wolfram.com/RiemannZetaFunction.html zeta function]
33 of z:
34
35 [equation zeta1]
36
37 [graph zeta1]
38
39 [graph zeta2]
40
41 [h4 Accuracy]
42
43 The following table shows the peak errors (in units of epsilon) 
44 found on various platforms with various floating point types, 
45 along with comparisons to the __gsl and __cephes libraries.
46 Unless otherwise specified any floating point type that is narrower
47 than the one shown will have __zero_error.
48
49 [table_zeta]
50
51 The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at `double` precision, 
52 and GCC-7.1/Ubuntu for `long double` and `__float128`.
53
54 [graph zeta__double]
55
56 [graph zeta__80_bit_long_double]
57
58 [graph zeta____float128]
59
60 [h4 Testing]
61
62 The tests for these functions come in two parts:
63 basic sanity checks use spot values calculated using
64 [@http://functions.wolfram.com/webMathematica/FunctionEvaluation.jsp?name=Zeta Mathworld's online evaluator],
65 while accuracy checks use high-precision test values calculated at 1000-bit precision with
66 [@http://shoup.net/ntl/doc/RR.txt NTL::RR] and this implementation. 
67 Note that the generic and type-specific
68 versions of these functions use differing implementations internally, so this
69 gives us reasonably independent test data.  Using our test data to test other
70 "known good" implementations also provides an additional sanity check. 
71
72 [h4 Implementation]
73
74 All versions of these functions first use the usual reflection formulas
75 to make their arguments positive:
76
77 [equation zeta3]
78
79 The generic versions of these functions are implemented using the series:
80
81 [equation zeta6]
82
83 When the significand (mantissa) size is recognised
84 (currently for 53, 64 and 113-bit reals, plus single-precision 24-bit handled via promotion to double)
85 then a series of rational approximations [jm_rationals] are used.
86
87 For 0 < z < 1 the approximating form is:
88
89 [equation zeta4]
90
91 For a rational approximation /R(1-z)/ and a constant /C/:
92
93 For 1 < z < 4 the approximating form is:
94
95 [equation zeta5]
96
97 For a rational approximation /R(n-z)/ and a constant /C/ and integer /n/:
98
99 For z > 4 the approximating form is:
100
101 [expression [zeta](z) = 1 + e[super R(z - n)]]
102
103 For a rational approximation /R(z-n)/ and integer /n/, note that the accuracy 
104 required for /R(z-n)/ is not full machine-precision, but an absolute error
105 of: /[epsilon]/R(0)/.  This saves us quite a few digits when dealing with large 
106 /z/, especially when [epsilon] is small.
107
108 Finally, there are some special cases for integer arguments, there are
109 closed forms for negative or even integers:
110
111 [equation zeta7]
112
113 [equation zeta8]
114
115 [equation zeta9]
116
117 and for positive odd integers we simply cache pre-computed values as these are of great
118 benefit to some infinite series calculations.
119
120 [endsect] [/section:zeta Riemann Zeta Function]
121
122 [/ :error_function The Error Functions]
123
124 [/ 
125   Copyright 2006 John Maddock and Paul A. Bristow.
126   Distributed under the Boost Software License, Version 1.0.
127   (See accompanying file LICENSE_1_0.txt or copy at
128   http://www.boost.org/LICENSE_1_0.txt).
129 ]