derivative

emlib.mathlib.derivative(func, h=0)[source]

Return a function which is the derivative of the given func

NB: Calculated via complex step finite difference

To find the derivative at x, do:

derivative(func)(x)

VIA: https://codewords.recurse.com/issues/four/hack-the-derivative

Return type:

Callable[[Union[Rational, float]], float]