23 #ifndef O2SCL_INTE_QNG_GSL_H
24 #define O2SCL_INTE_QNG_GSL_H
30 #include <o2scl/string_conv.h>
31 #include <o2scl/inte.h>
32 #include <o2scl/inte_gsl.h>
33 #include <o2scl/funct.h>
48 static const double x1[5] = {
49 0.973906528517171720077964012084452,
50 0.865063366688984510732096688423493,
51 0.679409568299024406234327365114874,
52 0.433395394129247190799265943165784,
53 0.148874338981631210884826001129720
57 static const double w10[5] = {
58 0.066671344308688137593568809893332,
59 0.149451349150580593145776339657697,
60 0.219086362515982043995534934228163,
61 0.269266719309996355091226921569469,
62 0.295524224714752870173892994651338
66 static const double x2[5] = {
67 0.995657163025808080735527280689003,
68 0.930157491355708226001207180059508,
69 0.780817726586416897063717578345042,
70 0.562757134668604683339000099272694,
71 0.294392862701460198131126603103866
75 static const double w21a[5] = {
76 0.032558162307964727478818972459390,
77 0.075039674810919952767043140916190,
78 0.109387158802297641899210590325805,
79 0.134709217311473325928054001771707,
80 0.147739104901338491374841515972068
84 static const double w21b[6] = {
85 0.011694638867371874278064396062192,
86 0.054755896574351996031381300244580,
87 0.093125454583697605535065465083366,
88 0.123491976262065851077958109831074,
89 0.142775938577060080797094273138717,
90 0.149445554002916905664936468389821
94 static const double x3[11] = {
95 0.999333360901932081394099323919911,
96 0.987433402908088869795961478381209,
97 0.954807934814266299257919200290473,
98 0.900148695748328293625099494069092,
99 0.825198314983114150847066732588520,
100 0.732148388989304982612354848755461,
101 0.622847970537725238641159120344323,
102 0.499479574071056499952214885499755,
103 0.364901661346580768043989548502644,
104 0.222254919776601296498260928066212,
105 0.074650617461383322043914435796506
109 static const double w43a[10] = {
110 0.016296734289666564924281974617663,
111 0.037522876120869501461613795898115,
112 0.054694902058255442147212685465005,
113 0.067355414609478086075553166302174,
114 0.073870199632393953432140695251367,
115 0.005768556059769796184184327908655,
116 0.027371890593248842081276069289151,
117 0.046560826910428830743339154433824,
118 0.061744995201442564496240336030883,
119 0.071387267268693397768559114425516
123 static const double w43b[12] = {
124 0.001844477640212414100389106552965,
125 0.010798689585891651740465406741293,
126 0.021895363867795428102523123075149,
127 0.032597463975345689443882222526137,
128 0.042163137935191811847627924327955,
129 0.050741939600184577780189020092084,
130 0.058379395542619248375475369330206,
131 0.064746404951445885544689259517511,
132 0.069566197912356484528633315038405,
133 0.072824441471833208150939535192842,
134 0.074507751014175118273571813842889,
135 0.074722147517403005594425168280423
139 static const double x4[22] = {
140 0.999902977262729234490529830591582,
141 0.997989895986678745427496322365960,
142 0.992175497860687222808523352251425,
143 0.981358163572712773571916941623894,
144 0.965057623858384619128284110607926,
145 0.943167613133670596816416634507426,
146 0.915806414685507209591826430720050,
147 0.883221657771316501372117548744163,
148 0.845710748462415666605902011504855,
149 0.803557658035230982788739474980964,
150 0.757005730685495558328942793432020,
151 0.706273209787321819824094274740840,
152 0.651589466501177922534422205016736,
153 0.593223374057961088875273770349144,
154 0.531493605970831932285268948562671,
155 0.466763623042022844871966781659270,
156 0.399424847859218804732101665817923,
157 0.329874877106188288265053371824597,
158 0.258503559202161551802280975429025,
159 0.185695396568346652015917141167606,
160 0.111842213179907468172398359241362,
161 0.037352123394619870814998165437704
165 static const double w87a[21] = {
166 0.008148377384149172900002878448190,
167 0.018761438201562822243935059003794,
168 0.027347451050052286161582829741283,
169 0.033677707311637930046581056957588,
170 0.036935099820427907614589586742499,
171 0.002884872430211530501334156248695,
172 0.013685946022712701888950035273128,
173 0.023280413502888311123409291030404,
174 0.030872497611713358675466394126442,
175 0.035693633639418770719351355457044,
176 0.000915283345202241360843392549948,
177 0.005399280219300471367738743391053,
178 0.010947679601118931134327826856808,
179 0.016298731696787335262665703223280,
180 0.021081568889203835112433060188190,
181 0.025370969769253827243467999831710,
182 0.029189697756475752501446154084920,
183 0.032373202467202789685788194889595,
184 0.034783098950365142750781997949596,
185 0.036412220731351787562801163687577,
186 0.037253875503047708539592001191226
190 static const double w87b[23] = {
191 0.000274145563762072350016527092881,
192 0.001807124155057942948341311753254,
193 0.004096869282759164864458070683480,
194 0.006758290051847378699816577897424,
195 0.009549957672201646536053581325377,
196 0.012329447652244853694626639963780,
197 0.015010447346388952376697286041943,
198 0.017548967986243191099665352925900,
199 0.019938037786440888202278192730714,
200 0.022194935961012286796332102959499,
201 0.024339147126000805470360647041454,
202 0.026374505414839207241503786552615,
203 0.028286910788771200659968002987960,
204 0.030052581128092695322521110347341,
205 0.031646751371439929404586051078883,
206 0.033050413419978503290785944862689,
207 0.034255099704226061787082821046821,
208 0.035262412660156681033782717998428,
209 0.036076989622888701185500318003895,
210 0.036698604498456094498018047441094,
211 0.037120549269832576114119958413599,
212 0.037334228751935040321235449094698,
213 0.037361073762679023410321241766599
217 #ifndef DOXYGEN_NO_O2NS
285 double &res,
double &err2) {
291 double res10, res21, res43, res87;
293 double result_kronrod, err;
302 double fv1[5], fv2[5], fv3[5], fv4[5];
304 const double half_length = 0.5 * (b - a);
305 const double abs_half_length = fabs(half_length);
306 const double center = 0.5 * (b + a);
309 f_center=func(center);
311 double dbl_eps=std::numeric_limits<double>::epsilon();
314 this->
tol_rel < min_rel_tol)) {
319 std::string estr=((std::string)
"Tolerance cannot be achieved ")+
322 ", in inte_qng_gsl::integ_err().";
333 for(
int k=0; k < 5; k++) {
336 fval1=func(center+abscissa);
337 fval2=func(center-abscissa);
338 const double fval = fval1 + fval2;
342 (fabs(fval1) + fabs(fval2));
348 for(
int k=0; k < 5; k++) {
351 fval1=func(center+abscissa);
352 fval2=func(center-abscissa);
353 const double fval = fval1 + fval2;
356 (fabs(fval1) + fabs(fval2));
357 savfun[k + 5] = fval;
362 resabs *= abs_half_length;
365 const double mean = 0.5 * res21;
369 for(
int k=0; k < 5; k++) {
370 resasc+=(fabs(fv1[k]-mean)+fabs(fv2[k]-mean))*
372 +(fabs(fv3[k]-mean)+fabs(fv4[k]-mean))*
375 resasc*=abs_half_length;
380 result_kronrod = res21 * half_length;
381 err =
rescale_error ((res21 - res10) * half_length, resabs, resasc);
384 std::cout <<
"inte_qng_gsl Iter: " << 1;
385 std::cout.setf(std::ios::showpos);
386 std::cout <<
" Res: " << result_kronrod;
387 std::cout.unsetf(std::ios::showpos);
389 double ttol=this->
tol_rel * fabs(result_kronrod);
392 std::cout <<
" Err: " << err
393 <<
" Tol: " << ttol << std::endl;
396 std::cout <<
"Press a key and type enter to continue. " ;
401 if (err < this->
tol_abs || err < this->
tol_rel * fabs(result_kronrod)) {
402 res = result_kronrod;
412 for(
int k=0; k < 10; k++) {
416 for(
int k=0; k < 11; k++) {
419 fval1=func(center+abscissa);
420 fval2=func(center-abscissa);
421 const double fval = fval1+fval2;
423 savfun[k + 10] = fval;
428 result_kronrod = res43 * half_length;
429 err =
rescale_error ((res43 - res21) * half_length, resabs, resasc);
432 std::cout <<
"inte_qng_gsl Iter: " << 2;
433 std::cout.setf(std::ios::showpos);
434 std::cout <<
" Res: " << result_kronrod;
435 std::cout.unsetf(std::ios::showpos);
437 double ttol=this->
tol_rel * fabs(result_kronrod);
440 std::cout <<
" Err: " << err
441 <<
" Tol: " << ttol << std::endl;
444 std::cout <<
"Press a key and type enter to continue. " ;
449 if (err < this->
tol_abs || err < this->
tol_rel * fabs(result_kronrod)) {
450 res = result_kronrod;
460 for(
int k=0; k < 21; k++) {
464 for(
int k=0; k < 22; k++) {
467 fval1=func(center+abscissa);
468 fval2=func(center-abscissa);
474 result_kronrod = res87 * half_length;
475 err =
rescale_error ((res87 - res43) * half_length, resabs, resasc);
478 std::cout <<
"inte_qng_gsl Iter: " << 3;
479 std::cout.setf(std::ios::showpos);
480 std::cout <<
" Res: " << result_kronrod;
481 std::cout.unsetf(std::ios::showpos);
483 double ttol=this->
tol_rel * fabs(result_kronrod);
486 std::cout <<
" Err: " << err
487 <<
" Tol: " << ttol << std::endl;
490 std::cout <<
"Press a key and type enter to continue. " ;
495 if (err < this->
tol_abs || err < this->
tol_rel * fabs(result_kronrod)) {
496 res = result_kronrod;
504 res = result_kronrod;
508 std::string estr=
"Failed to reach tolerance ";
509 estr+=
"in inte_qng_gsl::integ_err().";
514 const char *
type() {
return "inte_qng_gsl"; }
518 #ifndef DOXYGEN_NO_O2NS