powered by
Use the bisection method to find real roots
bisection(f, a, b, tol = 0.001, m = 100)
function to locate a root for
the a bound of the search region
the b bound of the search region
the error tolerance
the maximum number of iterations
the real root found
The bisection method functions by repeatedly halving 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 stops if after m iterations.
a
b
tol
m
Other optimz: goldsect, gradient, hillclimbing(), newton(), sa(), secant()
goldsect
gradient
hillclimbing()
newton()
sa()
secant()
# NOT RUN { f <- function(x) { x^3 - 2 * x^2 - 159 * x - 540} bisection(f, 0, 10) # }
Run the code above in your browser using DataLab