derivkit.kit module

Provides the DerivativeKit class.

The class is essentially a wrapper for AdaptiveFitDerivative and FiniteDifferenceDerivative. The user must specify the function to differentiate and the central value at which the derivative should be evaluated. More details about available options can be found in the documentation of the methods.

Typical usage example:

>>>  derivative = DerivativeKit(function_to_differentiate, 1)
>>>  adaptive = derivative.adaptive.compute()

derivative is the derivative of function_to_differerentiate at value 1.

class derivkit.kit.DerivativeKit(function: Callable[[float], float], central_value: float)

Bases: object

Provides access to adaptive and finite difference derivative calculators.

adaptive

Adaptive polynomial fit-based derivative method.

Type:

:class:AdaptiveFitDerivative

finite

High-order finite difference stencil-based method.

Type:

:class:`` FiniteDifferenceDerivative``

Initialises the class based on function and central value.

Parameters:
  • function – The scalar or vector-valued function to differentiate.

  • central_value – The point at which the derivative is evaluated.

get_used_points(derivative_order: int = 1, n_workers=1)

Returns x and y points used in the adaptive fit (for component 0).

Parameters:
  • derivative_order – Order of the derivative to compute diagnostics for (default is 1).

  • n_workers (int, optional) – Number of worker to use in multiprocessing. Default is 1 (no multiprocessing).

Returns:

A tuple of np.ndarray.