fdm.numerics module¶
-
fdm.numerics.
approx_equal
(x, y, eps_abs=2.220446049250313e-14, eps_rel=1.4901161193847656e-08)[source]¶ Check whether x and y are approximately equal.
Let eps_z = eps_abs / eps_rel. Call x and y small if abs(x) < eps_z and abs(y) < eps_z, and call x and y large otherwise. If this function returns True, then it is guaranteed that abs(x - y) < 2 eps_rel max(abs(x), abs(y)) if x and y are large, and abs(x - y) < 2 eps_abs if x and y are small.
- Parameters
x (object) – First object to compare.
y (object) – Second object to compare.
eps_abs (float, optional) – Absolute tolerance.
eps_rel (float, optional) – Relative tolerance.
- Returns
Approximate equality of x and y.
- Return type
bool
-
fdm.numerics.
check_sensitivity
(f, s_f, args, kw_args=None, eps_abs=2.220446049250313e-12, eps_rel=1.4901161193847656e-07, method=<fdm.fdm.FDM object>)[source]¶ Check the sensitivity of a function.
- Parameters
f (function) – Function to check.
s_f (function) – Sensitivity of f. Should have signature s_f(s_y, y, *args, **kw_args), where s_y is the sensitivity of the output, y = f(*args, **kw_args), and *args and **kw_args the arguments and keyword arguments that f was evaluated at.
args (tuple) – Arguments to test f at.
kw_args (dict, optional) – Keyword arguments to test f at. Defaults to {}.
eps_abs (float, optional) – Absolute tolerance.
eps_rel (float, optional) – Relative tolerance.
method (
fdm.FDM
, optional) – Finite difference method to use. Defaults tomultivariate.default_adaptive_method
.