Skip to main content

newton_system

Function newton_system 

Source
pub fn newton_system<F>(
    f: F,
    start: &[f64],
    criteria: Criteria,
) -> OgeomResult<SystemSolution>
where F: FnMut(&[f64]) -> (Vec<f64>, Vec<Vec<f64>>),
Expand description

Solve f(x) = 0 for a vector x, by damped Newton.

f returns the residual vector and the Jacobian, row-major. The step is halved until it actually reduces the residual; undamped Newton overshoots badly from a poor start, and a geometry caller’s start is often only a rough guess from a coarse sampling.

Surface projection is this with two equations in two unknowns; so is a step of a surface/surface intersection march.

Where no root exists the residual has a positive minimum, and no damping finds a downhill step from it. That is reported as Convergence::Exhausted with the best estimate attached; “no root here” is a useful answer, and far better than iterating to the limit.

§Errors

OgeomError::Dimension if the Jacobian’s shape disagrees with the residual, and OgeomError::Numeric if the Jacobian is singular at the starting point.