#include
#include
#include
#include
/* Test function */
double func(double x) {
return x*x*(x*x-2.0)*sin(x);
}
/* Integral of test function */
double fint(double x) {
return 4.0*x*(x*x-7.0)*sin(x)-(pow(x,4.0)-14.0*x*x+28.0)*cos(x);
}
int main() {
double xi=0.0,xf=M_PI/2,s;
int numpoints = 36;
array double x[numpoints], y[numpoints];
class CPlot plot;
linspace(x, xi, xf);
fevalarray(y, func, x);
printf("Actual value of the integration is %12.6lf\n",fint(xf)-fint(xi));
s=integral1(func,xi,xf);
printf("Result from the function integration is %11.6lf\n",s);
plot.Data2D(x, y);
plot.Data2D(x, y);
plot.PlotType(PLOT_PLOTTYPE_IMPULSES, 1);
plot.Plotting();
}
Actual value of integraion is -0.479159
Result from the function integration is -0.479158