Learn R Programming

spuRs (version 2.0.0)

bisection: A function of the bisection algorithm.

Description

Applies the bisection algorithm to find x such that ftn(x) == x.

Usage

bisection(ftn, x.l, x.r, tol = 1e-09)

Arguments

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.

Value

Returns the value of x at which ftn(x) == x. If the function fails to converge within max.iter iterations, returns NULL.

Details

We assume that ftn is a function of a single variable.

References

Jones, O.D., R. Maillardet, and A.P. Robinson. 2009. An Introduction to Scientific Programming and Simulation, Using R. Chapman And Hall/CRC.

See Also

newtonraphson, fixedpoint

Examples

Run this code
ftn5 <- function(x) return(log(x)-exp(-x))
bisection(ftn5, 1, 2, tol = 1e-6)

Run the code above in your browser using DataLab