Learn R Programming

pracma (version 1.4.5)

bisect: Rootfinding Through Bisection

Description

Finding roots of univariate functions in bounded intervals.

Usage

bisect(f, a, b, maxiter = 100, tol = .Machine$double.eps^0.5)

regulaFalsi(f, a, b, maxiter = 100, tol = .Machine$double.eps^0.5)

Arguments

f
Function or its name as a string.
a, b
interval end points.
maxiter
maximum number of iterations; default 100.
tol
absolute tolerance; default eps^(1/2)

Value

  • Return a list with components root, f.root, the function value at the found root, iter, the number of iterations done, and root, and the estimated accuracy estim.prec

Details

Well known root finding algorithms for real, univariate, continuous functions. Bisection works in any case if the function has opposite signs at the endpoints of the interval.

``Regula falsi'' combines bisection and secant methods. The so-called `Illinois' improvement is used.

References

Quarteroni, A., R. Sacco, and F. Saleri (2007). Numerical Mathematics. Second Edition, Springer-Verlag, Berlin Heidelberg.

See Also

ridders

Examples

Run this code
# Legendre polynomial of degree 5
lp5 <- c(63, 0, -70, 0, 15, 0)/8
f <- function(x) polyval(lp5, x)
bisect(f, 0.6, 1)       # 0.9061798453 correct to  9 decimals
regulaFalsi(f, 0.6, 1)  # 0.9061798459 correct to 10 decimals

Run the code above in your browser using DataLab