// Apply one scalar Newton update to a root estimate with a caller-supplied derivative. Preserve the estimate for a zero derivative. pub fn newton_step(estimate: f64, residual: f64, derivative: f64) -> f64 { if derivative == 0.0 { return estimate; } estimate-residual/derivative }