Compute numerical derivatives on possibly uneven grids
Source:R/differentiate.R
compute_gradient.RdThis helper implements a finite-difference scheme based on the Fornberg formula for interior points when the spacing between coordinates is non-uniform. End points use first-order forward/backward differences.
Value
A numeric vector of the same length as values containing the
estimated first derivative at each point.
References
Fornberg, B. (1988). Generation of finite difference formulas on arbitrarily spaced grids. Mathematics of Computation, 51(184), 699-706. doi:10.1090/S0025-5718-1988-0935077-0