Crates.io | generic-newton |
lib.rs | generic-newton |
version | 0.1.1 |
source | src |
created_at | 2020-08-09 11:00:52.815091 |
updated_at | 2020-10-08 13:43:17.069111 |
description | Simple generic Newton method. |
homepage | https://github.com/vigoux/newton |
repository | https://github.com/vigoux/newton |
max_upload_size | |
id | 274606 |
size | 5,323 |
A dead-simple, dependency-free Rust crate for generic Newton method.
Everything is contained in the Newton
iterator :
use newton::Newton;
fn main() {
let mut n = Newton::<f64>::new(
0.5, // Initial guess
|x| x.cos() - x.powi(3), // The actual function
|x| -(x.sin() + 3. * x.powi(2)), // Its derivative
);
assert!(n.nth(1000).unwrap() - 0.865474033102 < 1E-11)
}