fix build and add test for newtons_method

This commit is contained in:
Simon Gardling
2022-05-18 14:52:03 -04:00
parent db68d5e23a
commit e7e82a72b2
4 changed files with 21 additions and 7 deletions

View File

@@ -162,3 +162,16 @@ fn to_points() {
assert_eq!(*data.get_series().get_values(), data_raw);
}
#[test]
fn newtons_method() {
use ytbn_graphing_software::newtons_method;
let data = newtons_method(
&|x: f64| x.powf(2.0) - 1.0,
&|x: f64| 2.0 * x,
&3.0,
&(0.0..10.0),
&f64::EPSILON,
);
assert_eq!(data, Some(1.0));
}