39 return (fct(x + dx) - fct(x)) / dx;
56 return (fct(x + dx) - fct(x - dx)) / (2 * dx);
72 return (-3 * fct(x) + 4 * fct(x + dx) - fct(x + 2 * dx)) / (2 * dx);
88 return (3 * fct(x) - 4 * fct(x - dx) + fct(x - 2 * dx)) / (2 * dx);
104 return (-fct(x + 2 * dx) + 8 * fct(x + dx) - 8 * fct(x - dx) + fct(x - 2 * dx)) / (12 * dx);
std::uint32_t u32
32 bit unsigned integer
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for math utility
T estim_deriv_step(u32 order)
Estimate the best step size for numerical differentiation of given order.
T derivative_3point_forward(T x, T dx, std::function< T(T)> &&fct)
Compute the derivative of a function at x using a 3-point forward finite difference.
T derivative_3point_backward(T x, T dx, std::function< T(T)> &&fct)
Compute the derivative of a function at x using a 3-point backward finite difference.
T derivative_5point_midpoint(T x, T dx, std::function< T(T)> &&fct)
Compute the derivative of a function at x using a 5-point centered finite difference.
T derivative_upwind(T x, T dx, std::function< T(T)> &&fct)
Compute the derivative of a function at x using the upwind method.
T derivative_centered(T x, T dx, std::function< T(T)> &&fct)
Compute the derivative of a function at x using the centered difference method.