Skip to main content

newton

Function newton 

Source
pub fn newton<F>(
    f: F,
    a: f64,
    b: f64,
    start: f64,
    criteria: Criteria,
) -> OgeomResult<Solution>
where F: FnMut(f64) -> (f64, f64),
Expand description

Find a root of f near start, using its derivative, safeguarded by a bracket.

Takes a Newton step when that lands inside [a, b] and reduces the residual, and bisects otherwise. Plain Newton is not usable here: it diverges wherever the derivative is small, and small derivatives are precisely the tangential configurations a geometry kernel spends its time on.

f returns the value and the derivative together, since evaluating them separately usually repeats most of the work.

ยงErrors

OgeomError::Construction if the bracket is malformed or f does not change sign across it.