| tf_derive | R Documentation |
Derivatives of tf-objects use finite differences of the evaluations for
tfd and finite differences of the basis functions for tfb.
tf_derive(f, arg, order = 1, ...)
## S3 method for class 'matrix'
tf_derive(f, arg, order = 1, ...)
## S3 method for class 'tfd'
tf_derive(f, arg = tf_arg(f), order = 1, ...)
## S3 method for class 'tfd_irreg'
tf_derive(f, arg, order = 1, ...)
## S3 method for class 'tfb_spline'
tf_derive(f, arg = tf_arg(f), order = 1, ...)
## S3 method for class 'tfb_fpc'
tf_derive(f, arg = tf_arg(f), order = 1, ...)
f |
a |
arg |
grid to use for the finite differences. |
order |
order of differentiation. Maximal value for |
... |
not used |
The derivatives of tfd objects use second-order accurate central differences
for interior points and second-order accurate one-sided differences at
boundaries, following the non-uniform grid formulas from numpy.gradient
with edge_order=2 (Fornberg, 1988).
Domain and grid of the returned object are identical to the input. Unless the
tfd has a rather fine and regular grid, representing the data in a suitable
basis representation with tfb() and then computing the derivatives (or
integrals) of those is usually preferable.
Note that, for spline bases like "cr" or "tp" which are constrained to
begin/end linearly, computing second derivatives will produce artefacts at
the outer limits of the functions' domain due to these boundary constraints.
Basis "bs" does not have this problem for sufficiently high orders (but
tends to yield slightly less stable fits).
a tf (with the same arg for tfd-inputs, possibly different
basis for tfb-inputs, see details).
tf_derive(matrix): row-wise finite differences
tf_derive(tfd): derivatives by finite differencing of function evaluations.
tf_derive(tfd_irreg): element-wise finite differencing for irregular grids.
Falls back to tf_derive.tfd (interpolating to a common grid) if an
explicit arg vector is supplied.
tf_derive(tfb_spline): derivatives by finite differencing of spline basis functions.
tf_derive(tfb_fpc): derivatives by finite differencing of FPC basis functions.
Fornberg, Bengt (1988). “Generation of Finite Difference Formulas on Arbitrarily Spaced Grids.” Mathematics of Computation, 51(184), 699–706.
Other tidyfun calculus functions:
tf_integrate()
arg <- seq(0, 1, length.out = 31)
x <- tfd(rbind(arg^2, sin(2 * pi * arg)), arg = arg)
dx <- tf_derive(x)
x
dx
tf_arg(dx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.