deriv#

torchspin.deriv(y_or_x, y=None)[source]#

Numerical derivative using central differences.

Parameters:
  • y_or_x (array_like) – Either y (if y is not provided), or the abscissa x.

  • y (array_like, optional) – Ordinate values. If None, y_or_x is treated as y with unit spacing.

Returns:

dydx (ndarray) – Derivative, same shape as y.

Return type:

ndarray

Notes

Uses first differences averaged at interior points, with one-sided differences at the endpoints (identical to EasySpin’s deriv.m).