derivkit.calculus_kit module#

Provides the CalculusKit class.

A wrapper around the calculus helpers that exposes gradient, Jacobian, Hessian, and higher-order derivative tensors.

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()
>>> hess_third = calc.hyper_hessian(order=3)
>>> hess_fourth = calc.hyper_hessian(order=4)
>>>
>>> jac = CalculusKit(
...     identity_function,
...     x0=np.array([1.0, 2.0]),
... ).jacobian()