Computes the first derivative of a function at selected points using the
forward difference, backward difference, or centred difference. A regularly
spaced grid with corresponding values of the function must be available,
as well as a subset of the same grid points at which the derivative must
be calculated. For forward and backward differences, the last, respectively
the derivative cannot be calculated at the first or last grid point. For
centred difference it cannot be calculated at both first and last grid point.
Usage
deriv_reg(x0, x, f, scheme = "c")
Value
A vector of real numbers. These are the numeric approximations to the
first derivative of the function at all values in x0.
Arguments
x0
A numeric vector. Values at which the derivative is computed.
Must be an exact subset of x. Approximated values of
x will not be accepted.
x
A numeric vector. Regular grid points where the function is tabulated.
f
A numeric vector. Tabulated values of the function at grid x.
scheme
A one-letter character indicating which difference to use.
Possible values are "c", "f", "b" for centred, forward and
backward, respectively.