newtons_method: return None for Infinates and NaNs
This commit is contained in:
@@ -244,7 +244,7 @@ fn newtons_method(
|
|||||||
let mut x2: f64;
|
let mut x2: f64;
|
||||||
loop {
|
loop {
|
||||||
x2 = x1 - (f(x1) / f_1(x1));
|
x2 = x1 - (f(x1) / f_1(x1));
|
||||||
if !range.contains(&x2) {
|
if !x2.is_finite() | !range.contains(&x2) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user