Low-level function to compute numerical derivatives of arbitrary order using finite difference methods.
Usage
differentiate(x, dt, method = c("central", "forward", "backward"), order = 1L)Value
Differentiated data with same dimensions as input. Boundary values where the stencil cannot be applied are set to NA.
Details
For method = "central" with order = 1:
$$f'(i) = (x[i+1] - x[i-1]) / (2 \cdot dt)$$
For method = "central" with order = 2:
$$f''(i) = (x[i+1] - 2 x[i] + x[i-1]) / dt^2$$
For higher orders, the derivative is computed by repeated application of the first-order formula.
References
Winter DA (2009). "Biomechanics and Motor Control of Human Movement." 4th ed. John Wiley & Sons.
See also
computeVelocity() for computing velocity from PhysioExperiment,
computeAcceleration() for second-order derivatives,
savgolFilter() for smoothed differentiation via Savitzky-Golay.