Description Usage Arguments Details Value Examples
View source: R/bisection_method.R
The bisection method is an iterative root-finding method with linear convergence that does not use derivatives.
1 | bisection_method(f, x0, x1, tol = 1e-08)
|
f |
Univariate function to find root of |
x0 |
A point |
x1 |
A point larger than |
tol |
Tolerance for convergence. |
The bisection method finds the root of a univariate function f given two initial guesses x_0 and x_1 where x_0 < x_1 and sign(f(x_0)) = -sign(f(x_1)) by sequentially bisecting the interval (x_2 = (x_0 + x_1) / 2).
Convergence is guaranteed as long as f is continuous in the interval [x_0, x_1] and f(x_0) and f(x_1) have opposite signs
The algorithm terminates when:
the algorithm exceeds 1000 iterations,
the value of f is non-finite for an iterate (x_n),
the algorithm converges and |f(x_{n}) - f(x_{n + 1})| < tol.
A root of f
. If the algorithm does not converge, NA
is returned.
1 2 | bisection_method(cos, 0, pi)
bisection_method(function(x) x ^ 3 - x - 2, 1, 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.