43 double *f,
double *x,
long n) {
45 double h1 = 0, h2 = 0, h3 = 0, h4, r1, r2, r3, r4, d1 = 0, d2 = 0, d3 = 0, c, s, integ, dinteg1, dinteg2;
48 if (!integral || !f || !x)
53 integ = e = s = c = r4 = 0;
64 for (i = 2; i <= k; i++) {
67 h2 = x[i - 1] - x[i - 2];
70 d3 = (f[i - 1] - f[i - 2]) / h2;
72 d1 = (f[i] - f[i - 1]) / h3;
78 r1 = (f[i + 1] - f[i]) / h4;
81 r2 = (r1 - d1) / (h4 + h3);
86 integ = h2 * (f[0] + h2 * (d3 / 2.0 - h2 * (d2 / 6 - (h2 + 2 * h3) * r3 / 12)));
87 s = -ipow3(h2) * (h2 * (3 * h2 + 5 * h4) + 10 * h3 * h1) / 60.0;
88 integral[i - 1] = integ;
95 r1 = (f[i + 1] - f[i]) / h4;
110 dinteg1 = h3 * ((f[i] + f[i - 1]) / 2 - h3 * h3 * (d2 + r2 + (h2 - h4) * r3) / 12.0);
111 c = ipow3(h3) * (2 * h3 * h3 + 5 * (h3 * (h4 + h2) + 2 * h4 * h2)) / 120;
113 s = (i == 2 ? 2 * c + s : c);
116 integral[i] = integ + dinteg1 + e + de1;
118 integral[i] = integ + dinteg2 + e + de2;
129 dinteg2 = h4 * (f[i + 1] - h4 * (r1 / 2 + h4 * (r2 / 6 + (2 * h3 + h4) * r3 / 12)));
130 de2 = s * r4 - ipow3(h4) * r4 * (h4 * (3 * h4 + 5 * h2) + 10 * h3 * (h2 + h3 + h4)) / 60;
145 integral[i] = integ + e;
int GillMillerIntegration(double *integral, double *error, double *f, double *x, long n)
Performs numerical integration using the Gill-Miller method.