33 double a,
double b,
int N)
37 double h = (b -
a) / (N - 1);
39 for (
int i = 0;
i < N;
i++)
40 fx(
i) = (*f)(a +
i * h);
44 return h / 2*(fx(0) + fx(1));
46 return h / 3*(fx(0) + 4*fx(1) + fx(2));
48 return h*3.0 / 8.0*((fx(0) + fx(3)) + 3*(fx(1) + fx(2)));
50 return h*2.0 / 45.0*(7*(fx(0) + fx(4)) + 32*(fx(1) + fx(3)) + 12*fx(2));
52 return h*5.0 / 288.0*(19*(fx(0) + fx(5)) + 75*(fx(1) + fx(4)) + 50*(fx(2) + fx(3)));
54 return h / 140.0*(41*(fx(0) + fx(6)) + 216*(fx(1) + fx(5)) + 27*(fx(2) + fx(4)) +
57 return h*7.0 / 17280.0*(751*(fx(0) + fx(7)) + 3577*(fx(1) + fx(6)) + 1323*(fx(2) + fx(5)) +
58 2989*(fx(3) + fx(4)));
60 return 4.0 / 14175.0*h*(989*(fx(0) + fx(8)) + 5888*(fx(1) + fx(7)) +
61 -928*(fx(2) + fx(6)) + 10496*(fx(3) + fx(5)) - 4540*fx(4));
76 for (j = 1;j <= JMAX;j++)
79 if (fabs(s_internal - olds) <= EPS*fabs(olds))
81 if (s_internal == 0.0 && olds == 0.0 && j > 6)
103 return (s *= 0.5 * (b - a));
107 for (it = 1, j = 1;j < n - 1;j++)
112 for (sum = 0.0, j = 1;j <= it;j++, x +=
del)
114 s = 0.5 * (s + (b - a) * sum / tnm);
130 std::array<double, JMAXP+2> h;
131 std::array<double, JMAXP+2> s_internal;
133 for (j = 1;j <=
JMAXP;j++)
135 s_internal[
j] = midpnt(j);
138 polint(&h[j-K], &s_internal[j-K], K, 0.0, ss, dss);
139 if (fabs(dss) <= EPS*fabs(ss))
142 s_internal[j+1] = s_internal[
j];
162 return (s = (b - a) * func());
166 for (it = 1, j = 1;j < n - 1;j++)
169 del = (b - a) / (3.0 * tnm);
173 for (j = 1;j <= it;j++)
180 s = (s + (b - a) * sum / tnm) / 3.0;
#define REPORT_ERROR(nerr, ErrormMsg)
double integrateNewtonCotes(double(*f)(double), double a, double b, int N)
Incorrect argument received.
Error related to numerical calculation.
void polint(double *xa, double *ya, int n, double x, double &y, double &dy)
virtual double operator()()
virtual double operator()()
Incorrect value received.