stepx {pnd}R Documentation

Default step size at given points

Description

Compute an appropriate finite-difference step size based on the magnitude of x, derivation order, and accuracy order. If the function and its higher derivatives belong to the same order of magnitude, this step is near-optimal. For small x, returns a hard bound to prevent large machine-rounding errors.

Usage

stepx(x, deriv.order = 1, acc.order = 2, zero.tol = sqrt(.Machine$double.eps))

Arguments

x

Numeric vector or scalar: the point(s) at which the derivative is estimated. FUN(x) must be finite.

deriv.order

Integer or vector of integers indicating the desired derivative order, \mathrm{d}^m / \mathrm{d}x^m, for each element of x.

acc.order

Integer or vector of integers specifying the desired accuracy order for each element of x. The final error will be of the order O(h^{\mathrm{acc.order}}).

zero.tol

Small positive integer: if abs(x) >= zero.tol, then, the automatically guessed step size is relative (x multiplied by the step), unless an auto-selection procedure is requested; otherwise, it is absolute.

Value

A numeric vector of the same length as x with positive step sizes.

Examples

stepx(10^(-10:2))
stepx(10^(-10:2), deriv.order = 2, acc.order = 4)

[Package pnd version 0.1.0 Index]