Derivatives of tf-objects use finite differences of the evaluations for tfd and finite differences of the basis functions for tfb.

tf_derive(f, order = 1, arg = NULL, ...)

# S3 method for matrix
tf_derive(f, order = 1, arg = NULL, ...)

# S3 method for tfd
tf_derive(f, order = 1, arg = NULL, ...)

# S3 method for tfb_spline
tf_derive(f, order = 1, arg = NULL, ...)

# S3 method for tfb_fpc
tf_derive(f, order = 1, arg = NULL, ...)



a tf-object


order of differentiation. Maximal value for tfb_spline is 2.


grid to use for the finite differences. Not the arg of the returned object for tfd-inputs, see Details.


not used


a tf (with slightly different arg or basis for the derivatives, see Details)


The derivatives of tfd objects use centered finite differences, e.g. for first derivatives \(f'((t_i + t_{i+1})/2) \approx \frac{f(t_i) + f(t_{i+1})}{t_{i+1} - t_i}\), so the domains of differentiated tfd will shrink (slightly) at both ends. 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 some spline bases like "cr" or "tp" which always 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.

Methods (by class)

  • matrix: row-wise finite differences

  • tfd: derivatives by finite differencing.

  • tfb_spline: derivatives by finite differencing.

  • tfb_fpc: derivatives by finite differencing.