brentMin | R Documentation |
Brent's local minimisation
brentMin(
f,
interval,
lower = NA_real_,
upper = NA_real_,
tol = 1e-08,
maxiter = 200L,
trace = 0L
)
f |
A function to be minimised on an interval. |
interval |
A length-2 vector containing the end-points of the search interval. |
lower |
Scalar: the lower end point of the search interval. Not necessary if |
upper |
Scalar: the upper end point of the search interval. Not necessary if |
tol |
Small positive scalar: stopping criterion. The search stops when the
distance between the current candidate and the midpoint of the bracket is smaller than
the dynamic threshold |
maxiter |
Positive integer: the maximum number of iterations. |
trace |
Integer: 0, 1, or 2. Amount of tracing information on the optimisation progress
printed. |
This is an adaptation of the implementation by John Burkardt (currently available at [https://people.math.sc.edu/Burkardt/m_src/brent/brent.html](https://people.math.sc.edu/Burkardt/m_src/brent/brent.html)).
This function is similar to local_min
or R_zeroin2
-style logic, but with the
following additions: the number of iterations is tracked, and the algorithm stops when the
standard Brent criterion is met or if the maximum iteration count is reached.
The code stores the approximate final bracket width in estim.prec
, like in [uniroot()].
If the minimiser is pinned to an end point, estim.prec = NA
.
There are no preliminary iterations, unlike [brentZero()].
TODO: add preliminary iterations.
A list with the following elements:
Location of the minimum.
Function value at the minimuim location.
Total iteration count used.
Estimate of the final bracket size.
f <- function (x) (x - 1/3)^2
brentMin(f, c(0, 1), tol = 0.0001)
brentMin(function(x) x^2*(x-1), lower = 0, upper = 10, trace = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.