pub fn find_root_regula_falsi<F, Func>(
    a: F,
    b: F,
    f: Func,
    convergency: &mut dyn Convergency<F>
) -> Result<F, SearchError>where
    F: FloatType,
    Func: FnMut(F) -> F,
Expand description

Find a root of the function f(x) = 0 using the Illinois modification of the regula falsi method.

Pro

  • Simple
  • Robust
  • No need for derivative function

Contra

  • Slow
  • Needs initial bracketing

Failures

NoBracketing

Initial values do not bracket the root.

NoConvergency

Algorithm cannot find a root within the given number of iterations.

Examples

use roots::SimpleConvergency;
use roots::find_root_regula_falsi;

let f = |x| { 1f64*x*x - 1f64 };
let mut convergency = SimpleConvergency { eps:1e-15f64, max_iter:30 };

let root1 = find_root_regula_falsi(10f64, 0f64, &f, &mut convergency);
// Returns approximately Ok(1);

let root2 = find_root_regula_falsi(-10f64, 0f64, &f, &mut 1e-15f64);
// Returns approximately Ok(-1);