fzero {pracma}R Documentation

Root Finding Algorithm

Description

Find root of continuous function of one variable.

Usage

fzero(fun, x, maxiter = 500, tol = 1e-12, ...)

Arguments

fun

function whose root is sought.

x

a point near the root or an interval giving end points.

maxiter

maximum number of iterations.

tol

relative tolerance.

...

additional arguments to be passed to the function.

Details

fzero tries to find a zero of f near x, if x is a scalar. Expands the interval until different signs are found at the endpoints or the maximum number of iterations is exceeded. If x is a vector of length two, fzero assumes x is an interval where the sign of x[1] differs from the sign of x[1]. An error occurs if this is not the case.

“This is essentially the ACM algorithm 748. The structure of the algorithm has been transformed non-trivially: it implement here a FSM version using one interior point determination and one bracketing per iteration, thus reducing the number of temporary variables and simplifying the structure.”

This approach will not find zeroes of quadratic order.

Value

fzero returns a list with

x

location of the root.

fval

function value at the root.

Note

fzero mimics the Matlab function of the same name, but is translated from Octave's fzero function, copyrighted (c) 2009 by Jaroslav Hajek.

References

Alefeld, Potra and Shi (1995). Enclosing Zeros of Continuous Functions. ACM Transactions on Mathematical Software, Vol. 21, No. 3.

See Also

uniroot, brent

Examples

fzero(sin, 3)                    # 3.141593
fzero(cos,c(1, 2))               # 1.570796
fzero(function(x) x^3-2*x-5, 2)  # 2.094551

[Package pracma version 2.4.4 Index]