Skip to main content

DerivativeSolver

Trait DerivativeSolver 

Source
pub trait DerivativeSolver {
    // Required methods
    fn config(&self) -> &SolverConfig;
    fn refine<G: Function1D>(
        &self,
        g: &mut G,
        accuracy: Real,
        state: Solver1DState,
    ) -> QlResult<Real>;

    // Provided methods
    fn solve<G: Function1D>(
        &self,
        g: G,
        accuracy: Real,
        guess: Real,
        step: Real,
    ) -> QlResult<Real> { ... }
    fn solve_bracketed<G: Function1D>(
        &self,
        g: G,
        accuracy: Real,
        guess: Real,
        x_min: Real,
        x_max: Real,
    ) -> QlResult<Real> { ... }
}
Expand description

A 1-D root finder that uses the function’s derivative (Newton and friends).

A separate contract from Solver1D: its refinement needs f', so it takes a Function1D rather than a bare value closure. It still reuses the shared bracketing helpers for the auto-bracketing and bracket-validation phases.

Required Methods§

Source

fn config(&self) -> &SolverConfig

The shared configuration (evaluation cap, domain bounds).

Source

fn refine<G: Function1D>( &self, g: &mut G, accuracy: Real, state: Solver1DState, ) -> QlResult<Real>

Refine an already-bracketed root of g to the given accuracy, with the bracket invariants documented on Solver1DState guaranteed by the driver (the derivative-solver analogue of Solver1D::solve_impl).

§Errors

Returns an error if the refinement exhausts the evaluation budget or the method cannot proceed (e.g. a pure Newton step leaves the bracket).

Provided Methods§

Source

fn solve<G: Function1D>( &self, g: G, accuracy: Real, guess: Real, step: Real, ) -> QlResult<Real>

Find a zero of g near guess, auto-bracketing in steps of step.

§Errors

Returns an error if accuracy <= 0, no bracket is found, or refine fails.

Source

fn solve_bracketed<G: Function1D>( &self, g: G, accuracy: Real, guess: Real, x_min: Real, x_max: Real, ) -> QlResult<Real>

Find a zero of g in the caller-supplied bracket [x_min, x_max].

§Errors

As for solve, plus the bracket-validation errors of the shared driver.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§