
Last chance! 50% off unlimited learning
Sale ends in
Golden Section Search (GSS) is a useful algorithm for minimising a
continuous univariate function
GSS(f, a, b, tol = 1e-08, maxitgss = 100L, ...)
A list object containing the following:
argmin
, the argument of f
that minimises f
funmin
, the minimum value of f
achieved at argmin
converged
, a logical indicating whether the convergence tolerance
was satisfied
iterations
, an integer indicating the number of search iterations
used
A function of one variable that returns a numeric value
A numeric of length 1 representing the lower endpoint of the search interval
A numeric of length 1 representing the upper endpoint of the
search interval; must be greater than a
A numeric of length 1 representing the tolerance used to determine when the search interval has been narrowed sufficiently for convergence
An integer of length 1 representing the maximum number of iterations to use in the search
Additional arguments to pass to f
This function is modelled after a MATLAB function written by Zarnowiec22;textualskedastic. The method assumes that there is one local minimum in this interval. The solution produced is also an interval, the width of which can be made arbitrarily small by setting a tolerance value. Since the desired solution is a single point, the midpoint of the final interval can be taken as the best approximation to the solution.
The premise of the method is to shorten the interval
If
If
One then chooses two new test points by replacing
goldsect
is similar to this function, but does
not allow the user to pass additional arguments to f
f <- function(x) (x - 1) ^ 2
GSS(f, a = 0, b = 2)
Run the code above in your browser using DataLab