36 double simpson(
double from,
double to,
size_t intervals,
const F&
function)
39 double dx = (to - from) / intervals;
41 sum = 0.5 * (
function(from) +
function(to));
43 for (
size_t ix = 1; ix < intervals; ++ix, x+=dx)
47 for (
size_t ix = 0; ix < intervals; ++ix, x+=dx)
48 sum += 2 *
function(x);
50 return sum * dx / 3.0;
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
double simpson(double from, double to, size_t intervals, const F &function)
#define NS_MIA_END
conveniance define to end the mia namespace