(rontolisp) docs
← Functions

linalg:gradient

(linalg:gradient samples &optional spacing)

Returns the numerical derivative of a vector of samples (numpy's np.gradient): second-order central differences at interior points and first-order one-sided differences at the two ends, so the result has the same length as the input (unlike linalg:diff). spacing is either a uniform sample spacing (a number, default 1) or a coordinate vector of the same length for non-uniformly spaced samples (numpy's second-order interior formula, exact for quadratics). Vectors only, with at least 2 samples; the result preserves the input's width.