ellint_carlson.qbk 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. [/
  2. Copyright (c) 2006 Xiaogang Zhang
  3. Copyright (c) 2006 John Maddock
  4. Use, modification and distribution are subject to the
  5. Boost Software License, Version 1.0. (See accompanying file
  6. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ]
  8. [section:ellint_carlson Elliptic Integrals - Carlson Form]
  9. [heading Synopsis]
  10. ``
  11. #include <boost/math/special_functions/ellint_rf.hpp>
  12. ``
  13. namespace boost { namespace math {
  14. template <class T1, class T2, class T3>
  15. ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z)
  16. template <class T1, class T2, class T3, class ``__Policy``>
  17. ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z, const ``__Policy``&)
  18. }} // namespaces
  19. ``
  20. #include <boost/math/special_functions/ellint_rd.hpp>
  21. ``
  22. namespace boost { namespace math {
  23. template <class T1, class T2, class T3>
  24. ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z)
  25. template <class T1, class T2, class T3, class ``__Policy``>
  26. ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z, const ``__Policy``&)
  27. }} // namespaces
  28. ``
  29. #include <boost/math/special_functions/ellint_rj.hpp>
  30. ``
  31. namespace boost { namespace math {
  32. template <class T1, class T2, class T3, class T4>
  33. ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p)
  34. template <class T1, class T2, class T3, class T4, class ``__Policy``>
  35. ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p, const ``__Policy``&)
  36. }} // namespaces
  37. ``
  38. #include <boost/math/special_functions/ellint_rc.hpp>
  39. ``
  40. namespace boost { namespace math {
  41. template <class T1, class T2>
  42. ``__sf_result`` ellint_rc(T1 x, T2 y)
  43. template <class T1, class T2, class ``__Policy``>
  44. ``__sf_result`` ellint_rc(T1 x, T2 y, const ``__Policy``&)
  45. }} // namespaces
  46. ``
  47. #include <boost/math/special_functions/ellint_rg.hpp>
  48. ``
  49. namespace boost { namespace math {
  50. template <class T1, class T2, class T3>
  51. ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z)
  52. template <class T1, class T2, class T3, class ``__Policy``>
  53. ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z, const ``__Policy``&)
  54. }} // namespaces
  55. [heading Description]
  56. These functions return Carlson's symmetrical elliptic integrals, the functions
  57. have complicated behavior over all their possible domains, but the following
  58. graph gives an idea of their behavior:
  59. [graph ellint_carlson]
  60. The return type of these functions is computed using the __arg_promotion_rules
  61. when the arguments are of different types: otherwise the return is the same type
  62. as the arguments.
  63. template <class T1, class T2, class T3>
  64. ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z)
  65. template <class T1, class T2, class T3, class ``__Policy``>
  66. ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z, const ``__Policy``&)
  67. Returns Carlson's Elliptic Integral ['R[sub F]]:
  68. [equation ellint9]
  69. Requires that all of the arguments are non-negative, and at most
  70. one may be zero. Otherwise returns the result of __domain_error.
  71. [optional_policy]
  72. template <class T1, class T2, class T3>
  73. ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z)
  74. template <class T1, class T2, class T3, class ``__Policy``>
  75. ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z, const ``__Policy``&)
  76. Returns Carlson's elliptic integral R[sub D]:
  77. [equation ellint10]
  78. Requires that x and y are non-negative, with at most one of them
  79. zero, and that z >= 0. Otherwise returns the result of __domain_error.
  80. [optional_policy]
  81. template <class T1, class T2, class T3, class T4>
  82. ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p)
  83. template <class T1, class T2, class T3, class T4, class ``__Policy``>
  84. ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p, const ``__Policy``&)
  85. Returns Carlson's elliptic integral R[sub J]:
  86. [equation ellint11]
  87. Requires that x, y and z are non-negative, with at most one of them
  88. zero, and that ['p != 0]. Otherwise returns the result of __domain_error.
  89. [optional_policy]
  90. When ['p < 0] the function returns the
  91. [@http://en.wikipedia.org/wiki/Cauchy_principal_value Cauchy principal value]
  92. using the relation:
  93. [equation ellint17]
  94. template <class T1, class T2>
  95. ``__sf_result`` ellint_rc(T1 x, T2 y)
  96. template <class T1, class T2, class ``__Policy``>
  97. ``__sf_result`` ellint_rc(T1 x, T2 y, const ``__Policy``&)
  98. Returns Carlson's elliptic integral R[sub C]:
  99. [equation ellint12]
  100. Requires that ['x > 0] and that ['y != 0].
  101. Otherwise returns the result of __domain_error.
  102. [optional_policy]
  103. When ['y < 0] the function returns the
  104. [@http://mathworld.wolfram.com/CauchyPrincipalValue.html Cauchy principal value]
  105. using the relation:
  106. [equation ellint18]
  107. template <class T1, class T2, class T3>
  108. ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z)
  109. template <class T1, class T2, class T3, class ``__Policy``>
  110. ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z, const ``__Policy``&)
  111. Returns Carlson's elliptic integral ['R[sub G]:]
  112. [equation ellint27]
  113. Requires that x and y are non-negative, otherwise returns the result of __domain_error.
  114. [optional_policy]
  115. [heading Testing]
  116. There are two sets of tests.
  117. Spot tests compare selected values with test data given in:
  118. [:B. C. Carlson, ['[@http://arxiv.org/abs/math.CA/9409227
  119. Numerical computation of real or complex elliptic integrals]]. Numerical Algorithms,
  120. Volume 10, Number 1 / March, 1995, pp 13-26.]
  121. Random test data generated using NTL::RR at 1000-bit precision and our
  122. implementation checks for rounding-errors and/or regressions.
  123. There are also sanity checks that use the inter-relations between the integrals
  124. to verify their correctness: see the above Carlson paper for details.
  125. [heading Accuracy]
  126. These functions are computed using only basic arithmetic operations, so
  127. there isn't much variation in accuracy over differing platforms.
  128. Note that only results for the widest floating-point type on the
  129. system are given as narrower types have __zero_error. All values
  130. are relative errors in units of epsilon.
  131. [table_ellint_rc]
  132. [table_ellint_rd]
  133. [table_ellint_rg]
  134. [table_ellint_rf]
  135. [table_ellint_rj]
  136. [heading Implementation]
  137. The key of Carlson's algorithm [[link ellint_ref_carlson79 Carlson79]] is the
  138. duplication theorem:
  139. [equation ellint13]
  140. By applying it repeatedly, ['x], ['y], ['z] get
  141. closer and closer. When they are nearly equal, the special case equation
  142. [equation ellint16]
  143. is used. More specifically, ['[R F]] is evaluated from a Taylor series
  144. expansion to the fifth order. The calculations of the other three integrals
  145. are analogous, except for R[sub C] which can be computed from elementary functions.
  146. For ['p < 0] in ['R[sub J](x, y, z, p)] and ['y < 0] in ['R[sub C](x, y)],
  147. the integrals are singular and their
  148. [@http://mathworld.wolfram.com/CauchyPrincipalValue.html Cauchy principal values]
  149. are returned via the relations:
  150. [equation ellint17]
  151. [equation ellint18]
  152. [endsect] [/section:ellint_carlson Elliptic Integrals - Carlson Form]