Skip to main content

newton_1d

Function newton_1d 

Source
pub fn newton_1d<T: Newton1d, E: From<GeopError>>(
    seed: T,
    (lo, hi): (T, T),
    steps: usize,
    arrive: Arrive,
    at: impl FnMut(T) -> Result<(T, T), E>,
) -> Result<(T, bool), E>
Expand description

Newton’s method on one unknown from seed, at most steps steps, within (lo, hi). at(x) gives the function’s value and slope at x. Every iterate is a sharp seed clamped into (lo, hi): what is returned is a point as good as any other where the function vanishes, not an enclosure of the root. seed itself is asked as it is.

The last seed, and whether it arrived as arrive says (always, for Arrive::Exhausted). A slope with no step — zero, or one that could be — is an error.