gradient#
- rateslib.dual.gradient(dual, vars=None, order=1, keep_manifold=False)#
Return derivatives of a dual number.
- Parameters:
dual (Dual or Dual2) – The dual variable from which to derive derivatives.
vars (str, tuple, list optional) – Name of the variables which to return gradients for. If not given defaults to all vars attributed to the instance.
order ({1, 2}) – Whether to return the first or second derivative of the dual number. Second order will raise if applied to a
Dual
and notDual2
instance.keep_manifold (bool) – If
order
is 1 and the type isDual2
one can return aDual2
where thedual2
values are converted todual
values to represent a first order manifold of the first derivative (and thedual2
values set to zero). Useful for propagation in iterations.
- Return type:
float, ndarray, Dual2