pub struct Solver1d {
pub tol: f64,
pub max_iter: usize,
}Expand description
A 1-D root finder: residual tolerance plus an iteration cap.
Fields§
§tol: f64Convergence tolerance on |f(x)|.
max_iter: usizeMaximum number of iterations.
Implementations§
Source§impl Solver1d
impl Solver1d
pub fn new(tol: f64, max_iter: usize) -> Self
Sourcepub fn bisection(
&self,
f: impl Fn(f64) -> f64,
lo: f64,
hi: f64,
) -> Result<Root, RustyQLibError>
pub fn bisection( &self, f: impl Fn(f64) -> f64, lo: f64, hi: f64, ) -> Result<Root, RustyQLibError>
Bisection on a sign-changing bracket.
Sourcepub fn newton_raphson(
&self,
f: impl Fn(f64) -> f64,
df: impl Fn(f64) -> f64,
x0: f64,
) -> Root
pub fn newton_raphson( &self, f: impl Fn(f64) -> f64, df: impl Fn(f64) -> f64, x0: f64, ) -> Root
Newton-Raphson with an analytic derivative.
Sourcepub fn secant(&self, f: impl Fn(f64) -> f64, x0: f64, x1: f64) -> Root
pub fn secant(&self, f: impl Fn(f64) -> f64, x0: f64, x1: f64) -> Root
Secant from two starting points.
Sourcepub fn halley(
&self,
f: impl Fn(f64) -> f64,
df: impl Fn(f64) -> f64,
d2f: impl Fn(f64) -> f64,
x0: f64,
) -> Root
pub fn halley( &self, f: impl Fn(f64) -> f64, df: impl Fn(f64) -> f64, d2f: impl Fn(f64) -> f64, x0: f64, ) -> Root
Halley with analytic first and second derivatives.
Sourcepub fn newton_safeguarded(
&self,
f: impl Fn(f64) -> f64,
df: impl Fn(f64) -> f64,
lo: f64,
hi: f64,
x0: f64,
) -> Root
pub fn newton_safeguarded( &self, f: impl Fn(f64) -> f64, df: impl Fn(f64) -> f64, lo: f64, hi: f64, x0: f64, ) -> Root
Sourcepub fn solve(
&self,
method: Method,
problem: &Problem<'_>,
) -> Result<Root, RustyQLibError>
pub fn solve( &self, method: Method, problem: &Problem<'_>, ) -> Result<Root, RustyQLibError>
Solve problem with the chosen Method.
Derivatives the problem does not carry are approximated by central
finite differences, so Newton/Halley run on derivative-free
problems too. Bisection and NewtonSafeguarded require a
bracket and error without one.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Solver1d
impl RefUnwindSafe for Solver1d
impl Send for Solver1d
impl Sync for Solver1d
impl Unpin for Solver1d
impl UnsafeUnpin for Solver1d
impl UnwindSafe for Solver1d
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more