step.plugin {pnd} | R Documentation |
Plug-in step selection
Description
Plug-in step selection
Usage
step.plugin(
FUN,
x,
h0 = 1e-05 * max(abs(x), sqrt(.Machine$double.eps)),
max.rel.error = .Machine$double.eps^(7/8),
range = h0/c(10000, 1e-04),
cores = 1,
preschedule = getOption("pnd.preschedule", TRUE),
cl = NULL,
...
)
Arguments
FUN |
Function for which the optimal numerical derivative step size is needed. |
x |
Numeric scalar: the point at which the derivative is computed and the optimal step size is estimated. |
h0 |
Numeric scalar: initial step size, defaulting to a relative step of
slightly greater than .Machine$double.eps^(1/3) (or absolute step if |
max.rel.error |
Positive numeric scalar > 0 indicating the maximum relative
error of function evaluation. For highly accurate functions with all accurate bits
is equal to |
range |
Numeric vector of length 2 defining the valid search range for the step size. |
cores |
Integer specifying the number of CPU cores used for parallel computation. Recommended to be set to the number of physical cores on the machine minus one. |
preschedule |
Logical: if |
cl |
An optional user-supplied |
... |
Passed to FUN. |
Details
This function computes the optimal step size for central differences using the plug-in approach. The optimal step size is determined as the minimiser of the total error, which for central finite differences is (assuming minimal bounds for relative rounding errors)
\sqrt[3]{1.5 \frac{f'(x)}{f'''(x)} \epsilon_{\mathrm{mach}}}.
If the estimated third derivative is too small, the function assumes a third derivative of 1 to prevent division-by-zero errors.
Value
A list similar to the one returned by optim()
:
-
par
– the optimal step size found. -
value
– the estimated numerical first derivative (using central differences). -
counts
– the number of iterations (in this case, it is 2). -
abs.error
– an estimate of the truncation and rounding errors. -
exitcode
– an integer code indicating the termination status:-
0
– Termination with checks passed tolerance. -
1
– Third derivative is exactly zero; large step size preferred. -
2
– Third derivative is too close to zero; large step size preferred. -
3
– Solution lies at the boundary of the allowed value range.
-
-
message
– A summary message of the exit status. -
iterations
– A list including the two-step size search path, argument grids, function values on those grids, and estimated third derivative values.
References
There are no references for Rd macro \insertAllCites
on this help page.
Examples
f <- function(x) x^4
step.plugin(x = 2, f)
step.plugin(x = 0, f) # f''' = 0, setting a large one