simpsons

double simpsons(Function func, double a, double b, double tol, int nmax);

Returns an approximation to the integral of the function func from a to b. The relative error of the approximation is no more than tol. nmax is the maximum number of iteration to perform to reach this error level. Integration is performed using Simpson's rule.

Parameters:
funcFunction to integrate.
aLower bound of integration.
bUpper bound of integration.
tolMaximum error tolerance.
nmaxMaximum number of iterations.

Returns:
Integral of func from a to b.

Usage:
double sine(double x) { return sin(x); }
double s = simpsons(sine, 0.0, 3.14, 5e-10, 20);

Header:
#include "integrate.h"

See Also:
Function