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
function
given thatderivative
is the first derivative offunction
. Ifmax_iterations
is reached without the error falling below the givenacceptable_err
,nrfind
will returnNone
. - find_
sqrt - Find the square root of a given
radicand
to within a givenacceptable_err
by the Newton-Rahpson method, using the initial guessx0
. If, aftermax_iterations
, the error is not less than the giveacceptable_err
,None
is returned.
Type Aliases§
- Numeric
Solution Result - A
NumericSolutionResult
is returned from the variousnrfind
functions. AnOk
value signifies a result that is within the given precision while anErr
result signifies a result that is not known to be sufficiently precise.