Struct peroxide::numerical::root::RootFinder
source · pub struct RootFinder<F: Fn(AD) -> AD> { /* private fields */ }
Expand description
Structure for Root finding
Implementations§
source§impl<F: Fn(AD) -> AD> RootFinder<F>
impl<F: Fn(AD) -> AD> RootFinder<F>
sourcepub fn new(init: RootState, method: RootFind, f: F) -> Result<Self, RootError>
pub fn new(init: RootState, method: RootFind, f: F) -> Result<Self, RootError>
Create RootFinder
Default Options
- Times: 100
- Tolerance: 1e-10
Usage
extern crate peroxide;
use peroxide::fuga::*;
fn main() -> Result<(), RootError> {
let init = RootState::I(1f64, 3f64);
let mut a = RootFinder::new(init, Bisection, f)?;
let x = a.find_root()?;
x.print();
Ok(())
}
fn f(x: AD) -> AD {
x.powi(2) - 4f64
}
pub fn f(&self, x: AD) -> AD
sourcepub fn condition_number(&self) -> f64
pub fn condition_number(&self) -> f64
Condition number
sourcepub fn get_method(&self) -> RootFind
pub fn get_method(&self) -> RootFind
Get method
sourcepub fn check_find(&self) -> RootBool
pub fn check_find(&self) -> RootBool
Check if find root