53 inline double simpson(
const double low,
const double high,
const uint32 n,
54 const std::function<
double(
double)>&
f) noexcept
56 const double width = (high - low) /
static_cast<double>(n);
58 double simpson_integral = 0.0;
59 for (
uint32 step = 0; step < n; ++step)
61 const double x1 = low +
static_cast<double>(step) * width;
62 const double x2 = low +
static_cast<double>(step + 1) * width;
64 simpson_integral += (x2 - x1) / 6.0 * (
f(x1) + 4.0 *
f(0.5 * (x1 + x2)) +
f(x2));
67 return simpson_integral;
double simpson(const double low, const double high, const uint32 n, const std::function< double(double)> &f) noexcept
Definition: simpson.hpp:53
dtype f(dtype inDofN, dtype inDofD)
Definition: f.hpp:56
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40