derivkit.calculus_kit module#
Provides the CalculusKit class.
A wrapper around the calculus helpers that exposes the gradient, Jacobian, and Hessian functions.
Typical usage examples:
>>> import numpy as np
>>> from derivkit import CalculusKit
>>>
>>> def sin_function(x):
... # scalar-valued function: f(x) = sin(x[0])
... return np.sin(x[0])
>>>
>>> def identity_function(x):
... # vector-valued function: f(x) = x
... return np.asarray(x, dtype=float)
>>>
>>> calc = CalculusKit(sin_function, x0=np.array([0.5]))
>>> grad = calc.gradient()
>>> hess = calc.hessian()
>>>
>>> jac = CalculusKit(identity_function, x0=np.array([1.0, 2.0])).jacobian()