From 605dd5ae18ca9a5b6e0a5732dee21ce77e628e26 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 16 May 2022 09:22:37 -0400 Subject: [PATCH] fix jittering of roots/extrema --- src/misc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/misc.rs b/src/misc.rs index 751584e..bb47665 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -256,8 +256,8 @@ fn newtons_method( x1 = x2; } - // If failed, return NaN, which is then filtered out - return Some(x1); + // return x2 as loop breaks before x1 is set to x2 + return Some(x2); } /// Inputs `Vec>` and outputs a `String` containing a pretty representation of the Vector