jacobi_elliptic.qbk 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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:jacobi Jacobi Elliptic Functions]
  8. [section:jac_over Overview of the Jacobi Elliptic Functions]
  9. There are twelve Jacobi Elliptic functions, of which the three copolar functions ['sn], ['cn] and ['dn] are the most important
  10. as the other nine can be computed from these three
  11. [footnote [@http://en.wikipedia.org/wiki/Jacobi_elliptic_functions Wikipedia: Jacobi elliptic functions]]
  12. [footnote [@http://mathworld.wolfram.com/JacobiEllipticFunctions.html Weisstein, Eric W. "Jacobi Elliptic Functions." From MathWorld - A Wolfram Web Resource.]]
  13. [footnote [@http://dlmf.nist.gov/22 Digital Library of Mathematical Functions: Jacobian Elliptic Functions, Reinhardt, W. P., Walker, O. L.]].
  14. These functions each take two arguments: a parameter, and a variable as described below.
  15. Like all elliptic functions these can be parameterised in a number of ways:
  16. * In terms of a parameter ['m].
  17. * In terms of the elliptic modulus ['k] where ['m = k[super 2]].
  18. * In terms of the modular angle [alpha], where ['m = sin[super 2][thin][alpha]].
  19. In our implementation, these functions all take the elliptic modulus /k/ as the parameter.
  20. In addition the variable /u/ is sometimes expressed as an amplitude [phi], in our implementation we always use /u/.
  21. Finally note that our functions all take the elliptic modulus /k/ as the *first* argument - this is for alignment with
  22. the Elliptic Integrals (but is different from other implementations, for example Mathworks).
  23. A simple example comparing use of __WolframAlpha with Boost.Math (including much higher precision using Boost.Multiprecision)
  24. is [@../../example/jacobi_zeta_example.cpp jacobi_zeta_example.cpp].
  25. There are twelve functions for computing the twelve individual Jacobi elliptic functions: __jacobi_cd, __jacobi_cn, __jacobi_cs,
  26. __jacobi_dc, __jacobi_dn, __jacobi_ds, __jacobi_nc, __jacobi_nd, __jacobi_ns, __jacobi_sc, __jacobi_sd and __jacobi_sn.
  27. They are all called as for example:
  28. jacobi_cs(k, u);
  29. Note however that these individual functions are all really thin wrappers around the function __jacobi_elliptic which calculates
  30. the three copolar functions ['sn], ['cn] and ['dn] in a single function call.
  31. [tip If you need more than one of these functions
  32. for a given set of arguments, it's most efficient to use __jacobi_elliptic.]
  33. [endsect] [/section:jac_over Overvew of the Jacobi Elliptic Functions]
  34. [section:jacobi_elliptic Jacobi Elliptic SN, CN and DN]
  35. [heading Synopsis]
  36. ``
  37. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  38. ``
  39. namespace boost { namespace math {
  40. template <class T, class U, class V>
  41. ``__sf_result`` jacobi_elliptic(T k, U u, V* pcn, V* pdn);
  42. template <class T, class U, class V, class Policy>
  43. ``__sf_result`` jacobi_elliptic(T k, U u, V* pcn, V* pdn, const Policy&);
  44. }} // namespaces
  45. [heading Description]
  46. The function __jacobi_elliptic calculates the three copolar Jacobi elliptic functions
  47. ['sn(u, k)], ['cn(u, k)] and ['dn(u, k)]. The returned value is
  48. ['sn(u, k)], and if provided, `*pcn` is
  49. set to ['cn(u, k)], and `*pdn` is set to ['dn(u, k)].
  50. The functions are defined as follows, given:
  51. [equation jacobi1]
  52. The the angle ['[phi]] is called the ['amplitude] and:
  53. [equation jacobi2]
  54. [note
  55. ['[phi]] is called the amplitude.
  56. ['k] is called the elliptic modulus.
  57. ]
  58. [caution Rather like other elliptic functions, the Jacobi functions
  59. are expressed in a variety of different ways. In particular,
  60. the parameter /k/ (the modulus) may also be expressed using a modular
  61. angle [alpha], or a parameter /m/. These are related by:
  62. [expression k = sin [alpha]]
  63. [expression m = k[super 2] = sin[super 2][alpha]]
  64. So that the function ['sn] (for example) may be expressed as
  65. either:
  66. [expression sn(u, k)]
  67. [expression sn(u \\ [alpha])]
  68. [expression sn(u | m)]
  69. To further complicate matters, some texts refer to the ['complement
  70. of the parameter m], or 1 - m, where:
  71. [expression 1 - m = 1 - k[super 2] = cos[super 2][alpha]]
  72. This implementation uses /k/ throughout, and makes this the first argument
  73. to the functions: this is for alignment with the elliptic integrals which match the requirements
  74. of the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
  75. Technical Report on C++ Library Extensions]. However, you should
  76. be extra careful when using these functions!]
  77. [optional_policy]
  78. The following graphs illustrate how these functions change as /k/ changes: for small /k/
  79. these are sine waves, while as /k/ tends to 1 they become hyperbolic functions:
  80. [graph jacobi_sn]
  81. [graph jacobi_cn]
  82. [graph jacobi_dn]
  83. [heading Accuracy]
  84. These functions are computed using only basic arithmetic operations and trigomometric functions, so
  85. there isn't much variation in accuracy over differing platforms.
  86. Typically errors are trivially small for small angles, and as is typical for cyclic
  87. functions, grow as the angle increases.
  88. Note that only results for the widest floating-point type on the
  89. system are given as narrower types have __zero_error. All values
  90. are relative errors in units of epsilon.
  91. [table_jacobi_cn]
  92. [table_jacobi_dn]
  93. [table_jacobi_sn]
  94. [heading Testing]
  95. The tests use a mixture of spot test values calculated using the online
  96. calculator at [@http://functions.wolfram.com/ functions.wolfram.com],
  97. and random test data generated using
  98. MPFR at 1000-bit precision and this implementation.
  99. [heading Implementation]
  100. For ['k > 1] we apply the relations:
  101. [equation jacobi3]
  102. Then filter off the special cases:
  103. [expression ['sn(0, k) = 0] and ['cn(0, k) = dn(0, k) = 1]]
  104. [expression ['sn(u, 0) = sin(u), cn(u, 0) = cos(u) and dn(u, 0) = 1]]
  105. [expression ['sn(u, 1) = tanh(u), cn(u, 1) = dn(u, 1) = 1 / cosh(u)]]
  106. And for ['k[super 4] < [epsilon]] we have:
  107. [equation jacobi4]
  108. Otherwise the values are calculated using the method of [@http://dlmf.nist.gov/22.20#SS2 arithmetic geometric means].
  109. [endsect] [/section:jacobi_elliptic Jacobi Elliptic SN, CN and DN]
  110. [section:jacobi_cd Jacobi Elliptic Function cd]
  111. [heading Synopsis]
  112. ``
  113. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  114. ``
  115. namespace boost { namespace math {
  116. template <class T, class U>
  117. ``__sf_result`` jacobi_cd(T k, U u);
  118. template <class T, class U, class Policy>
  119. ``__sf_result`` jacobi_cd(T k, U u, const Policy& pol);
  120. }} // namespaces
  121. [heading Description]
  122. This function returns the Jacobi elliptic function ['cd].
  123. [optional_policy]
  124. This function is a trivial wrapper around __jacobi_elliptic, with:
  125. [expression ['cd(u, k) = cn(u, k) / dn(u, k)]]
  126. [graph jacobi_cd]
  127. [endsect] [/section:jacobi_cd Jacobi Elliptic Function cd]
  128. [section:jacobi_cn Jacobi Elliptic Function cn]
  129. [heading Synopsis]
  130. ``
  131. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  132. ``
  133. namespace boost { namespace math {
  134. template <class T, class U>
  135. ``__sf_result`` jacobi_cn(T k, U u);
  136. template <class T, class U, class Policy>
  137. ``__sf_result`` jacobi_cn(T k, U u, const Policy& pol);
  138. }} // namespaces
  139. [heading Description]
  140. This function returns the Jacobi elliptic function ['cn].
  141. [optional_policy]
  142. This function is a trivial wrapper around __jacobi_elliptic.
  143. [graph jacobi_cn]
  144. [endsect] [/section:jacobi_cn Jacobi Elliptic Function cn]
  145. [section:jacobi_cs Jacobi Elliptic Function cs]
  146. [heading Synopsis]
  147. ``
  148. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  149. ``
  150. namespace boost { namespace math {
  151. template <class T, class U>
  152. ``__sf_result`` jacobi_cs(T k, U u);
  153. template <class T, class U, class Policy>
  154. ``__sf_result`` jacobi_cs(T k, U u, const Policy& pol);
  155. }} // namespaces
  156. [heading Description]
  157. This function returns the Jacobi elliptic function ['cs].
  158. [optional_policy]
  159. This function is a trivial wrapper around __jacobi_elliptic, with:
  160. [expression ['cs(u, k) = cn(u, k) / sn(u, k)]]
  161. [graph jacobi_cs]
  162. [endsect] [/section:jacobi_cs Jacobi Elliptic Function cs]
  163. [section:jacobi_dc Jacobi Elliptic Function dc]
  164. [heading Synopsis]
  165. ``
  166. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  167. ``
  168. namespace boost { namespace math {
  169. template <class T, class U>
  170. ``__sf_result`` jacobi_dc(T k, U u);
  171. template <class T, class U, class Policy>
  172. ``__sf_result`` jacobi_dc(T k, U u, const Policy& pol);
  173. }} // namespaces
  174. [heading Description]
  175. This function returns the Jacobi elliptic function ['dc].
  176. [optional_policy]
  177. This function is a trivial wrapper around __jacobi_elliptic, with:
  178. [expression ['dc(u, k) = dn(u, k) / cn(u, k)]]
  179. [graph jacobi_dc]
  180. [endsect] [/section:jacobi_dc Jacobi Elliptic Function dc]
  181. [section:jacobi_dn Jacobi Elliptic Function dn]
  182. [heading Synopsis]
  183. ``
  184. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  185. ``
  186. namespace boost { namespace math {
  187. template <class T, class U>
  188. ``__sf_result`` jacobi_dn(T k, U u);
  189. template <class T, class U, class Policy>
  190. ``__sf_result`` jacobi_dn(T k, U u, const Policy& pol);
  191. }} // namespaces
  192. [heading Description]
  193. This function returns the Jacobi elliptic function ['dn].
  194. [optional_policy]
  195. This function is a trivial wrapper around __jacobi_elliptic.
  196. [graph jacobi_dn]
  197. [endsect]
  198. [section:jacobi_ds Jacobi Elliptic Function ds]
  199. [heading Synopsis]
  200. ``
  201. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  202. ``
  203. namespace boost { namespace math {
  204. template <class T, class U>
  205. ``__sf_result`` jacobi_ds(T k, U u);
  206. template <class T, class U, class Policy>
  207. ``__sf_result`` jacobi_ds(T k, U u, const Policy& pol);
  208. }} // namespaces
  209. [heading Description]
  210. This function returns the Jacobi elliptic function ['ds].
  211. [optional_policy]
  212. This function is a trivial wrapper around __jacobi_elliptic, with:
  213. [expression ['ds(u, k) = dn(u, k) / sn(u, k)]]
  214. [graph jacobi_ds]
  215. [endsect] [/section:jacobi_dn Jacobi Elliptic Function dn]
  216. [section:jacobi_nc Jacobi Elliptic Function nc]
  217. [heading Synopsis]
  218. ``
  219. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  220. ``
  221. namespace boost { namespace math {
  222. template <class T, class U>
  223. ``__sf_result`` jacobi_nc(T k, U u);
  224. template <class T, class U, class Policy>
  225. ``__sf_result`` jacobi_nc(T k, U u, const Policy& pol);
  226. }} // namespaces
  227. [heading Description]
  228. This function returns the Jacobi elliptic function ['nc].
  229. [optional_policy]
  230. This function is a trivial wrapper around __jacobi_elliptic, with:
  231. [expression ['nc(u, k) = 1 / cn(u, k)]]
  232. [graph jacobi_nc]
  233. [endsect] [/section:jacobi_nc Jacobi Elliptic Function nc]
  234. [section:jacobi_nd Jacobi Elliptic Function nd]
  235. [heading Synopsis]
  236. ``
  237. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  238. ``
  239. namespace boost { namespace math {
  240. template <class T, class U>
  241. ``__sf_result`` jacobi_nd(T k, U u);
  242. template <class T, class U, class Policy>
  243. ``__sf_result`` jacobi_nd(T k, U u, const Policy& pol);
  244. }} // namespaces
  245. [heading Description]
  246. This function returns the Jacobi elliptic function ['nd].
  247. [optional_policy]
  248. This function is a trivial wrapper around __jacobi_elliptic, with:
  249. [expression ['nd(u, k) = 1 / dn(u, k)]]
  250. [graph jacobi_nd]
  251. [endsect] [/section:jacobi_nd Jacobi Elliptic Function nd]
  252. [section:jacobi_ns Jacobi Elliptic Function ns]
  253. [heading Synopsis]
  254. ``
  255. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  256. ``
  257. namespace boost { namespace math {
  258. template <class T, class U>
  259. ``__sf_result`` jacobi_ns(T k, U u);
  260. template <class T, class U, class Policy>
  261. ``__sf_result`` jacobi_ns(T k, U u, const Policy& pol);
  262. }} // namespaces
  263. [heading Description]
  264. This function returns the Jacobi elliptic function ['ns].
  265. [optional_policy]
  266. This function is a trivial wrapper around __jacobi_elliptic, with:
  267. [expression ['ns(u, k) = 1 / sn(u, k)]]
  268. [graph jacobi_ns]
  269. [endsect] [/section:jacobi_ns Jacobi Elliptic Function ns]
  270. [section:jacobi_sc Jacobi Elliptic Function sc]
  271. [heading Synopsis]
  272. ``
  273. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  274. ``
  275. namespace boost { namespace math {
  276. template <class T, class U>
  277. ``__sf_result`` jacobi_sc(T k, U u);
  278. template <class T, class U, class Policy>
  279. ``__sf_result`` jacobi_sc(T k, U u, const Policy& pol);
  280. }} // namespaces
  281. [heading Description]
  282. This function returns the Jacobi elliptic function ['sc].
  283. [optional_policy]
  284. This function is a trivial wrapper around __jacobi_elliptic, with:
  285. [expression ['sc(u, k) = sn(u, k) / cn(u, k)]]
  286. [graph jacobi_sc]
  287. [endsect] [/section:jacobi_sc Jacobi Elliptic Function sc]
  288. [section:jacobi_sd Jacobi Elliptic Function sd]
  289. [heading Synopsis]
  290. ``
  291. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  292. ``
  293. namespace boost { namespace math {
  294. template <class T, class U>
  295. ``__sf_result`` jacobi_sd(T k, U u);
  296. template <class T, class U, class Policy>
  297. ``__sf_result`` jacobi_sd(T k, U u, const Policy& pol);
  298. }} // namespaces
  299. [heading Description]
  300. This function returns the Jacobi elliptic function ['sd].
  301. [optional_policy]
  302. This function is a trivial wrapper around __jacobi_elliptic, with:
  303. [expression ['sd(u, k) = sn(u, k) / dn(u, k)]]
  304. [graph jacobi_sd]
  305. [endsect] [/section:jacobi_sd Jacobi Elliptic Function sd]
  306. [section:jacobi_sn Jacobi Elliptic Function sn]
  307. [heading Synopsis]
  308. ``
  309. #include <boost/math/special_functions/jacobi_elliptic.hpp>
  310. ``
  311. namespace boost { namespace math {
  312. template <class T, class U>
  313. ``__sf_result`` jacobi_sn(T k, U u);
  314. template <class T, class U, class Policy>
  315. ``__sf_result`` jacobi_sn(T k, U u, const Policy& pol);
  316. }} // namespaces
  317. [heading Description]
  318. This function returns the Jacobi elliptic function ['sn].
  319. [optional_policy]
  320. This function is a trivial wrapper around __jacobi_elliptic.
  321. [graph jacobi_sn]
  322. [endsect] [/section:jacobi_sn Jacobi Elliptic Function sn]
  323. [endsect] [/section:jacobi Jacobi Elliptic Functions]