Debian Codegraph @

external/gsl/gsl_specfunc__ellint.c

raw symbols SCIP
1 /* specfunc/ellint.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 /* Author: G. Jungman */
21
22 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
23 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
24 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
25 #include "gsl_precision.h"cxx . . $ `<file>/external/gsl/gsl_precision.h`/
26 #include "gsl_sf_ellint.h"cxx . . $ `<file>/external/gsl/gsl_sf_ellint.h`/
27
28 #include "gsl_specfunc__error.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__error.h`/
29
30 /*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
31
32 inline
33 static double locMAX3cxx . . $ locMAX3(7678bba071383ab).(double x, double y, double z)
34 {
35 double xy = GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(x, y);
36 return GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(xy, z);
37 }
38
39 inline
40 static double locMAX4cxx . . $ locMAX4(6ba6c9f826937c6e).(double x, double y, double z, double w)
41 {
42 double xy = GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(x, y);
43 double xyz = GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(xy, z);
44 return GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(xyz, w);
45 }
46
47
48 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
49
50
51 /* based on Carlson's algorithms:
52 [B. C. Carlson Numer. Math. 33, 1 (1979)]
53
54 see also:
55 [B.C. Carlson, Special Functions of Applied Mathematics (1977)]
56 */
57
58 /* According to Carlson's algorithm, the errtol parameter
59 typically effects the relative error in the following way:
60
61 relative error < 16 errtol^6 / (1 - 2 errtol)
62
63 errtol precision
64 ------ ----------
65 0.001 1.0e-17
66 0.003 2.0e-14
67 0.01 2.0e-11
68 0.03 2.0e-8
69 0.1 2.0e-5
70 */
71
72
73 int
74 gsl_sf_ellint_RC_ecxx . . $ gsl_sf_ellint_RC_e(f85c8505c912bd35).(double x, double y, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
75 {
76 const double lolim = 5.0 * GSL_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:25:9`!;
77 const double uplim = 0.2 * GSL_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:33:9`!;
78 const gsl_prec_tcxx . . $ gsl_prec_t# goal = GSL_MODE_PRECcxx . . $ `external/gsl/gsl_mode.h:76:9`!(mode);
79 const double errtol = ( goal == GSL_PREC_DOUBLEcxx . . $ `external/gsl/gsl_mode.h:65:9`! ? 0.001 : 0.03 );
80 const double prec = gsl_prec_epscxx . . $ gsl_prec_eps.[goal];
81
82 if(x < 0.0 || y < 0.0 || x + y < lolim) {
83 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
84 }
85 else if(GSL_MAXcxx . . $ `external/gsl/gsl_math.h:122:9`!(x, y) < uplim) {
86 const double c1 = 1.0 / 7.0;
87 const double c2 = 9.0 / 22.0;
88 double xn = x;
89 double yn = y;
90 double mu, sn, lamda, s;
91 while(1) {
92 mu = (xn + yn + yn) / 3.0;
93 sn = (yn + mu) / mu - 2.0;
94 if (fabscxx . . $ fabs(447c67c6676f75c3).(sn) < errtol) break;
95 lamda = 2.0 * sqrtcxx . . $ sqrt(447c67c6676f75c3).(xn) * sqrtcxx . . $ sqrt(447c67c6676f75c3).(yn) + yn;
96 xn = (xn + lamda) * 0.25;
97 yn = (yn + lamda) * 0.25;
98 }
99 s = sn * sn * (0.3 + sn * (c1 + sn * (0.375 + sn * c2)));
100 result->valcxx . . $ gsl_sf_result_struct#val. = (1.0 + s) / sqrtcxx . . $ sqrt(447c67c6676f75c3).(mu);
101 result->errcxx . . $ gsl_sf_result_struct#err. = prec * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.);
102 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
103 }
104 else {
105 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
106 }
107 }
108
109
110 int
111 gsl_sf_ellint_RD_ecxx . . $ gsl_sf_ellint_RD_e(c0f8b609a119d834).(double x, double y, double z, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
112 {
113 const gsl_prec_tcxx . . $ gsl_prec_t# goal = GSL_MODE_PRECcxx . . $ `external/gsl/gsl_mode.h:76:9`!(mode);
114 const double errtol = ( goal == GSL_PREC_DOUBLEcxx . . $ `external/gsl/gsl_mode.h:65:9`! ? 0.001 : 0.03 );
115 const double prec = gsl_prec_epscxx . . $ gsl_prec_eps.[goal];
116 const double lolim = 2.0/powcxx . . $ pow(d8e7e0733fa41c87).(GSL_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:33:9`!, 2.0/3.0);
117 const double uplim = powcxx . . $ pow(d8e7e0733fa41c87).(0.1*errtol/GSL_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:25:9`!, 2.0/3.0);
118
119 if(GSL_MINcxx . . $ `external/gsl/gsl_math.h:123:9`!(x,y) < 0.0 || GSL_MINcxx . . $ `external/gsl/gsl_math.h:123:9`!(x+y,z) < lolim) {
120 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
121 }
122 else if(locMAX3cxx . . $ locMAX3(7678bba071383ab).(x,y,z) < uplim) {
123 const double c1 = 3.0 / 14.0;
124 const double c2 = 1.0 / 6.0;
125 const double c3 = 9.0 / 22.0;
126 const double c4 = 3.0 / 26.0;
127 double xn = x;
128 double yn = y;
129 double zn = z;
130 double sigma = 0.0;
131 double power4 = 1.0;
132 double ea, eb, ec, ed, ef, s1, s2;
133 double mu, xndev, yndev, zndev;
134 while(1) {
135 double xnroot, ynroot, znroot, lamda;
136 double epslon;
137 mu = (xn + yn + 3.0 * zn) * 0.2;
138 xndev = (mu - xn) / mu;
139 yndev = (mu - yn) / mu;
140 zndev = (mu - zn) / mu;
141 epslon = locMAX3cxx . . $ locMAX3(7678bba071383ab).(fabscxx . . $ fabs(447c67c6676f75c3).(xndev), fabscxx . . $ fabs(447c67c6676f75c3).(yndev), fabscxx . . $ fabs(447c67c6676f75c3).(zndev));
142 if (epslon < errtol) break;
143 xnroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(xn);
144 ynroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(yn);
145 znroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(zn);
146 lamda = xnroot * (ynroot + znroot) + ynroot * znroot;
147 sigma += power4 / (znroot * (zn + lamda));
148 power4 *= 0.25;
149 xn = (xn + lamda) * 0.25;
150 yn = (yn + lamda) * 0.25;
151 zn = (zn + lamda) * 0.25;
152 }
153 ea = xndev * yndev;
154 eb = zndev * zndev;
155 ec = ea - eb;
156 ed = ea - 6.0 * eb;
157 ef = ed + ec + ec;
158 s1 = ed * (- c1 + 0.25 * c3 * ed - 1.5 * c4 * zndev * ef);
159 s2 = zndev * (c2 * ef + zndev * (- c3 * ec + zndev * c4 * ea));
160 result->valcxx . . $ gsl_sf_result_struct#val. = 3.0 * sigma + power4 * (1.0 + s1 + s2) / (mu * sqrtcxx . . $ sqrt(447c67c6676f75c3).(mu));
161 result->errcxx . . $ gsl_sf_result_struct#err. = prec * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.);
162 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
163 }
164 else {
165 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
166 }
167 }
168
169
170 int
171 gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(double x, double y, double z, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
172 {
173 const double lolim = 5.0 * GSL_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:25:9`!;
174 const double uplim = 0.2 * GSL_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:33:9`!;
175 const gsl_prec_tcxx . . $ gsl_prec_t# goal = GSL_MODE_PRECcxx . . $ `external/gsl/gsl_mode.h:76:9`!(mode);
176 const double errtol = ( goal == GSL_PREC_DOUBLEcxx . . $ `external/gsl/gsl_mode.h:65:9`! ? 0.001 : 0.03 );
177 const double prec = gsl_prec_epscxx . . $ gsl_prec_eps.[goal];
178
179 if(x < 0.0 || y < 0.0 || z < 0.0) {
180 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
181 }
182 else if(x+y < lolim || x+z < lolim || y+z < lolim) {
183 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
184 }
185 else if(locMAX3cxx . . $ locMAX3(7678bba071383ab).(x,y,z) < uplim) {
186 const double c1 = 1.0 / 24.0;
187 const double c2 = 3.0 / 44.0;
188 const double c3 = 1.0 / 14.0;
189 double xn = x;
190 double yn = y;
191 double zn = z;
192 double mu, xndev, yndev, zndev, e2, e3, s;
193 while(1) {
194 double epslon, lamda;
195 double xnroot, ynroot, znroot;
196 mu = (xn + yn + zn) / 3.0;
197 xndev = 2.0 - (mu + xn) / mu;
198 yndev = 2.0 - (mu + yn) / mu;
199 zndev = 2.0 - (mu + zn) / mu;
200 epslon = locMAX3cxx . . $ locMAX3(7678bba071383ab).(fabscxx . . $ fabs(447c67c6676f75c3).(xndev), fabscxx . . $ fabs(447c67c6676f75c3).(yndev), fabscxx . . $ fabs(447c67c6676f75c3).(zndev));
201 if (epslon < errtol) break;
202 xnroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(xn);
203 ynroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(yn);
204 znroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(zn);
205 lamda = xnroot * (ynroot + znroot) + ynroot * znroot;
206 xn = (xn + lamda) * 0.25;
207 yn = (yn + lamda) * 0.25;
208 zn = (zn + lamda) * 0.25;
209 }
210 e2 = xndev * yndev - zndev * zndev;
211 e3 = xndev * yndev * zndev;
212 s = 1.0 + (c1 * e2 - 0.1 - c2 * e3) * e2 + c3 * e3;
213 result->valcxx . . $ gsl_sf_result_struct#val. = s / sqrtcxx . . $ sqrt(447c67c6676f75c3).(mu);
214 result->errcxx . . $ gsl_sf_result_struct#err. = prec * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.);
215 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
216 }
217 else {
218 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
219 }
220 }
221
222
223 int
224 gsl_sf_ellint_RJ_ecxx . . $ gsl_sf_ellint_RJ_e(7ac17249d713d72d).(double x, double y, double z, double p, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
225 {
226 const gsl_prec_tcxx . . $ gsl_prec_t# goal = GSL_MODE_PRECcxx . . $ `external/gsl/gsl_mode.h:76:9`!(mode);
227 const double errtol = ( goal == GSL_PREC_DOUBLEcxx . . $ `external/gsl/gsl_mode.h:65:9`! ? 0.001 : 0.03 );
228 const double prec = gsl_prec_epscxx . . $ gsl_prec_eps.[goal];
229 const double lolim = powcxx . . $ pow(d8e7e0733fa41c87).(5.0 * GSL_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:25:9`!, 1.0/3.0);
230 const double uplim = 0.3 * powcxx . . $ pow(d8e7e0733fa41c87).(0.2 * GSL_DBL_MAXcxx . . $ `external/gsl/gsl_machine.h:33:9`!, 1.0/3.0);
231
232 if(x < 0.0 || y < 0.0 || z < 0.0) {
233 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
234 }
235 else if(x + y < lolim || x + z < lolim || y + z < lolim || p < lolim) {
236 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
237 }
238 else if(locMAX4cxx . . $ locMAX4(6ba6c9f826937c6e).(x,y,z,p) < uplim) {
239 const double c1 = 3.0 / 14.0;
240 const double c2 = 1.0 / 3.0;
241 const double c3 = 3.0 / 22.0;
242 const double c4 = 3.0 / 26.0;
243 double xn = x;
244 double yn = y;
245 double zn = z;
246 double pn = p;
247 double sigma = 0.0;
248 double power4 = 1.0;
249 double mu, xndev, yndev, zndev, pndev;
250 double ea, eb, ec, e2, e3, s1, s2, s3;
251 while(1) {
252 double xnroot, ynroot, znroot;
253 double lamda, alfa, beta;
254 double epslon;
255 gsl_sf_resultcxx . . $ gsl_sf_result# rcresult;
256 int rcstatus;
257 mu = (xn + yn + zn + pn + pn) * 0.2;
258 xndev = (mu - xn) / mu;
259 yndev = (mu - yn) / mu;
260 zndev = (mu - zn) / mu;
261 pndev = (mu - pn) / mu;
262 epslon = locMAX4cxx . . $ locMAX4(6ba6c9f826937c6e).(fabscxx . . $ fabs(447c67c6676f75c3).(xndev), fabscxx . . $ fabs(447c67c6676f75c3).(yndev), fabscxx . . $ fabs(447c67c6676f75c3).(zndev), fabscxx . . $ fabs(447c67c6676f75c3).(pndev));
263 if(epslon < errtol) break;
264 xnroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(xn);
265 ynroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(yn);
266 znroot = sqrtcxx . . $ sqrt(447c67c6676f75c3).(zn);
267 lamda = xnroot * (ynroot + znroot) + ynroot * znroot;
268 alfa = pn * (xnroot + ynroot + znroot) + xnroot * ynroot * znroot;
269 alfa = alfa * alfa;
270 beta = pn * (pn + lamda) * (pn + lamda);
271 rcstatus = gsl_sf_ellint_RC_ecxx . . $ gsl_sf_ellint_RC_e(f85c8505c912bd35).(alfa, beta, mode, &rcresult);
272 if(rcstatus != GSL_SUCCESScxx . . $ GSL_SUCCESS.) {
273 result->valcxx . . $ gsl_sf_result_struct#val. = 0.0;
274 result->errcxx . . $ gsl_sf_result_struct#err. = 0.0;
275 return rcstatus;
276 }
277 sigma += power4 * rcresult.valcxx . . $ gsl_sf_result_struct#val.;
278 power4 *= 0.25;
279 xn = (xn + lamda) * 0.25;
280 yn = (yn + lamda) * 0.25;
281 zn = (zn + lamda) * 0.25;
282 pn = (pn + lamda) * 0.25;
283 }
284
285 ea = xndev * (yndev + zndev) + yndev * zndev;
286 eb = xndev * yndev * zndev;
287 ec = pndev * pndev;
288 e2 = ea - 3.0 * ec;
289 e3 = eb + 2.0 * pndev * (ea - ec);
290 s1 = 1.0 + e2 * (- c1 + 0.75 * c3 * e2 - 1.5 * c4 * e3);
291 s2 = eb * (0.5 * c2 + pndev * (- c3 - c3 + pndev * c4));
292 s3 = pndev * ea * (c2 - pndev * c3) - c2 * pndev * ec;
293 result->valcxx . . $ gsl_sf_result_struct#val. = 3.0 * sigma + power4 * (s1 + s2 + s3) / (mu * sqrtcxx . . $ sqrt(447c67c6676f75c3).(mu));
294 result->errcxx . . $ gsl_sf_result_struct#err. = prec * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.);
295 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
296 }
297 else {
298 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
299 }
300 }
301
302
303 /* [Carlson, Numer. Math. 33 (1979) 1, (4.1)] */
304 int
305 gsl_sf_ellint_F_ecxx . . $ gsl_sf_ellint_F_e(f85c8505c912bd35).(double phi, double k, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
306 {
307 /* Angular reduction to -pi/2 < phi < pi/2 (we should really use an
308 exact reduction but this will have to do for now) BJG */
309
310 double nc = floorcxx . . $ floor(447c67c6676f75c3).(phi/M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! + 0.5);
311 double phi_red = phi - nc * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
312 phi = phi_red;
313
314 {
315 double sin_phi = sincxx . . $ sin(447c67c6676f75c3).(phi);
316 double sin2_phi = sin_phi*sin_phi;
317 double x = 1.0 - sin2_phi;
318 double y = 1.0 - k*k*sin2_phi;
319 gsl_sf_resultcxx . . $ gsl_sf_result# rf;
320 int status = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(x, y, 1.0, mode, &rf);
321 result->valcxx . . $ gsl_sf_result_struct#val. = sin_phi * rf.valcxx . . $ gsl_sf_result_struct#val.;
322 result->errcxx . . $ gsl_sf_result_struct#err. = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.) + fabscxx . . $ fabs(447c67c6676f75c3).(sin_phi*rf.errcxx . . $ gsl_sf_result_struct#err.);
323 if (nc == 0) {
324 return status;
325 } else {
326 gsl_sf_resultcxx . . $ gsl_sf_result# rk; /* add extra terms from periodicity */
327 const int rkstatus = gsl_sf_ellint_Kcomp_ecxx . . $ gsl_sf_ellint_Kcomp_e(20a82b5be633c070).(k, mode, &rk);
328 result->valcxx . . $ gsl_sf_result_struct#val. += 2*nc*rk.valcxx . . $ gsl_sf_result_struct#val.;
329 result->errcxx . . $ gsl_sf_result_struct#err. += 2*fabscxx . . $ fabs(447c67c6676f75c3).(nc)*rk.errcxx . . $ gsl_sf_result_struct#err.;
330 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(status, rkstatus);
331 }
332 }
333 }
334
335
336 /* [Carlson, Numer. Math. 33 (1979) 1, (4.2)] */
337 int
338 gsl_sf_ellint_E_ecxx . . $ gsl_sf_ellint_E_e(f85c8505c912bd35).(double phi, double k, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
339 {
340 /* Angular reduction to -pi/2 < phi < pi/2 (we should really use an
341 exact reduction but this will have to do for now) BJG */
342
343 double nc = floorcxx . . $ floor(447c67c6676f75c3).(phi/M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! + 0.5);
344 double phi_red = phi - nc * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
345 phi = phi_red;
346
347 {
348 const double sin_phi = sincxx . . $ sin(447c67c6676f75c3).(phi);
349 const double sin2_phi = sin_phi * sin_phi;
350 const double x = 1.0 - sin2_phi;
351 const double y = 1.0 - k*k*sin2_phi;
352
353 if(x < GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!) {
354 gsl_sf_resultcxx . . $ gsl_sf_result# re;
355 const int status = gsl_sf_ellint_Ecomp_ecxx . . $ gsl_sf_ellint_Ecomp_e(20a82b5be633c070).(k, mode, &re);
356 /* could use A&S 17.4.14 to improve the value below */
357 result->valcxx . . $ gsl_sf_result_struct#val. = 2*nc*re.valcxx . . $ gsl_sf_result_struct#val. + GSL_SIGNcxx . . $ `external/gsl/gsl_math.h:114:9`!(sin_phi) * re.valcxx . . $ gsl_sf_result_struct#val.;
358 result->errcxx . . $ gsl_sf_result_struct#err. = 2*fabscxx . . $ fabs(447c67c6676f75c3).(nc)*re.errcxx . . $ gsl_sf_result_struct#err. + re.errcxx . . $ gsl_sf_result_struct#err.;
359 return status;
360 }
361 else {
362 gsl_sf_resultcxx . . $ gsl_sf_result# rf, rd;
363 const double sin3_phi = sin2_phi * sin_phi;
364 const int rfstatus = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(x, y, 1.0, mode, &rf);
365 const int rdstatus = gsl_sf_ellint_RD_ecxx . . $ gsl_sf_ellint_RD_e(c0f8b609a119d834).(x, y, 1.0, mode, &rd);
366 result->valcxx . . $ gsl_sf_result_struct#val. = sin_phi * rf.valcxx . . $ gsl_sf_result_struct#val. - k*k/3.0 * sin3_phi * rd.valcxx . . $ gsl_sf_result_struct#val.;
367 result->errcxx . . $ gsl_sf_result_struct#err. = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(sin_phi * rf.valcxx . . $ gsl_sf_result_struct#val.);
368 result->errcxx . . $ gsl_sf_result_struct#err. += fabscxx . . $ fabs(447c67c6676f75c3).(sin_phi*rf.errcxx . . $ gsl_sf_result_struct#err.);
369 result->errcxx . . $ gsl_sf_result_struct#err. += k*k/3.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(sin3_phi * rd.valcxx . . $ gsl_sf_result_struct#val.);
370 result->errcxx . . $ gsl_sf_result_struct#err. += k*k/3.0 * fabscxx . . $ fabs(447c67c6676f75c3).(sin3_phi*rd.errcxx . . $ gsl_sf_result_struct#err.);
371 if (nc == 0) {
372 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(rfstatus, rdstatus);
373 } else {
374 gsl_sf_resultcxx . . $ gsl_sf_result# re; /* add extra terms from periodicity */
375 const int restatus = gsl_sf_ellint_Ecomp_ecxx . . $ gsl_sf_ellint_Ecomp_e(20a82b5be633c070).(k, mode, &re);
376 result->valcxx . . $ gsl_sf_result_struct#val. += 2*nc*re.valcxx . . $ gsl_sf_result_struct#val.;
377 result->errcxx . . $ gsl_sf_result_struct#err. += 2*fabscxx . . $ fabs(447c67c6676f75c3).(nc)*re.errcxx . . $ gsl_sf_result_struct#err.;
378 return GSL_ERROR_SELECT_3cxx . . $ `external/gsl/gsl_errno.h:146:9`!(rfstatus, rdstatus, restatus);
379 }
380 }
381 }
382 }
383
384
385 /* [Carlson, Numer. Math. 33 (1979) 1, (4.3)] */
386 int
387 gsl_sf_ellint_P_ecxx . . $ gsl_sf_ellint_P_e(c0f8b609a119d834).(double phi, double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
388 {
389 /* Angular reduction to -pi/2 < phi < pi/2 (we should really use an
390 exact reduction but this will have to do for now) BJG */
391
392 double nc = floorcxx . . $ floor(447c67c6676f75c3).(phi/M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! + 0.5);
393 double phi_red = phi - nc * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
394 phi = phi_red;
395
396 /* FIXME: need to handle the case of small x, as for E,F */
397
398 {
399 const double sin_phi = sincxx . . $ sin(447c67c6676f75c3).(phi);
400 const double sin2_phi = sin_phi * sin_phi;
401 const double sin3_phi = sin2_phi * sin_phi;
402 const double x = 1.0 - sin2_phi;
403 const double y = 1.0 - k*k*sin2_phi;
404 gsl_sf_resultcxx . . $ gsl_sf_result# rf;
405 gsl_sf_resultcxx . . $ gsl_sf_result# rj;
406 const int rfstatus = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(x, y, 1.0, mode, &rf);
407 const int rjstatus = gsl_sf_ellint_RJ_ecxx . . $ gsl_sf_ellint_RJ_e(7ac17249d713d72d).(x, y, 1.0, 1.0 + n*sin2_phi, mode, &rj);
408 result->valcxx . . $ gsl_sf_result_struct#val. = sin_phi * rf.valcxx . . $ gsl_sf_result_struct#val. - n/3.0*sin3_phi * rj.valcxx . . $ gsl_sf_result_struct#val.;
409 result->errcxx . . $ gsl_sf_result_struct#err. = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(sin_phi * rf.valcxx . . $ gsl_sf_result_struct#val.);
410 result->errcxx . . $ gsl_sf_result_struct#err. += fabscxx . . $ fabs(447c67c6676f75c3).(sin_phi * rf.errcxx . . $ gsl_sf_result_struct#err.);
411 result->errcxx . . $ gsl_sf_result_struct#err. += n/3.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(sin3_phi*rj.valcxx . . $ gsl_sf_result_struct#val.);
412 result->errcxx . . $ gsl_sf_result_struct#err. += n/3.0 * fabscxx . . $ fabs(447c67c6676f75c3).(sin3_phi*rj.errcxx . . $ gsl_sf_result_struct#err.);
413 if (nc == 0) {
414 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(rfstatus, rjstatus);
415 } else {
416 gsl_sf_resultcxx . . $ gsl_sf_result# rp; /* add extra terms from periodicity */
417 const int rpstatus = gsl_sf_ellint_Pcomp_ecxx . . $ gsl_sf_ellint_Pcomp_e(f85c8505c912bd35).(k, n, mode, &rp);
418 result->valcxx . . $ gsl_sf_result_struct#val. += 2*nc*rp.valcxx . . $ gsl_sf_result_struct#val.;
419 result->errcxx . . $ gsl_sf_result_struct#err. += 2*fabscxx . . $ fabs(447c67c6676f75c3).(nc)*rp.errcxx . . $ gsl_sf_result_struct#err.;
420 return GSL_ERROR_SELECT_3cxx . . $ `external/gsl/gsl_errno.h:146:9`!(rfstatus, rjstatus, rpstatus);
421 }
422 }
423 }
424
425
426 /* [Carlson, Numer. Math. 33 (1979) 1, (4.4)] */
427 int
428 gsl_sf_ellint_D_ecxx . . $ gsl_sf_ellint_D_e(c0f8b609a119d834).(double phi, double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
429 {
430 /* Angular reduction to -pi/2 < phi < pi/2 (we should really use an
431 exact reduction but this will have to do for now) BJG */
432
433 double nc = floorcxx . . $ floor(447c67c6676f75c3).(phi/M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! + 0.5);
434 double phi_red = phi - nc * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!;
435 phi = phi_red;
436
437 /* FIXME: need to handle the case of small x, as for E,F */
438 {
439 const double sin_phi = sincxx . . $ sin(447c67c6676f75c3).(phi);
440 const double sin2_phi = sin_phi * sin_phi;
441 const double sin3_phi = sin2_phi * sin_phi;
442 const double x = 1.0 - sin2_phi;
443 const double y = 1.0 - k*k*sin2_phi;
444 gsl_sf_resultcxx . . $ gsl_sf_result# rd;
445 const int status = gsl_sf_ellint_RD_ecxx . . $ gsl_sf_ellint_RD_e(c0f8b609a119d834).(x, y, 1.0, mode, &rd);
446 result->valcxx . . $ gsl_sf_result_struct#val. = sin3_phi/3.0 * rd.valcxx . . $ gsl_sf_result_struct#val.;
447 result->errcxx . . $ gsl_sf_result_struct#err. = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.) + fabscxx . . $ fabs(447c67c6676f75c3).(sin3_phi/3.0 * rd.errcxx . . $ gsl_sf_result_struct#err.);
448 if (nc == 0) {
449 return status;
450 } else {
451 gsl_sf_resultcxx . . $ gsl_sf_result# rd; /* add extra terms from periodicity */
452 const int rdstatus = gsl_sf_ellint_Dcomp_ecxx . . $ gsl_sf_ellint_Dcomp_e(20a82b5be633c070).(k, mode, &rd);
453 result->valcxx . . $ gsl_sf_result_struct#val. += 2*nc*rd.valcxx . . $ gsl_sf_result_struct#val.;
454 result->errcxx . . $ gsl_sf_result_struct#err. += 2*fabscxx . . $ fabs(447c67c6676f75c3).(nc)*rd.errcxx . . $ gsl_sf_result_struct#err.;
455 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(status, rdstatus);
456 }
457 }
458 }
459
460 int
461 gsl_sf_ellint_Dcomp_ecxx . . $ gsl_sf_ellint_Dcomp_e(20a82b5be633c070).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
462 {
463 if(k*k >= 1.0) {
464 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
465 } else {
466 const double y = 1.0 - k*k; /* FIXME: still need to handle k~=~1 */
467 gsl_sf_resultcxx . . $ gsl_sf_result# rd;
468 const int status = gsl_sf_ellint_RD_ecxx . . $ gsl_sf_ellint_RD_e(c0f8b609a119d834).(0.0, y, 1.0, mode, &rd);
469 result->valcxx . . $ gsl_sf_result_struct#val. = (1.0/3.0) * rd.valcxx . . $ gsl_sf_result_struct#val.;
470 result->errcxx . . $ gsl_sf_result_struct#err. = GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabscxx . . $ fabs(447c67c6676f75c3).(result->valcxx . . $ gsl_sf_result_struct#val.) + fabscxx . . $ fabs(447c67c6676f75c3).(1.0/3.0 * rd.errcxx . . $ gsl_sf_result_struct#err.);
471 return status;
472 }
473 }
474
475
476 /* [Carlson, Numer. Math. 33 (1979) 1, (4.5)] */
477 int
478 gsl_sf_ellint_Kcomp_ecxx . . $ gsl_sf_ellint_Kcomp_e(20a82b5be633c070).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
479 {
480 if(k*k >= 1.0) {
481 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
482 }
483 else if(k*k >= 1.0 - GSL_SQRT_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:18:9`!) {
484 /* [Abramowitz+Stegun, 17.3.33] */
485 const double y = 1.0 - k*k;
486 const double a[] = { 1.38629436112, 0.09666344259, 0.03590092383 };
487 const double b[] = { 0.5, 0.12498593597, 0.06880248576 };
488 const double ta = a[0] + y*(a[1] + y*a[2]);
489 const double tb = -logcxx . . $ log(447c67c6676f75c3).(y) * (b[0] * y*(b[1] + y*b[2]));
490 result->valcxx . . $ gsl_sf_result_struct#val. = ta + tb;
491 result->errcxx . . $ gsl_sf_result_struct#err. = 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * result->valcxx . . $ gsl_sf_result_struct#val.;
492 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
493 }
494 else {
495 /* This was previously computed as,
496
497 return gsl_sf_ellint_RF_e(0.0, 1.0 - k*k, 1.0, mode, result);
498
499 but this underestimated the total error for small k, since the
500 argument y=1-k^2 is not exact (there is an absolute error of
501 GSL_DBL_EPSILON near y=0 due to cancellation in the subtraction).
502 Taking the singular behavior of -log(y) above gives an error
503 of 0.5*epsilon/y near y=0. (BJG) */
504
505 double y = 1.0 - k*k;
506 int status = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(0.0, y, 1.0, mode, result);
507 result->errcxx . . $ gsl_sf_result_struct#err. += 0.5 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! / y;
508 return status ;
509 }
510 }
511
512
513 /* [Carlson, Numer. Math. 33 (1979) 1, (4.6)] */
514 int
515 gsl_sf_ellint_Ecomp_ecxx . . $ gsl_sf_ellint_Ecomp_e(20a82b5be633c070).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
516 {
517 if(k*k >= 1.0) {
518 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
519 }
520 else if(k*k >= 1.0 - GSL_SQRT_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:18:9`!) {
521 /* [Abramowitz+Stegun, 17.3.36] */
522 const double y = 1.0 - k*k;
523 const double a[] = { 0.44325141463, 0.06260601220, 0.04757383546 };
524 const double b[] = { 0.24998368310, 0.09200180037, 0.04069697526 };
525 const double ta = 1.0 + y*(a[0] + y*(a[1] + a[2]*y));
526 const double tb = -y*logcxx . . $ log(447c67c6676f75c3).(y) * (b[0] + y*(b[1] + b[2]*y));
527 result->valcxx . . $ gsl_sf_result_struct#val. = ta + tb;
528 result->errcxx . . $ gsl_sf_result_struct#err. = 2.0 * GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * result->valcxx . . $ gsl_sf_result_struct#val.;
529 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
530 }
531 else {
532 gsl_sf_resultcxx . . $ gsl_sf_result# rf;
533 gsl_sf_resultcxx . . $ gsl_sf_result# rd;
534 const double y = 1.0 - k*k;
535 const int rfstatus = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(0.0, y, 1.0, mode, &rf);
536 const int rdstatus = gsl_sf_ellint_RD_ecxx . . $ gsl_sf_ellint_RD_e(c0f8b609a119d834).(0.0, y, 1.0, mode, &rd);
537 result->valcxx . . $ gsl_sf_result_struct#val. = rf.valcxx . . $ gsl_sf_result_struct#val. - k*k/3.0 * rd.valcxx . . $ gsl_sf_result_struct#val.;
538 result->errcxx . . $ gsl_sf_result_struct#err. = rf.errcxx . . $ gsl_sf_result_struct#err. + k*k/3.0 * rd.errcxx . . $ gsl_sf_result_struct#err.;
539 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(rfstatus, rdstatus);
540 }
541 }
542
543 /* [Carlson, Numer. Math. 33 (1979) 1, (4.3) phi=pi/2] */
544 int
545 gsl_sf_ellint_Pcomp_ecxx . . $ gsl_sf_ellint_Pcomp_e(f85c8505c912bd35).(double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
546 {
547 if(k*k >= 1.0) {
548 DOMAIN_ERRORcxx . . $ `external/gsl/gsl_specfunc__error.h:9:9`!(result);
549 }
550 /* FIXME: need to handle k ~=~ 1 cancellations */
551 else {
552 gsl_sf_resultcxx . . $ gsl_sf_result# rf;
553 gsl_sf_resultcxx . . $ gsl_sf_result# rj;
554 const double y = 1.0 - k*k;
555 const int rfstatus = gsl_sf_ellint_RF_ecxx . . $ gsl_sf_ellint_RF_e(c0f8b609a119d834).(0.0, y, 1.0, mode, &rf);
556 const int rjstatus = gsl_sf_ellint_RJ_ecxx . . $ gsl_sf_ellint_RJ_e(7ac17249d713d72d).(0.0, y, 1.0, 1.0 + n, mode, &rj);
557 result->valcxx . . $ gsl_sf_result_struct#val. = rf.valcxx . . $ gsl_sf_result_struct#val. - (n/3.0) * rj.valcxx . . $ gsl_sf_result_struct#val.;
558 result->errcxx . . $ gsl_sf_result_struct#err. = rf.errcxx . . $ gsl_sf_result_struct#err. + fabscxx . . $ fabs(447c67c6676f75c3).(n/3.0) * rj.errcxx . . $ gsl_sf_result_struct#err.;
559 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(rfstatus, rjstatus);
560 }
561 }
562
563
564
565 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
566
567 #include "gsl_specfunc__eval.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__eval.h`/
568
569 double gsl_sf_ellint_Kcompcxx . . $ gsl_sf_ellint_Kcomp(19d8e2eb71b44d09).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode)
570 {
571 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_Kcomp_e(k, mode, &result));
572 }
573
574 double gsl_sf_ellint_Ecompcxx . . $ gsl_sf_ellint_Ecomp(19d8e2eb71b44d09).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode)
575 {
576 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_Ecomp_e(k, mode, &result));
577 }
578
579 double gsl_sf_ellint_Pcompcxx . . $ gsl_sf_ellint_Pcomp(cf53bd735d2a50cb).(double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode)
580 {
581 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_Pcomp_e(k, n, mode, &result));
582 }
583
584 double gsl_sf_ellint_Dcompcxx . . $ gsl_sf_ellint_Dcomp(19d8e2eb71b44d09).(double k, gsl_mode_tcxx . . $ gsl_mode_t# mode)
585 {
586 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_Dcomp_e(k, mode, &result));
587 }
588
589 double gsl_sf_ellint_Fcxx . . $ gsl_sf_ellint_F(cf53bd735d2a50cb).(double phi, double k, gsl_mode_tcxx . . $ gsl_mode_t# mode)
590 {
591 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_F_e(phi, k, mode, &result));
592 }
593
594 double gsl_sf_ellint_Ecxx . . $ gsl_sf_ellint_E(cf53bd735d2a50cb).(double phi, double k, gsl_mode_tcxx . . $ gsl_mode_t# mode)
595 {
596 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_E_e(phi, k, mode, &result));
597 }
598
599 double gsl_sf_ellint_Pcxx . . $ gsl_sf_ellint_P(6f78d70b2927d97d).(double phi, double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode)
600 {
601 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_P_e(phi, k, n, mode, &result));
602 }
603
604 double gsl_sf_ellint_Dcxx . . $ gsl_sf_ellint_D(6f78d70b2927d97d).(double phi, double k, double n, gsl_mode_tcxx . . $ gsl_mode_t# mode)
605 {
606 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_D_e(phi, k, n, mode, &result));
607 }
608
609 double gsl_sf_ellint_RCcxx . . $ gsl_sf_ellint_RC(cf53bd735d2a50cb).(double x, double y, gsl_mode_tcxx . . $ gsl_mode_t# mode)
610 {
611 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_RC_e(x, y, mode, &result));
612 }
613
614 double gsl_sf_ellint_RDcxx . . $ gsl_sf_ellint_RD(6f78d70b2927d97d).(double x, double y, double z, gsl_mode_tcxx . . $ gsl_mode_t# mode)
615 {
616 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_RD_e(x, y, z, mode, &result));
617 }
618
619 double gsl_sf_ellint_RFcxx . . $ gsl_sf_ellint_RF(6f78d70b2927d97d).(double x, double y, double z, gsl_mode_tcxx . . $ gsl_mode_t# mode)
620 {
621 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_RF_e(x, y, z, mode, &result));
622 }
623
624 double gsl_sf_ellint_RJcxx . . $ gsl_sf_ellint_RJ(ac47983728c28a8).(double x, double y, double z, double p, gsl_mode_tcxx . . $ gsl_mode_t# mode)
625 {
626 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_ellint_RJ_e(x, y, z, p, mode, &result));
627 }