File: ellint_legendre.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (588 lines) | stat: -rw-r--r-- 17,221 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
[/
Copyright (c) 2006 Xiaogang Zhang
Copyright (c) 2006 John Maddock
Use, modification and distribution are subject to the
Boost Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]

[section:ellint_1 Elliptic Integrals of the First Kind - Legendre Form]

[heading Synopsis]

``
  #include <boost/math/special_functions/ellint_1.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2>
  ``__sf_result`` ellint_1(T1 k, T2 phi);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_1(T1 k, T2 phi, const ``__Policy``&);

  template <class T>
  ``__sf_result`` ellint_1(T k);

  template <class T, class ``__Policy``>
  ``__sf_result`` ellint_1(T k, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

These two functions evaluate the incomplete elliptic integral of the first kind
['F([phi], k)] and its complete counterpart ['K(k) = F([pi]/2, k)].

[graph ellint_1]

The return type of these functions is computed using the __arg_promotion_rules
when T1 and T2 are different types: when they are the same type then the result
is the same type as the arguments.

  template <class T1, class T2>
  ``__sf_result`` ellint_1(T1 k, T2 phi);
  
  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_1(T1 k, T2 phi, const ``__Policy``&);
  
Returns the incomplete elliptic integral of the first kind ['F([phi], k)]:

[equation ellint2]

Requires k[super 2]sin[super 2](phi) < 1, otherwise returns the result of __domain_error.

[optional_policy]

  template <class T>
  ``__sf_result`` ellint_1(T k);
  
  template <class T>
  ``__sf_result`` ellint_1(T k, const ``__Policy``&);
  
Returns the complete elliptic integral of the first kind ['K(k)]:

[equation ellint6]

Requires |k| < 1, otherwise returns the result of __domain_error.

[optional_policy]

[heading Accuracy]

These functions are computed using only basic arithmetic operations, so
there isn't much variation in accuracy over differing platforms.
Note that only results for the widest floating point type on the 
system are given as narrower types have __zero_error.  All values
are relative errors in units of epsilon.

[table_ellint_1]

The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at `double` precision, 
and GCC-7.1/Ubuntu for `long double` and `__float128`.

[graph elliptic_integral_k__double]

[graph elliptic_integral_k__80_bit_long_double]

[graph elliptic_integral_k____float128]

[heading Testing]

The tests use a mixture of spot test values calculated using the online
calculator at [@http://functions.wolfram.com/ functions.wolfram.com],
and random test data generated using
NTL::RR at 1000-bit precision and this implementation.

[heading Implementation]

These functions are implemented in terms of Carlson's integrals using the relations:

[equation ellint19]

and

[equation ellint20]

[endsect] [/section:ellint_1 Elliptic Integrals of the First Kind - Legendre Form]

[section:ellint_2 Elliptic Integrals of the Second Kind - Legendre Form]

[heading Synopsis]

``
  #include <boost/math/special_functions/ellint_2.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2>
  ``__sf_result`` ellint_2(T1 k, T2 phi);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_2(T1 k, T2 phi, const ``__Policy``&);

  template <class T>
  ``__sf_result`` ellint_2(T k);

  template <class T, class ``__Policy``>
  ``__sf_result`` ellint_2(T k, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

These two functions evaluate the incomplete elliptic integral of the second kind
['E([phi], k)] and its complete counterpart ['E(k) = E([pi]/2, k)].

[graph ellint_2]

The return type of these functions is computed using the __arg_promotion_rules
when T1 and T2 are different types: when they are the same type then the result
is the same type as the arguments.

  template <class T1, class T2>
  ``__sf_result`` ellint_2(T1 k, T2 phi);
  
  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_2(T1 k, T2 phi, const ``__Policy``&);
  
Returns the incomplete elliptic integral of the second kind ['E([phi], k)]:

[equation ellint3]

Requires k[super 2]sin[super 2](phi) < 1, otherwise returns the result of __domain_error.

[optional_policy]

  template <class T>
  ``__sf_result`` ellint_2(T k);
  
  template <class T>
  ``__sf_result`` ellint_2(T k, const ``__Policy``&);
  
Returns the complete elliptic integral of the second kind ['E(k)]:

[equation ellint7]

Requires |k| < 1, otherwise returns the result of __domain_error.

[optional_policy]

[heading Accuracy]

These functions are computed using only basic arithmetic operations, so
there isn't much variation in accuracy over differing platforms.
Note that only results for the widest floating point type on the 
system are given as narrower types have __zero_error.  All values
are relative errors in units of epsilon.

[table_ellint_2]

The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at `double` precision, 
and GCC-7.1/Ubuntu for `long double` and `__float128`.

[graph elliptic_integral_e__double]

[graph elliptic_integral_e__80_bit_long_double]

[graph elliptic_integral_e____float128]

[heading Testing]

The tests use a mixture of spot test values calculated using the online
calculator at [@http://functions.wolfram.com
functions.wolfram.com], and random test data generated using
NTL::RR at 1000-bit precision and this implementation.

[heading Implementation]

These functions are implemented in terms of Carlson's integrals
using the relations:

[equation ellint21]

and

[equation ellint22]

[endsect] [/section:ellint_2 Elliptic Integrals of the Second Kind - Legendre Form]

[section:ellint_3 Elliptic Integrals of the Third Kind - Legendre Form]

[heading Synopsis]

``
  #include <boost/math/special_functions/ellint_3.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2, class T3>
  ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi);

  template <class T1, class T2, class T3, class ``__Policy``>
  ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi, const ``__Policy``&);

  template <class T1, class T2>
  ``__sf_result`` ellint_3(T1 k, T2 n);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_3(T1 k, T2 n, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

These two functions evaluate the incomplete elliptic integral of the third kind
['[Pi](n, [phi], k)] and its complete counterpart ['[Pi](n, k) = E(n, [pi]/2, k)].

[graph ellint_3]

The return type of these functions is computed using the __arg_promotion_rules
when the arguments are of different types: when they are the same type then the result
is the same type as the arguments.

  template <class T1, class T2, class T3>
  ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi);
  
  template <class T1, class T2, class T3, class ``__Policy``>
  ``__sf_result`` ellint_3(T1 k, T2 n, T3 phi, const ``__Policy``&);
  
Returns the incomplete elliptic integral of the third kind ['[Pi](n, [phi], k)]:

[equation ellint4]

Requires ['k[super 2]sin[super 2](phi) < 1] and ['n < 1/sin[super 2]([phi])], otherwise 
returns the result of __domain_error (outside this range the result 
would be complex).

[optional_policy]

  template <class T1, class T2>
  ``__sf_result`` ellint_3(T1 k, T2 n);
  
  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_3(T1 k, T2 n, const ``__Policy``&);
  
Returns the complete elliptic integral of the first kind ['[Pi](n, k)]:

[equation ellint8]

Requires ['|k| < 1] and ['n < 1], otherwise returns the 
result of __domain_error (outside this range the result would be complex).

[optional_policy]

[heading Accuracy]

These functions are computed using only basic arithmetic operations, so
there isn't much variation in accuracy over differing platforms.
Note that only results for the widest floating point type on the 
system are given as narrower types have __zero_error.  All values
are relative errors in units of epsilon.

[table_ellint_3]

[heading Testing]

The tests use a mixture of spot test values calculated using the online
calculator at [@http://functions.wolfram.com
functions.wolfram.com], and random test data generated using
NTL::RR at 1000-bit precision and this implementation.

[heading Implementation]

The implementation for [Pi](n, [phi], k) first siphons off the special cases:

[expression ['[Pi](0, [phi], k) = F([phi], k)]]

[expression ['[Pi](n, [pi]/2, k) = [Pi](n, k)]]

and

[equation ellint23]

Then if n < 0 the relations (A&S 17.7.15/16):

[equation ellint24]

are used to shift /n/ to the range \[0, 1\].

Then the relations:

[expression ['[Pi](n, -[phi], k) = -[Pi](n, [phi], k)]]

[expression ['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) + 2m[Pi](n, k) ; n <= 1]]

[expression ['[Pi](n, [phi]+m[pi], k) = [Pi](n, [phi], k) ; n > 1] [indent] [indent]
[footnote I haven't been able to find a literature reference for this
relation, but it appears to be the convention used by Mathematica.
Intuitively the first ['2 * m * [Pi](n, k)] terms cancel out as the
derivative alternates between +[infin] and -[infin].]]

are used to move [phi] to the range \[0, [pi]\/2\].

The functions are then implemented in terms of Carlson's integrals using the relations:

[equation ellint25]

and

[equation ellint26]

[endsect] [/section:ellint_3 Elliptic Integrals of the Third Kind - Legendre Form]

[section:ellint_d Elliptic Integral D - Legendre Form]

[heading Synopsis]

``
  #include <boost/math/special_functions/ellint_d.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2>
  ``__sf_result`` ellint_d(T1 k, T2 phi);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_d(T1 k, T2 phi, const ``__Policy``&);

  template <class T1>
  ``__sf_result`` ellint_d(T1 k);

  template <class T1, class ``__Policy``>
  ``__sf_result`` ellint_d(T1 k, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

These two functions evaluate the incomplete elliptic integral 
['D([phi], k)] and its complete counterpart ['D(k) = D([pi]/2, k)].

The return type of these functions is computed using the __arg_promotion_rules
when the arguments are of different types: when they are the same type then the result
is the same type as the arguments.

  template <class T1, class T2>
  ``__sf_result`` ellint_d(T1 k, T2 phi);
  
  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` ellint_3(T1 k, T2 phi, const ``__Policy``&);
  
Returns the incomplete elliptic integral:

[equation ellint_d]

Requires ['k[super 2]sin[super 2](phi) < 1], otherwise 
returns the result of __domain_error (outside this range the result 
would be complex).

[optional_policy]

  template <class T1>
  ``__sf_result`` ellint_d(T1 k);
  
  template <class T1, class ``__Policy``>
  ``__sf_result`` ellint_d(T1 k, const ``__Policy``&);
  
Returns the complete elliptic integral ['D(k) = D([pi]/2, k)]

Requires ['-1 <= k <= 1] otherwise returns the 
result of __domain_error (outside this range the result would be complex).

[optional_policy]

[heading Accuracy]

These functions are trivially computed in terms of other elliptic integrals
and generally have very low error rates (a few epsilon) unless parameter [phi]
is very large, in which case the usual trigonometric function argument-reduction issues apply.

[table_ellint_d_complete_]

[table_ellint_d]

The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at `double` precision, 
and GCC-7.1/Ubuntu for `long double` and `__float128`.

[graph elliptic_integral_d__double]

[graph elliptic_integral_d__80_bit_long_double]

[graph elliptic_integral_d____float128]


[heading Testing]

The tests use a mixture of spot test values calculated using 
values calculated at __WolframAlpha, and random test data generated using
MPFR at 1000-bit precision and a deliberately naive implementation in terms of
the Legendre integrals.

[heading Implementation]

The implementation for D([phi], k) first performs argument reduction using the relations:

[expression ['D(-[phi], k) = -D([phi], k)]]

and

[expression ['D(n[pi]+[phi], k) = 2nD(k) + D([phi], k)]]

to move [phi] to the range \[0, [pi]\/2\].

The functions are then implemented in terms of Carlson's integral R[sub D]
using the relation:

[equation ellint_d]

[endsect] [/section:ellint_d Elliptic Integral D - Legendre Form]

[section:jacobi_zeta Jacobi Zeta Function]

[heading Synopsis]

``
  #include <boost/math/special_functions/jacobi_zeta.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2>
  ``__sf_result`` jacobi_zeta(T1 k, T2 phi);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` jacobi_zeta(T1 k, T2 phi, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

This function evaluates the Jacobi Zeta Function ['Z([phi], k)]

[equation jacobi_zeta]

Please note the use of [phi], and /k/ as the parameters, the function is often defined as ['Z([phi], m)]
with ['m = k[super 2]], see for example  [@http://mathworld.wolfram.com/JacobiZetaFunction.html Weisstein, Eric W. "Jacobi Zeta Function." From MathWorld--A Wolfram Web Resource.]
Or else as [@https://dlmf.nist.gov/22.16#E32 ['Z(x, k)]] with ['[phi] = am(x, k)], 
where ['am] is the [@https://dlmf.nist.gov/22.16#E1 Jacobi amplitude function] 
which is equivalent to ['asin(jacobi_elliptic(k, x))].

The return type of this function is computed using the __arg_promotion_rules
when the arguments are of different types: when they are the same type then the result
is the same type as the arguments.

Requires ['-1 <= k <= 1], otherwise 
returns the result of __domain_error (outside this range the result would be complex).

[optional_policy]

Note that there is no complete analogue of this function (where [phi] = [pi] / 2)
as this takes the value 0 for all ['k].

[heading Accuracy]

These functions are trivially computed in terms of other elliptic integrals
and generally have very low error rates (a few epsilon) unless parameter [phi]
is very large, in which case the usual trigonometric function argument-reduction issues apply.

[table_jacobi_zeta]

[heading Testing]

The tests use a mixture of spot test values calculated using 
values calculated at __WolframAlpha, and random test data generated using
MPFR at 1000-bit precision and a deliberately naive implementation in terms of
the Legendre integrals.

[heading Implementation]

The implementation for Z([phi], k) first makes the argument [phi] positive using:

[expression ['Z(-[phi], k) = -Z([phi], k)]]

The function is then implemented in terms of Carlson's integral R[sub J]
using the relation:

[equation jacobi_zeta]

There is one special case where the above relation fails: when ['k = 1], in that case
the function simplifies to

[expression ['Z([phi], 1) = sign(cos([phi])) sin([phi])]]

[h5:jacobi_zeta_example Example]

A simple example comparing use of __WolframAlpha with Boost.Math (including much higher precision using Boost.Multiprecision)
is [@../../example/jacobi_zeta_example.cpp jacobi_zeta_example.cpp].

[endsect] [/section:jacobi_zeta Jacobi Zeta Function]

[section:heuman_lambda Heuman Lambda Function]

[heading Synopsis]

``
  #include <boost/math/special_functions/heuman_lambda.hpp>
``

  namespace boost { namespace math {

  template <class T1, class T2>
  ``__sf_result`` heuman_lambda(T1 k, T2 phi);

  template <class T1, class T2, class ``__Policy``>
  ``__sf_result`` heuman_lambda(T1 k, T2 phi, const ``__Policy``&);

  }} // namespaces
  
[heading Description]

This function evaluates the Heuman Lambda Function ['[Lambda][sub 0]([phi], k)]

[equation heuman_lambda]

The return type of this function is computed using the __arg_promotion_rules
when the arguments are of different types: when they are the same type then the result
is the same type as the arguments.

Requires ['-1 <= k <= 1], otherwise 
returns the result of __domain_error (outside this range the result would be complex).

[optional_policy]

Note that there is no complete analogue of this function (where [phi] = [pi] / 2)
as this takes the value 1 for all ['k].

[heading Accuracy]

These functions are trivially computed in terms of other elliptic integrals
and generally have very low error rates (a few epsilon) unless parameter [phi]
is very large, in which case the usual trigonometric function argument-reduction issues apply.

[table_heuman_lambda]

[heading Testing]

The tests use a mixture of spot test values calculated using 
values calculated at __WolframAlpha, and random test data generated using
MPFR at 1000-bit precision and a deliberately naive implementation in terms of
the Legendre integrals.

[heading Implementation]

The function is then implemented in terms of Carlson's integrals R[sub J] and R[sub F]
using the relation:

[equation heuman_lambda]

This relation fails for ['|[phi]| >= [pi]/2] in which case the definition in terms of the
Jacobi Zeta is used.

[endsect] [/section:heuman_lambda Heuman Lambda Function]