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)
9 [section:ellint_1 Elliptic Integrals of the First Kind - Legendre Form]
14 #include <boost/math/special_functions/ellint_1.hpp>
17 namespace boost { namespace math {
19 template <class T1, class T2>
20 ``__sf_result`` ellint_1(T1 k, T2 phi);
22 template <class T1, class T2, class ``__Policy``>
23 ``__sf_result`` ellint_1(T1 k, T2 phi, const ``__Policy``&);
26 ``__sf_result`` ellint_1(T k);
28 template <class T, class ``__Policy``>
29 ``__sf_result`` ellint_1(T k, const ``__Policy``&);
35 These two functions evaluate the incomplete elliptic integral of the first kind
36 ['F([phi], k)] and its complete counterpart ['K(k) = F([pi]/2, k)].
40 The return type of these functions is computed using the __arg_promotion_rules
41 when T1 and T2 are different types: when they are the same type then the result
42 is the same type as the arguments.
44 template <class T1, class T2>
45 ``__sf_result`` ellint_1(T1 k, T2 phi);
47 template <class T1, class T2, class ``__Policy``>
48 ``__sf_result`` ellint_1(T1 k, T2 phi, const ``__Policy``&);
50 Returns the incomplete elliptic integral of the first kind ['F([phi], k)]:
54 Requires -1 <= k <= 1, otherwise returns the result of __domain_error.
59 ``__sf_result`` ellint_1(T k);
62 ``__sf_result`` ellint_1(T k, const ``__Policy``&);
64 Returns the complete elliptic integral of the first kind ['K(k)]:
68 Requires -1 <= k <= 1, otherwise returns the result of __domain_error.
74 These functions are computed using only basic arithmetic operations, so
75 there isn't much variation in accuracy over differing platforms.
76 Note that only results for the widest floating point type on the
77 system are given as narrower types have __zero_error. All values
78 are relative errors in units of epsilon.
84 The tests use a mixture of spot test values calculated using the online
85 calculator at [@http://functions.wolfram.com/ functions.wolfram.com],
86 and random test data generated using
87 NTL::RR at 1000-bit precision and this implementation.
89 [heading Implementation]
91 These functions are implemented in terms of Carlson's integrals
103 [section:ellint_2 Elliptic Integrals of the Second Kind - Legendre Form]
108 #include <boost/math/special_functions/ellint_2.hpp>
111 namespace boost { namespace math {
113 template <class T1, class T2>
114 ``__sf_result`` ellint_2(T1 k, T2 phi);
116 template <class T1, class T2, class ``__Policy``>
117 ``__sf_result`` ellint_2(T1 k, T2 phi, const ``__Policy``&);
120 ``__sf_result`` ellint_2(T k);
122 template <class T, class ``__Policy``>
123 ``__sf_result`` ellint_2(T k, const ``__Policy``&);
127 [heading Description]
129 These two functions evaluate the incomplete elliptic integral of the second kind
130 ['E([phi], k)] and its complete counterpart ['E(k) = E([pi]/2, k)].
134 The return type of these functions is computed using the __arg_promotion_rules
135 when T1 and T2 are different types: when they are the same type then the result
136 is the same type as the arguments.
138 template <class T1, class T2>
139 ``__sf_result`` ellint_2(T1 k, T2 phi);
141 template <class T1, class T2, class ``__Policy``>
142 ``__sf_result`` ellint_2(T1 k, T2 phi, const ``__Policy``&);
144 Returns the incomplete elliptic integral of the second kind ['E([phi], k)]:
148 Requires -1 <= k <= 1, otherwise returns the result of __domain_error.
153 ``__sf_result`` ellint_2(T k);
156 ``__sf_result`` ellint_2(T k, const ``__Policy``&);
158 Returns the complete elliptic integral of the second kind ['E(k)]:
162 Requires -1 <= k <= 1, otherwise returns the result of __domain_error.
168 These functions are computed using only basic arithmetic operations, so
169 there isn't much variation in accuracy over differing platforms.
170 Note that only results for the widest floating point type on the
171 system are given as narrower types have __zero_error. All values
172 are relative errors in units of epsilon.
178 The tests use a mixture of spot test values calculated using the online
179 calculator at [@http://functions.wolfram.com
180 functions.wolfram.com], and random test data generated using
181 NTL::RR at 1000-bit precision and this implementation.
183 [heading Implementation]
185 These functions are implemented in terms of Carlson's integrals
197 [section:ellint_3 Elliptic Integrals of the Third Kind - Legendre Form]
202 #include <boost/math/special_functions/ellint_3.hpp>
205 namespace boost { namespace math {
207 template <class T1, class T2, class T3>
208 ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi);
210 template <class T1, class T2, class T3, class ``__Policy``>
211 ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi, const ``__Policy``&);
213 template <class T1, class T2>
214 ``__sf_result`` ellint_3(T1 k, T2 n);
216 template <class T1, class T2, class ``__Policy``>
217 ``__sf_result`` ellint_3(T1 k, T2 n, const ``__Policy``&);
221 [heading Description]
223 These two functions evaluate the incomplete elliptic integral of the third kind
224 ['[Pi](n, [phi], k)] and its complete counterpart ['[Pi](n, k) = E(n, [pi]/2, k)].
228 The return type of these functions is computed using the __arg_promotion_rules
229 when the arguments are of different types: when they are the same type then the result
230 is the same type as the arguments.
232 template <class T1, class T2, class T3>
233 ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi);
235 template <class T1, class T2, class T3, class ``__Policy``>
236 ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi, const ``__Policy``&);
238 Returns the incomplete elliptic integral of the third kind ['[Pi](n, [phi], k)]:
242 Requires ['-1 <= k <= 1] and ['n < 1/sin[super 2]([phi])], otherwise
243 returns the result of __domain_error (outside this range the result
248 template <class T1, class T2>
249 ``__sf_result`` ellint_3(T1 k, T2 n);
251 template <class T1, class T2, class ``__Policy``>
252 ``__sf_result`` ellint_3(T1 k, T2 n, const ``__Policy``&);
254 Returns the complete elliptic integral of the first kind ['[Pi](n, k)]:
258 Requires ['-1 <= k <= 1] and ['n < 1], otherwise returns the
259 result of __domain_error (outside this range the result would be complex).
265 These functions are computed using only basic arithmetic operations, so
266 there isn't much variation in accuracy over differing platforms.
267 Note that only results for the widest floating point type on the
268 system are given as narrower types have __zero_error. All values
269 are relative errors in units of epsilon.
275 The tests use a mixture of spot test values calculated using the online
276 calculator at [@http://functions.wolfram.com
277 functions.wolfram.com], and random test data generated using
278 NTL::RR at 1000-bit precision and this implementation.
280 [heading Implementation]
282 The implementation for [Pi](n, [phi], k) first siphons off the special cases:
284 ['[Pi](0, [phi], k) = F([phi], k)]
286 ['[Pi](n, [pi]/2, k) = [Pi](n, k)]
292 Then if n < 0 the relations (A&S 17.7.15/16):
296 are used to shift /n/ to the range \[0, 1\].
300 ['[Pi](n, -[phi], k) = -[Pi](n, [phi], k)]
302 ['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) + 2m[Pi](n, k) ; n <= 1]
304 ['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) ; n > 1]
305 [footnote I haven't been able to find a literature reference for this
306 relation, but it appears to be the convention used by Mathematica.
307 Intuitively the first ['2 * m * [Pi](n, k)] terms cancel out as the
308 derivative alternates between +[infin] and -[infin].]
310 are used to move [phi][space] to the range \[0, [pi]\/2\].
312 The functions are then implemented in terms of Carlson's integrals
323 [section:ellint_d Elliptic Integral D - Legendre Form]
328 #include <boost/math/special_functions/ellint_d.hpp>
331 namespace boost { namespace math {
333 template <class T1, class T2>
334 ``__sf_result`` ellint_d(T1 k, T2 phi);
336 template <class T1, class T2, class ``__Policy``>
337 ``__sf_result`` ellint_d(T1 k, T2 phi, const ``__Policy``&);
340 ``__sf_result`` ellint_d(T1 k);
342 template <class T1, class ``__Policy``>
343 ``__sf_result`` ellint_d(T1 k, const ``__Policy``&);
347 [heading Description]
349 These two functions evaluate the incomplete elliptic integral
350 ['D([phi], k)] and its complete counterpart ['D(k) = D([pi]/2, k)].
352 The return type of these functions is computed using the __arg_pomotion_rules
353 when the arguments are of different types: when they are the same type then the result
354 is the same type as the arguments.
356 template <class T1, class T2>
357 ``__sf_result`` ellint_d(T1 k, T2 phi);
359 template <class T1, class T2, class ``__Policy``>
360 ``__sf_result`` ellint_3(T1 k, T2 phi, const ``__Policy``&);
362 Returns the incomplete elliptic integral:
366 Requires ['-1 <= k <= 1], otherwise
367 returns the result of __domain_error (outside this range the result
373 ``__sf_result`` ellint_d(T1 k);
375 template <class T1, class ``__Policy``>
376 ``__sf_result`` ellint_d(T1 k, const ``__Policy``&);
378 Returns the complete elliptic integral ['D(k) = D([pi]/2, k)]
380 Requires ['-1 <= k <= 1] otherwise returns the
381 result of __domain_error (outside this range the result would be complex).
387 These functions are trivially computed in terms of other elliptic integrals
388 and generally have very low error rates (a few epsilon) unless parameter [phi]
389 is very large, in which case the usual trigonometric function argument-reduction issues apply.
391 [table_ellint_d_complete_]
397 The tests use a mixture of spot test values calculated using
398 values calculated at wolframalpha.com, and random test data generated using
399 MPFR at 1000-bit precision and a deliberately naive implementation in terms of
400 the Legendre integrals.
402 [heading Implementation]
404 The implementation for D([phi], k) first performs argument reduction using the relations:
406 ['D(-[phi], k) = -D([phi], k)]
410 ['D(n[pi]+[phi], k) = 2nD(k) + D([phi], k)]
412 to move [phi][space] to the range \[0, [pi]\/2\].
414 The functions are then implemented in terms of Carlson's integral R[sub D]
421 [section:jacobi_zeta Jacobi Zeta Function]
426 #include <boost/math/special_functions/jacobi_zeta.hpp>
429 namespace boost { namespace math {
431 template <class T1, class T2>
432 ``__sf_result`` jacobi_zeta(T1 k, T2 phi);
434 template <class T1, class T2, class ``__Policy``>
435 ``__sf_result`` jacobi_zeta(T1 k, T2 phi, const ``__Policy``&);
439 [heading Description]
441 This function evaluates the Jacobi Zeta Function ['Z([phi], k)]
443 [equation jacobi_zeta]
445 The return type of this function is computed using the __arg_pomotion_rules
446 when the arguments are of different types: when they are the same type then the result
447 is the same type as the arguments.
449 Requires ['-1 <= k <= 1], otherwise
450 returns the result of __domain_error (outside this range the result
455 Note that there is no complete analogue of this function (where [phi] = [pi] / 2)
456 as this takes the value 0 for all ['k].
460 These functions are trivially computed in terms of other elliptic integrals
461 and generally have very low error rates (a few epsilon) unless parameter [phi]
462 is very large, in which case the usual trigonometric function argument-reduction issues apply.
468 The tests use a mixture of spot test values calculated using
469 values calculated at wolframalpha.com, and random test data generated using
470 MPFR at 1000-bit precision and a deliberately naive implementation in terms of
471 the Legendre integrals.
473 [heading Implementation]
475 The implementation for Z([phi], k) first makes the argument [phi] positive using:
477 ['Z(-[phi], k) = -Z([phi], k)]
479 The function is then implemented in terms of Carlson's integral R[sub J]
482 [equation jacobi_zeta]
484 There is one special case where the above relation fails: when ['k = 1], in that case
485 the function simplifies to
487 ['Z([phi], 1) = sign(cos([phi])) sin([phi])]
491 [section:heuman_lambda Heuman Lambda Function]
496 #include <boost/math/special_functions/heuman_lambda.hpp>
499 namespace boost { namespace math {
501 template <class T1, class T2>
502 ``__sf_result`` heuman_lambda(T1 k, T2 phi);
504 template <class T1, class T2, class ``__Policy``>
505 ``__sf_result`` heuman_lambda(T1 k, T2 phi, const ``__Policy``&);
509 [heading Description]
511 This function evaluates the Heuman Lambda Function ['[Lambda][sub 0]([phi], k)]
513 [equation heuman_lambda]
515 The return type of this function is computed using the __arg_pomotion_rules
516 when the arguments are of different types: when they are the same type then the result
517 is the same type as the arguments.
519 Requires ['-1 <= k <= 1], otherwise
520 returns the result of __domain_error (outside this range the result
525 Note that there is no complete analogue of this function (where [phi] = [pi] / 2)
526 as this takes the value 1 for all ['k].
530 These functions are trivially computed in terms of other elliptic integrals
531 and generally have very low error rates (a few epsilon) unless parameter [phi]
532 is very large, in which case the usual trigonometric function argument-reduction issues apply.
534 [table_heuman_lambda]
538 The tests use a mixture of spot test values calculated using
539 values calculated at wolframalpha.com, and random test data generated using
540 MPFR at 1000-bit precision and a deliberately naive implementation in terms of
541 the Legendre integrals.
543 [heading Implementation]
545 The function is then implemented in terms of Carlson's integrals R[sub J] and R[sub F]
548 [equation heuman_lambda]
550 This relation fails for ['|[phi]| >= [pi]/2] in which case the definition in terms of the