Last chance! 50% off unlimited learning
Sale ends in
Use golden section search to find local extrema
goldsectmin(f, a, b, tol = 0.001, m = 100)goldsectmax(f, a, b, tol = 0.001, m = 100)
function to integrate
the a bound of the search region
the b bound of the search region
the error tolerance
the maximum number of iterations
the x
value of the minimum found
The golden section search method functions by repeatedly dividing the interval
between a
and b
and will return when the
interval between them is less than tol
, the error tolerance.
However, this implementation also stop if after m
iterations.
Other optimz:
bisection()
,
gradient
,
hillclimbing()
,
newton()
,
sa()
,
secant()
# NOT RUN {
f <- function(x) { x^2 - 3 * x + 3 }
goldsectmin(f, 0, 5)
# }
Run the code above in your browser using DataLab