simplify newtons_method return logic
This commit is contained in:
parent
123c49a5d8
commit
a224ae7497
@ -88,14 +88,11 @@ pub fn newtons_method(
|
|||||||
|
|
||||||
// If below threshold, break
|
// If below threshold, break
|
||||||
if (x2 - x1).abs() < threshold {
|
if (x2 - x1).abs() < threshold {
|
||||||
break;
|
return Some(x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return x2 as loop breaks before x1 is set to x2
|
|
||||||
Some(x2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inputs `Vec<Option<T>>` and outputs a `String` containing a pretty representation of the Vector
|
/// Inputs `Vec<Option<T>>` and outputs a `String` containing a pretty representation of the Vector
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user