Description Usage Arguments Details Value Examples
View source: R/secant_method.R
The secant method is an iterative root-finding method with order of convergence phi (1.618...) that does not use derivatives.
1 | secant_method(f, x0, x1, tol = 1e-08)
|
f |
Univariate function to find root of |
x0 |
A point close to the root of |
x1 |
A point close to the root of |
tol |
Tolerance for convergence. |
The secant method finds the root of a univariate function f given two initial guesses x_0 and x_1 by the iteration:
x_{n + 1} = x_n - f(x_n) \frac{x_n - x_{n - 1}}{f(x_n) - f(x_{n - 1})}
.
The algorithm terminates when:
the algorithm exceeds 1000 iterations,
the value of f is non-finite for an iterate (x_n),
the iterate (x_n) becomes non-finite, or
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 | secant_method(cos, 0, 1)
secant_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.