33 if (!x || !y || !integral || n <= 1)
35 sum = y[n - 1] * x[n - 1] - y[0] * x[0];
36 for (i = 0; i < n - 1; i++)
37 sum += y[i] * x[i + 1] - y[i + 1] * x[i];
56 if (!x || !y || !integral || n <= 1)
59 for (i = 1; i < n; i++)
60 integral[i] = integral[i - 1] + (y[i] + y[i - 1]) * (x[i] - x[i - 1]) / 2;
long trapazoidIntegration1(double *x, double *y, long n, double *integral)
Computes the integral as a function of x using the trapezoidal rule.
long trapazoidIntegration(double *x, double *y, long n, double *integral)
Computes the integral of a dataset using the trapezoidal rule.