gradient

gradient(f, x)

Take the gradient of a function of a parameter vector.

Parameters

Name Type Description Default
f callable A function taking a numeric vector and returning one number. required
x array_like The point to differentiate at. required

Returns

Name Type Description
numpy.ndarray The gradient, the length of x.

Examples

>>> import corehydropy as ch
>>> ch.gradient(lambda p: (1 - p[0])**2 + 100 * (p[1] - p[0]**2)**2, [1.0, 1.0]).round(6)
array([-0.,  0.])