airy.qbk 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. [/
  2. Copyright (c) 2012 John Maddock
  3. Use, modification and distribution are subject to the
  4. Boost Software License, Version 1.0. (See accompanying file
  5. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ]
  7. [section:airy Airy Functions]
  8. [section:ai Airy Ai Function]
  9. [heading Synopsis]
  10. ``
  11. #include <boost/math/special_functions/airy.hpp>
  12. ``
  13. namespace boost { namespace math {
  14. template <class T>
  15. ``__sf_result`` airy_ai(T x);
  16. template <class T, class Policy>
  17. ``__sf_result`` airy_ai(T x, const Policy&);
  18. }} // namespaces
  19. [heading Description]
  20. The function __airy_ai calculates the Airy function Ai which is the first solution
  21. to the differential equation:
  22. [equation airy]
  23. See Weisstein, Eric W. "Airy Functions." From MathWorld--A Wolfram Web Resource.
  24. [@http://mathworld.wolfram.com/AiryFunctions.html]
  25. and [@https://en.wikipedia.org/wiki/Airy_zeta_function Airy Zeta function].
  26. [optional_policy]
  27. The following graph illustrates how this function changes as /x/ changes: for negative /x/
  28. the function is cyclic, while for positive /x/ the value tends to zero:
  29. [graph airy_ai]
  30. [heading Accuracy]
  31. This function is implemented entirely in terms of the Bessel functions
  32. __cyl_bessel_j and __cyl_bessel_k - refer to those functions for detailed accuracy information.
  33. In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
  34. only the absolute error is low for /x < 0/ as the following error plot illustrates:
  35. [graph ai__double]
  36. [heading Testing]
  37. Since this function is implemented in terms of other special functions, there are only a few
  38. basic sanity checks, using test values from [@http://functions.wolfram.com/ Wolfram Airy Functions].
  39. [heading Implementation]
  40. This function is implemented in terms of the Bessel functions using the relations:
  41. [equation airy_ai]
  42. [endsect] [/section:ai Airy Ai Function]
  43. [section:bi Airy Bi Function]
  44. [heading Synopsis]
  45. ``
  46. #include <boost/math/special_functions/airy.hpp>
  47. ``
  48. namespace boost { namespace math {
  49. template <class T>
  50. ``__sf_result`` airy_bi(T x);
  51. template <class T, class Policy>
  52. ``__sf_result`` airy_bi(T x, const Policy&);
  53. }} // namespaces
  54. [heading Description]
  55. The function __airy_bi calculates the Airy function Bi which is the second solution to the differential equation:
  56. [equation airy]
  57. [optional_policy]
  58. The following graph illustrates how this function changes as /x/ changes: for negative /x/
  59. the function is cyclic, while for positive /x/ the value tends to infinity:
  60. [graph airy_bi]
  61. [heading Accuracy]
  62. This function is implemented entirely in terms of the Bessel functions
  63. __cyl_bessel_i and __cyl_bessel_j - refer to those functions for detailed accuracy information.
  64. In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
  65. only the absolute error is low for /x < 0/ as the following error plot illustrate:
  66. [graph bi__double]
  67. [heading Testing]
  68. Since this function is implemented in terms of other special functions, there are only a few
  69. basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
  70. [heading Implementation]
  71. This function is implemented in terms of the Bessel functions using the relations:
  72. [equation airy_bi]
  73. [endsect] [/section:bi Airy Bi Function]
  74. [section:aip Airy Ai' Function]
  75. [heading Synopsis]
  76. ``
  77. #include <boost/math/special_functions/airy.hpp>
  78. ``
  79. namespace boost { namespace math {
  80. template <class T>
  81. ``__sf_result`` airy_ai_prime(T x);
  82. template <class T, class Policy>
  83. ``__sf_result`` airy_ai_prime(T x, const Policy&);
  84. }} // namespaces
  85. [heading Description]
  86. The function __airy_ai_prime calculates the Airy function Ai' which is the derivative of the first solution to the differential equation:
  87. [equation airy]
  88. [optional_policy]
  89. The following graph illustrates how this function changes as /x/ changes: for negative /x/
  90. the function is cyclic, while for positive /x/ the value tends to zero:
  91. [graph airy_aip]
  92. [heading Accuracy]
  93. This function is implemented entirely in terms of the Bessel functions
  94. __cyl_bessel_j and __cyl_bessel_k - refer to those functions for detailed accuracy information.
  95. In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
  96. only the absolute error is low for /x < 0/ as the following error plot illustrates:
  97. [graph ai_prime__double]
  98. [heading Testing]
  99. Since this function is implemented in terms of other special functions, there are only a few
  100. basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
  101. [heading Implementation]
  102. This function is implemented in terms of the Bessel functions using the relations:
  103. [equation airy_aip]
  104. [endsect] [/section:aip Airy Ai' Function]
  105. [section:bip Airy Bi' Function]
  106. [heading Synopsis]
  107. ``
  108. #include <boost/math/special_functions/airy.hpp>
  109. ``
  110. namespace boost { namespace math {
  111. template <class T>
  112. ``__sf_result`` airy_bi_prime(T x);
  113. template <class T, class Policy>
  114. ``__sf_result`` airy_bi_prime(T x, const Policy&);
  115. }} // namespaces
  116. [heading Description]
  117. The function __airy_bi_prime calculates the Airy function Bi' which is the derivative of the second solution to the differential equation:
  118. [equation airy]
  119. [optional_policy]
  120. The following graph illustrates how this function changes as /x/ changes: for negative /x/
  121. the function is cyclic, while for positive /x/ the value tends to infinity:
  122. [graph airy_bi]
  123. [heading Accuracy]
  124. This function is implemented entirely in terms of the Bessel functions
  125. __cyl_bessel_i and __cyl_bessel_j - refer to those functions for detailed accuracy information.
  126. In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
  127. only the absolute error is low for /x < 0/ as the following error plot illustrates:
  128. [graph bi_prime__double]
  129. [heading Testing]
  130. Since this function is implemented in terms of other special functions, there are only a few
  131. basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
  132. [heading Implementation]
  133. This function is implemented in terms of the Bessel functions using the relations:
  134. [equation airy_bip]
  135. [endsect] [/section:bip Airy Bi' Function]
  136. [section:airy_root Finding Zeros of Airy Functions]
  137. [h4 Synopsis]
  138. `#include <boost/math/special_functions/airy.hpp>`
  139. Functions for obtaining both a single zero or root of the Airy functions,
  140. and placing multiple zeros into a container like `std::vector`
  141. by providing an output iterator.
  142. The signature of the single value functions are:
  143. template <class T>
  144. T airy_ai_zero(
  145. int m); // 1-based index of zero.
  146. template <class T>
  147. T airy_bi_zero(
  148. int m); // 1-based index of zero.
  149. and for multiple zeros:
  150. template <class T, class OutputIterator>
  151. OutputIterator airy_ai_zero(
  152. int start_index, // 1-based index of first zero.
  153. unsigned number_of_zeros, // How many zeros to generate.
  154. OutputIterator out_it); // Destination for zeros.
  155. template <class T, class OutputIterator>
  156. OutputIterator airy_bi_zero(
  157. int start_index, // 1-based index of zero.
  158. unsigned number_of_zeros, // How many zeros to generate
  159. OutputIterator out_it); // Destination for zeros.
  160. There are also versions which allow control of the __policy_section for error handling and precision.
  161. template <class T>
  162. T airy_ai_zero(
  163. int m, // 1-based index of zero.
  164. const Policy&); // Policy to use.
  165. template <class T>
  166. T airy_bi_zero(
  167. int m, // 1-based index of zero.
  168. const Policy&); // Policy to use.
  169. template <class T, class OutputIterator>
  170. OutputIterator airy_ai_zero(
  171. int start_index, // 1-based index of first zero.
  172. unsigned number_of_zeros, // How many zeros to generate.
  173. OutputIterator out_it, // Destination for zeros.
  174. const Policy& pol); // Policy to use.
  175. template <class T, class OutputIterator>
  176. OutputIterator airy_bi_zero(
  177. int start_index, // 1-based index of zero.
  178. unsigned number_of_zeros, // How many zeros to generate.
  179. OutputIterator out_it, // Destination for zeros.
  180. const Policy& pol); // Policy to use.
  181. [h4 Description]
  182. The Airy Ai and Bi functions have an infinite
  183. number of zeros on the negative real axis. The real zeros on the negative real
  184. axis can be found by solving for the roots of
  185. [:['Ai(x[sub m]) = 0]]
  186. [:['Bi(y[sub m]) = 0]]
  187. Here, ['x[sub m]] represents the ['m[super th]]
  188. root of the Airy Ai function,
  189. and ['y[sub m]] represents the ['m[super th]]
  190. root of the Airy Bi function.
  191. The zeros or roots (values of `x` where the function crosses the horizontal `y = 0` axis)
  192. of the Airy Ai and Bi functions are computed by two functions,
  193. `airy_ai_zero` and `airy_bi_zero`.
  194. In each case the index or rank of the zero
  195. returned is 1-based, which is to say:
  196. airy_ai_zero(1);
  197. returns the first zero of Ai.
  198. Passing an `start_index <= 0` results in a __domain_error being raised.
  199. The first few zeros returned by these functions have approximate values as follows:
  200. [table
  201. [[m][Ai][Bi]]
  202. [[1][-2.33811...][-1.17371...]]
  203. [[2][-4.08795...][-3.27109...]]
  204. [[3][-5.52056...][-4.83074...]]
  205. [[4][-6.78671...][-6.16985...]]
  206. [[5][-7.94413...][-7.37676...]]
  207. [[6][-9.02265...][-8.49195...]]
  208. ]
  209. [graph airy_zeros]
  210. [h4 Examples of finding Airy Zeros]
  211. [import ../../example/airy_zeros_example.cpp]
  212. [airy_zeros_example_1]
  213. [airy_zeros_example_2]
  214. Produces the program output:
  215. [pre
  216. boost::math::airy_ai_zero<double>(1) = -2.33811
  217. boost::math::airy_ai_zero<double>(2) = -4.08795
  218. boost::math::airy_bi_zero<double>(3) = -4.83074
  219. airy_ai_zeros:
  220. -2.33811
  221. -4.08795
  222. -5.52056
  223. -6.78671
  224. -7.94413
  225. boost::math::airy_bi_zero<float_type>(1) = -2.3381074104597670384891972524467354406385401456711
  226. boost::math::airy_bi_zero<float_type>(2) = -4.0879494441309706166369887014573910602247646991085
  227. boost::math::airy_bi_zero<float_type>(7) = -9.5381943793462388866329885451560196208390720763825
  228. airy_ai_zeros:
  229. -2.3381074104597670384891972524467354406385401456711
  230. -4.0879494441309706166369887014573910602247646991085
  231. -5.5205598280955510591298555129312935737972142806175
  232. ]
  233. The full code (and output) for this example is at
  234. [@../../example/airy_zeros_example.cpp airy_zeros_example.cpp],
  235. [h3 Implementation]
  236. Given the following function (A&S 10.4.105):
  237. [equation airy_zero_1]
  238. Then an initial estimate for the n[super th] zero a[sub n] of Ai is given by (A&S 10.4.94):
  239. [equation airy_zero_2]
  240. and an initial estimate for the n[super th] zero b[sub n] of Bi is given by (A&S 10.4.98):
  241. [equation airy_zero_3]
  242. Thereafter the roots are refined using Newton iteration.
  243. [h3 Testing]
  244. The precision of evaluation of zeros was tested at 50 decimal digits using `cpp_dec_float_50`
  245. and found identical with spot values computed by __WolframAlpha.
  246. [endsect] [/section:airy_root Finding Zeros of Airy Functions]
  247. [endsect] [/section:airy Airy Functions]