File: ellint_carlson.qbk

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (247 lines) | stat: -rw-r--r-- 7,263 bytes parent folder | download | duplicates (5)
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
[/
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_carlson Elliptic Integrals - Carlson Form]

[heading Synopsis]

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

  namespace boost { namespace math {

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z)

  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z, const ``__Policy``&)

  }} // namespaces


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

  namespace boost { namespace math {

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z)

  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z, const ``__Policy``&)

  }} // namespaces


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

  namespace boost { namespace math {

  template <class T1, class T2, class T3, class T4>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p)

  template <class T1, class T2, class T3, class T4, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p, const ``__Policy``&)

  }} // namespaces


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

  namespace boost { namespace math {

  template <class T1, class T2>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rc(T1 x, T2 y)

  template <class T1, class T2, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rc(T1 x, T2 y, const ``__Policy``&)

  }} // namespaces

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

  namespace boost { namespace math {

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z)

  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z, const ``__Policy``&)

  }} // namespaces



[heading Description]

These functions return Carlson's symmetrical elliptic integrals, the functions
have complicated behavior over all their possible domains, but the following
graph gives an idea of their behavior:

[graph ellint_carlson]

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

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z)
  
  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rf(T1 x, T2 y, T3 z, const ``__Policy``&)
  
Returns Carlson's Elliptic Integral ['R[sub F]]:

[equation ellint9]

Requires that all of the arguments are non-negative, and at most
one may be zero.  Otherwise returns the result of __domain_error.

[optional_policy]

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z)
  
  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rd(T1 x, T2 y, T3 z, const ``__Policy``&)
  
Returns Carlson's elliptic integral R[sub D]:

[equation ellint10]

Requires that x and y are non-negative, with at most one of them
zero, and that z >= 0.  Otherwise returns the result of __domain_error.

[optional_policy]

  template <class T1, class T2, class T3, class T4>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p)

  template <class T1, class T2, class T3, class T4, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rj(T1 x, T2 y, T3 z, T4 p, const ``__Policy``&)

Returns Carlson's elliptic integral R[sub J]:
  
[equation ellint11]

Requires that x, y and z are non-negative, with at most one of them
zero, and that ['p != 0].  Otherwise returns the result of __domain_error.

[optional_policy]

When ['p < 0] the function returns the
[@http://en.wikipedia.org/wiki/Cauchy_principal_value Cauchy principal value]
using the relation:

[equation ellint17]

  template <class T1, class T2>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rc(T1 x, T2 y)

  template <class T1, class T2, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rc(T1 x, T2 y, const ``__Policy``&)

Returns Carlson's elliptic integral R[sub C]:
  
[equation ellint12]

Requires that ['x > 0] and that ['y != 0].  
Otherwise returns the result of __domain_error.

[optional_policy]

When ['y < 0] the function returns the
[@http://mathworld.wolfram.com/CauchyPrincipalValue.html Cauchy principal value]
using the relation:

[equation ellint18]

  template <class T1, class T2, class T3>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z)
  
  template <class T1, class T2, class T3, class ``__Policy``>
  BOOST_MATH_GPU_ENABLED ``__sf_result`` ellint_rg(T1 x, T2 y, T3 z, const ``__Policy``&)
  
Returns Carlson's elliptic integral ['R[sub G]:]

[equation ellint27]

Requires that x and y are non-negative, otherwise returns the result of __domain_error.

[optional_policy]

[heading Testing]

There are two sets of tests.

Spot tests compare selected values with test data given in:

[:B. C. Carlson, ['[@http://arxiv.org/abs/math.CA/9409227 
Numerical computation of real or complex elliptic integrals]]. Numerical Algorithms,
Volume 10, Number 1 / March, 1995, pp 13-26.]

Random test data generated using NTL::RR at 1000-bit precision and our
implementation checks for rounding-errors and/or regressions.

There are also sanity checks that use the inter-relations between the integrals
to verify their correctness: see the above Carlson paper for details.

[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_rc]

[table_ellint_rd]

[table_ellint_rg]

[table_ellint_rf]

[table_ellint_rj]


[heading Implementation]

The key of Carlson's algorithm [[link ellint_ref_carlson79 Carlson79]] is the
duplication theorem:

[equation ellint13]

By applying it repeatedly, ['x], ['y], ['z] get
closer and closer. When they are nearly equal, the special case equation

[equation ellint16]

is used. More specifically, ['[R F]] is evaluated from a Taylor series
expansion to the fifth order. The calculations of the other three integrals
are analogous, except for R[sub C] which can be computed from elementary functions.

For ['p < 0] in ['R[sub J](x, y, z, p)] and ['y < 0] in ['R[sub C](x, y)],
the integrals are singular and their
[@http://mathworld.wolfram.com/CauchyPrincipalValue.html Cauchy principal values]
are returned via the relations:

[equation ellint17]

[equation ellint18]

[endsect] [/section:ellint_carlson Elliptic Integrals - Carlson Form]