pub struct RootFSolverType { /* private fields */ }
Expand description
The root bracketing algorithms described in this section require an initial interval which is guaranteed to contain a root—if a and b are the endpoints of the interval then f (a) must differ in sign from f (b). This ensures that the function crosses zero at least once in the interval. If a valid initial interval is used then these algorithm cannot fail, provided the function is well-behaved. Note that a bracketing algorithm cannot find roots of even degree, since these do not cross the x-axis.
Implementations
sourceimpl RootFSolverType
impl RootFSolverType
sourcepub fn bisection() -> RootFSolverType
pub fn bisection() -> RootFSolverType
The bisection algorithm is the simplest method of bracketing the roots of a function. It is the slowest algorithm provided by the library, with linear convergence. On each iteration, the interval is bisected and the value of the function at the midpoint is calculated. The sign of this value is used to determine which half of the interval does not contain a root. That half is discarded to give a new, smaller interval containing the root. This procedure can be continued indefinitely until the interval is sufficiently small.
At any time the current estimate of the root is taken as the midpoint of the interval.
sourcepub fn brent() -> RootFSolverType
pub fn brent() -> RootFSolverType
The false position algorithm is a method of finding roots based on linear interpolation. Its convergence is linear, but it is usually faster than bisection.
On each iteration a line is drawn between the endpoints (a, f (a)) and (b, f (b)) and the point where this line crosses the x-axis taken as a “midpoint”. The value of the function at this point is calculated and its sign is used to determine which side of the interval does not contain a root. That side is discarded to give a new, smaller interval containing the root. This procedure can be continued indefinitely until the interval is sufficiently small.
The best estimate of the root is taken from the linear interpolation of the interval on the current iteration.
sourcepub fn falsepos() -> RootFSolverType
pub fn falsepos() -> RootFSolverType
The Brent-Dekker method (referred to here as Brent’s method) combines an interpo- lation strategy with the bisection algorithm. This produces a fast algorithm which is still robust. On each iteration Brent’s method approximates the function using an interpolating curve. On the first iteration this is a linear interpolation of the two endpoints. For subsequent iterations the algorithm uses an inverse quadratic fit to the last three points, for higher accuracy. The intercept of the interpolating curve with the x-axis is taken as a guess for the root. If it lies within the bounds of the current interval then the interpolating point is accepted, and used to generate a smaller interval. If the interpolating point is not accepted then the algorithm falls back to an ordinary bisection step.
The best estimate of the root is taken from the most recent interpolation or bisection.
Trait Implementations
sourceimpl Clone for RootFSolverType
impl Clone for RootFSolverType
sourcefn clone(&self) -> RootFSolverType
fn clone(&self) -> RootFSolverType
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for RootFSolverType
Auto Trait Implementations
impl RefUnwindSafe for RootFSolverType
impl !Send for RootFSolverType
impl !Sync for RootFSolverType
impl Unpin for RootFSolverType
impl UnwindSafe for RootFSolverType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more