Expand description
nrfind is a crate for finding the roots of arbitrary functions whose derivatives
are known by the Newton-Rahpson method.
§Examples
Here, find_sqrt is used to approximate the square root of 25.1 to within
0.01, with a starting guess of 5, using at most 100 iterations of the NR
method.
use nrfind::find_sqrt;
match find_sqrt(25.1, 5.0, 0.01, 100) {
Ok(v) => println!("sqrt(25.1) ~= {} within 0.01", v),
Err(v) => println!("Could not find sqrt(25.1) within 0.01; closest guess was {}.", v),
}Functions§
- find_
root - Uses the Newton-Raphson method to find roots for
functiongiven thatderivativeis the first derivative offunction. Ifmax_iterationsis reached without the error falling below the givenacceptable_err,nrfindwill returnNone. - find_
sqrt - Find the square root of a given
radicandto within a givenacceptable_errby the Newton-Rahpson method, using the initial guessx0. If, aftermax_iterations, the error is not less than the giveacceptable_err,Noneis returned.
Type Aliases§
- Numeric
Solution Result - A
NumericSolutionResultis returned from the variousnrfindfunctions. AnOkvalue signifies a result that is within the given precision while anErrresult signifies a result that is not known to be sufficiently precise.