Learn R Programming

kmconfband (version 0.1)

zbrent: Van Wijngaarden-Decker-Brent Root-finding Algorithm

Description

The function zbrent searches the interval int for a root, i.e., a zero, with respect to the first argument of a one-dimensional user-supplied function func.

Usage

zbrent(func,int,tol)

Arguments

func
the function for which the root is sought
int
a vector representing the interval in which the required root is located
tol
the desired accuracy (convergence tolerance)

Value

The algorithm returns the required root unless there is none, or the algorithm exceeds 100 iterations. In the latter case, an error message is displayed, and the current approximation is returned.

Details

The values of func at the two endpoints of int must have opposite signs.

References

Press W.H., Flannery B.P., Teukolsky S.A., Vetterling W.T. (1988) Numerical Recipes: The Art of Scientific Computing. Cambridge: Cambridge University Press.

See Also

confband, exact

Examples

Run this code
f<-function(x) x*(x^2-1)+0.5
x<-seq(-2,2,length=100)
plot(x,f(x),type="l")
zbrent(f,c(-2,2),1.0e-10)

Run the code above in your browser using DataLab