58 romberg(
const double low,
const double high,
const uint8 n,
const std::function<
double(
double)>&
f)
65 double h = high - low;
66 for (
uint8 step = 1; step < n; step++)
71 double trapezoidal_integration = 0.0;
73 for (
uint32 tzStep = 1; tzStep <= stepEnd; ++tzStep)
75 const double deltaX = (2.0 *
static_cast<double>(tzStep - 1)) * h;
76 trapezoidal_integration +=
f(low + deltaX);
79 rombergIntegral(step, 0) = 0.5 * rombergIntegral(step - 1, 0);
80 rombergIntegral(step, 0) += trapezoidal_integration * h;
83 for (
uint8 rbStep = 1; rbStep <= step; ++rbStep)
86 rombergIntegral(step, rbStep) = k * rombergIntegral(step, rbStep - 1);
87 rombergIntegral(step, rbStep) -= rombergIntegral(step - 1, rbStep - 1);
88 rombergIntegral(step, rbStep) /= (k - 1.0);
92 return rombergIntegral.
back();
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2194
double romberg(const double low, const double high, const uint8 n, const std::function< double(double)> &f)
Definition: romberg.hpp:58
double trapazoidal(const double low, const double high, const uint32 n, const std::function< double(double)> &f) noexcept
Definition: trapazoidal.hpp:53
dtype f(GeneratorType &generator, dtype inDofN, dtype inDofD)
Definition: f.hpp:58
dtype power(dtype inValue, uint8 inPower) noexcept
Definition: Utils/power.hpp:48
Definition: Coordinate.hpp:45
std::uint8_t uint8
Definition: Types.hpp:42
std::uint32_t uint32
Definition: Types.hpp:40