Numerical Differentiation¶
- pathsim.optim.numerical.num_jac(func, x, r=0.001, tol=1e-08)[source]¶
Numerically computes the jacobian of the function ‘func’ by central differences.
The stepsize ‘h’ is adaptively computed as a relative perturbation ‘r’ with an absolute floor ‘tol’. The floor keeps the perturbation meaningful when components of ‘x’ are near zero, where a purely relative step would shrink below the floating point resolution of ‘func’ and the central difference would collapse to zero.
- Parameters:
- Returns:
jac – 2d jacobian array
- Return type:
array[array[float]]
- pathsim.optim.numerical.num_autojac(func)[source]¶
Wraps a function object such that it computes the jacobian of the function with respect to the first argument.
This is intended to compute the jacobian ‘jac(x, u, t)’ of the right hand side function ‘func(x, u, t)’ of numerical integrators with respect to ‘x’.
- Parameters:
func (callable) – function to wrap for jacobian
- Returns:
wrap_func – wrapped funtion as numerical jacobian of ‘func’
- Return type:
callable