bisection {spuRs} | R Documentation |
Applies the bisection algorithm to find x such that ftn(x) == x.
bisection(ftn, x.l, x.r, tol = 1e-09)
ftn |
the function. |
x.l |
is the lower starting point. |
x.r |
is the upper starting point. |
tol |
distance of successive iterations at which algorithm terminates. |
We assume that ftn is a function of a single variable.
Returns the value of x at which ftn(x) == x. If the function fails to converge within max.iter iterations, returns NULL.
Jones, O.D., R. Maillardet, and A.P. Robinson. 2009. An Introduction to Scientific Programming and Simulation, Using R. Chapman And Hall/CRC.
ftn5 <- function(x) return(log(x)-exp(-x))
bisection(ftn5, 1, 2, tol = 1e-6)