zeta.qbk 3.6 KB

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