Crates.io | rootfinder |
lib.rs | rootfinder |
version | 0.2.1 |
source | src |
created_at | 2024-11-03 00:03:12.568927 |
updated_at | 2024-12-08 20:16:18.173106 |
description | Root-finding methods for both univariate, scalar-valued functions and multivariate, vector-valued functions. |
homepage | |
repository | https://github.com/tamaskis/rootfinder |
max_upload_size | |
id | 1433268 |
size | 96,684 |
Root-finding methods for both univariate, scalar-valued functions and multivariate, vector-valued functions.
Please see https://docs.rs/rootfinder.
use rootfinder::{root_bisection, Interval};
// Define the function f(x) = x² - 1.
let f = |x: f64| x.powi(2) - 1.0;
// We want the root in the interval [0,∞). Therefore, we use an initial interval of
// [a,b] = [0,9999999]. Finding this root using the bisection method,
let result = root_bisection(&f, Interval::new(0.0, 9999999.0), None, None);
let root = result.unwrap();
// `root` is `0.9999999999999999`, which is very close to the true root of 1.