:orphan: :mod:`atsim.potentials._util` ============================= .. py:module:: atsim.potentials._util Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: atsim.potentials._util.deriv atsim.potentials._util.num_deriv atsim.potentials._util.gradient .. function:: deriv(r, func, h=1e-06) Evaluates the derivative of a unary callable, `func` at a value of `r`. If the object `func` has a unary method `deriv(r)`, this will be used to evauluate the derivative (allowing analytical derivatives to be used). If `func` does not have a specific `deriv(r)` method then its numerical-derivative of will be taken by calling num_deriv() :param r: Value at which derivative of `func` should be evaluated. :param func: Function whose derivative is to be evaluated. :param h: Step size used when performing numerical differentiation. :return: Derivative of func at `r`. .. function:: num_deriv(r, func, h=1e-06) Returns numerical derivative of the callable `func` :param r: Value at which derivative of `func` should be evaluated. :param func: Function whose gradient is to be evaluated. :param h: Step size used when performing numerical differentiation. :return: Numerical derivative of func at `r`. .. function:: gradient(func, h=1e-06) Function wrapper that returns derivative of func. If the callable, `func` provides a `.deriv(r)` method this will be used to evaluate the derivative of the function, if not the returned function will use num_deriv() in gradient evaluation. If the callable additionally provides a `.deriv2(r)` method, representing its second derivative, the function returned by this routine will have a `deriv()` method which will delegate to func.deriv2() when called. By providing .deriv() and .deriv2() on the `func` callable analytical descriptions of a potential's first and second derivatives may be specified. :param func: Function to be wrapped :param h: Step size used when performing numerical differentiation :return: Function that returns derivative of func