newtons_method: return None for Infinates and NaNs
This commit is contained in:
parent
605dd5ae18
commit
de2a24e469
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user