diff --git a/russell_lab/README.md b/russell_lab/README.md index 3aff616a..b05c2c04 100644 --- a/russell_lab/README.md +++ b/russell_lab/README.md @@ -482,7 +482,7 @@ Total computation time = 907ns ### Finding all roots in an interval -This example employs a Chebyshev interpolant to find all roots of a function in an interval. The method uses adaptive interpolation followed by calculating the eigenvalues of the companion matrix. These eigenvalues equal the roots of the polynomial. After that, a simple Newton polishing algorithm is applied. +This example employs a Chebyshev interpolant to find all roots of a function in an interval. The method uses adaptive interpolation followed by calculating the eigenvalues of the companion matrix. These eigenvalues equal the roots of the polynomial. After that, a simple Newton refining (polishing) algorithm is applied. [See the code](https://github.com/cpmech/russell/tree/main/russell_lab/examples/algo_multi_root_solver_cheby.rs) diff --git a/russell_lab/examples/algo_multi_root_solver_cheby.rs b/russell_lab/examples/algo_multi_root_solver_cheby.rs index ecd0d60f..f58b1ceb 100644 --- a/russell_lab/examples/algo_multi_root_solver_cheby.rs +++ b/russell_lab/examples/algo_multi_root_solver_cheby.rs @@ -23,7 +23,7 @@ fn main() -> Result<(), StrError> { println!("roots =\n{}", roots); println!("f @ roots =\n{}", vec_fmt_scientific(&f_at_roots, 2)); - // polish the roots + // refine/polish the roots let mut roots_refined = roots.clone(); solver.refine(roots_refined.as_mut_data(), xa, xb, args, f)?; let f_at_roots_refined = roots_refined.get_mapped(|x| f(x, args).unwrap()); diff --git a/russell_lab/src/algo/root_finding.rs b/russell_lab/src/algo/root_finding.rs index c75677c7..87a28994 100644 --- a/russell_lab/src/algo/root_finding.rs +++ b/russell_lab/src/algo/root_finding.rs @@ -53,7 +53,7 @@ pub struct RootFinding { /// Default = 1e-13 pub newton_tol_zero_fx: f64, - /// Holds the maximum number of iterations for the Newton polishing + /// Holds the maximum number of iterations for the Newton refinement/polishing /// /// Default = 15 pub newton_max_iterations: usize, @@ -218,8 +218,8 @@ impl RootFinding { /// let mut roots = solver.chebyshev(&interp)?; /// array_approx_eq(&roots, &[-0.5, 0.5], 1e-15); // inaccurate /// - /// // polish the roots - /// solver.polish_roots_newton(&mut roots, xa, xb, args, f)?; + /// // refine/polish the roots + /// solver.refine(&mut roots, xa, xb, args, f)?; /// array_approx_eq(&roots, &[-1.0, 1.0], 1e-15); // accurate /// Ok(()) /// } @@ -428,7 +428,7 @@ mod tests { } #[test] - fn polish_roots_newton_captures_errors() { + fn refine_captures_errors() { let f = |_, _: &mut NoArgs| Ok(0.0); let args = &mut 0; let _ = f(0.0, args); @@ -448,7 +448,7 @@ mod tests { } #[test] - fn polish_roots_newton_works() { + fn refine_works() { // function let f = |x, _: &mut NoArgs| Ok(x * x * x * x - 1.0); let (xa, xb) = (-2.0, 2.0); @@ -471,7 +471,7 @@ mod tests { // figure /* graph( - "test_polish_roots_newton", + "test_root_finding_refine", &interp, &roots, &roots_refined,