52 simpson(
const double low,
const double high,
const uint32 n,
const std::function<
double(
double)>&
f)
noexcept
54 const double width = (high - low) /
static_cast<double>(n);
56 double simpson_integral = 0.;
57 for (
uint32 step = 0; step < n; ++step)
59 const double x1 = low +
static_cast<double>(step) * width;
60 const double x2 = low +
static_cast<double>(step + 1) * width;
62 simpson_integral += (x2 - x1) / 6. * (
f(x1) + 4. *
f(0.5 * (x1 + x2)) +
f(x2));
65 return simpson_integral;
Definition: gauss_legendre.hpp:43
double simpson(const double low, const double high, const uint32 n, const std::function< double(double)> &f) noexcept
Definition: simpson.hpp:52
dtype f(GeneratorType &generator, dtype inDofN, dtype inDofD)
Definition: f.hpp:56
std::uint32_t uint32
Definition: Types.hpp:40