derivkit.calculus.hyper_hessian module#

Construct derivative tensors (“hyper-Hessians”) for scalar- or vector-valued functions.

derivkit.calculus.hyper_hessian.build_hyper_hessian(function: Callable[[ArrayLike], float | ndarray], theta0: NDArray[float64] | Sequence[float], *, order: int = 3, method: str | None = None, n_workers: int = 1, dk_init_kwargs: dict[str, Any] | None = None, **dk_diff_kwargs: Any) → NDArray[float64]#

Returns a derivative tensor (“hyper-Hessian”) of a function.

This function computes all partial derivatives of the requested order of a scalar- or vector-valued function with respect to its parameters, evaluated at a single point in parameter space. The resulting tensor is useful for higher-order Taylor expansions, non-Gaussian approximations, and sensitivity analyses beyond quadratic order.

Parameters:
  • function – Function to differentiate.

  • theta0 – 1D Parameter vector where the derivatives are evaluated.

  • order – Derivative order. An order of zero returns the function value evaluated at theta0.

  • method – Derivative method name or alias. If None, the derivkit.DerivativeKit default is used.

  • n_workers – Outer parallelism across output components (tensor outputs only).

  • dk_init_kwargs – Optional keyword arguments passed to derivkit.derivative_kit.DerivativeKit during initialization. This can include cache-related settings.

  • **dk_diff_kwargs – Additional keyword arguments passed to derivkit.derivative_kit.DerivativeKit.differentiate().

Returns:

Function value or derivative tensor evaluated at theta0. For order=0, the function value itself is returned. For positive derivative orders, order parameter axes are appended to the function output shape.

Raises:
  • ValueError – If theta0 is empty or order is negative.

  • TypeError – If function does not return a scalar or a vector.

  • FloatingPointError – If non-finite values are encountered.