This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit 765afd0beccaa420db537ce1c0bf668c8fb913fc Author: aherbert <[email protected]> AuthorDate: Thu Dec 16 16:34:00 2021 +0000 Remove redundant variable assignment Use e directly and update to d in the condition that accepts the interpolation. The condition that rejects interpolation updates e anyway. --- .../java/org/apache/commons/numbers/rootfinder/BrentSolver.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java index ad80fa5..13a5bbc 100644 --- a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java +++ b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java @@ -193,7 +193,7 @@ public class BrentSolver { d = m; e = d; } else { - double s = fb / fa; + final double s = fb / fa; double p; double q; // The equality test (a == c) is intentional, @@ -215,16 +215,15 @@ public class BrentSolver { } else { p = -p; } - s = e; - e = d; if (p >= 1.5 * m * q - Math.abs(tol * q) || - p >= Math.abs(0.5 * s * q)) { + p >= Math.abs(0.5 * e * q)) { // Inverse quadratic interpolation gives a value // in the wrong direction, or progress is slow. // Fall back to bisection. d = m; e = d; } else { + e = d; d = p / q; } }
