derivkit.utils.numerics module¶
Numerical utilities.
- derivkit.utils.numerics.central_difference_error_estimate(step_size: float, order: int = 1) float¶
Computes a general heuristic size of the first omitted term in central-difference stencils.
Uses the general pattern h^2 / ((order + 1) * (order + 2)) as a rule-of-thumb O(h^2) truncation-error scale.
- Parameters:
step_size – Grid spacing.
order – Derivative order (positive integer).
- Returns:
Estimated truncation error scale.
- derivkit.utils.numerics.relative_error(a: ndarray, b: ndarray) float¶
Computes the relative error metric between a and b.
This metric is defined as the maximum over all components of a and b of the absolute difference divided by the maximum of 1.0 and the absolute values of a and b.
- Parameters:
a – First array-like input.
b – Second array-like input.
- Returns:
The relative error metric as a float.