From a224ae7497b5174e1f7e0c2e228d23705f5071fc Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 25 May 2022 12:30:46 -0400 Subject: [PATCH] simplify newtons_method return logic --- src/misc.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/misc.rs b/src/misc.rs index 807fe51..89d4596 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -88,14 +88,11 @@ pub fn newtons_method( // If below threshold, break if (x2 - x1).abs() < threshold { - break; + return Some(x2); } x1 = x2; } - - // return x2 as loop breaks before x1 is set to x2 - Some(x2) } /// Inputs `Vec>` and outputs a `String` containing a pretty representation of the Vector