Skip to main content

secant_method

Function secant_method 

Source
pub fn secant_method<F>(
    f: F,
    x0: f64,
    x1: f64,
    tol: f64,
) -> Result<f64, ErrorsJSL>
where F: Fn(f64) -> f64,
Expand description

Finds a root of f with the secant method starting from x0 and x1.

Stops when f is exactly zero, or successive iterates differ by less than tol and either f changes sign between them or their own secant slope places the root within tol. Errors on a zero secant slope, divergence, or 100 iterations without convergence. The order of convergence near a simple root is the golden ratio, 1.618.