diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java index 498159293..956bf9ed7 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolver.java @@ -20,8 +20,8 @@ package org.apache.commons.math3.analysis.solvers; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.exception.MathInternalError; import org.apache.commons.math3.exception.NoBracketingException; -import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.exception.NumberIsTooLargeException; +import org.apache.commons.math3.exception.NumberIsTooSmallException; import org.apache.commons.math3.exception.TooManyEvaluationsException; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Precision; @@ -36,9 +36,8 @@ import org.apache.commons.math3.util.Precision; * to user specified {@link AllowedSolution}, *
+ * The given interval must bracket the root.
* */ public class BracketingNthOrderBrentSolver diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java index 0cc87501c..cf69410d4 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/BrentSolver.java @@ -18,8 +18,8 @@ package org.apache.commons.math3.analysis.solvers; import org.apache.commons.math3.exception.NoBracketingException; -import org.apache.commons.math3.exception.TooManyEvaluationsException; import org.apache.commons.math3.exception.NumberIsTooLargeException; +import org.apache.commons.math3.exception.TooManyEvaluationsException; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Precision; @@ -31,15 +31,14 @@ import org.apache.commons.math3.util.Precision; * in the given interval {@code [a, b]} to within a tolerance * {@code 2 eps abs(x) + t} where {@code eps} is the relative accuracy and * {@code t} is the absolute accuracy. - * The given interval must bracket the root. + *The given interval must bracket the root.
** The reference implementation is given in chapter 4 of *
- * Algorithms for Minimization Without Derivatives- * * * @see BaseAbstractUnivariateSolver */ @@ -138,8 +137,8 @@ public class BrentSolver extends AbstractUnivariateSolver { * This implementation is based on the algorithm described at page 58 of * the book *
- * Richard P. Brent
- * Dover, 2002
+ * Algorithms for Minimization Without Derivatives, + * Richard P. Brent, + * Dover, 2002 *
- * Algorithms for Minimization Without Derivatives - ** diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/FieldBracketingNthOrderBrentSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/FieldBracketingNthOrderBrentSolver.java index d3f4a2aea..f0ca8b93d 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/FieldBracketingNthOrderBrentSolver.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/FieldBracketingNthOrderBrentSolver.java @@ -36,12 +36,11 @@ import org.apache.commons.math3.util.Precision; * The changes with respect to the original Brent algorithm are: *Richard P. Brent + * Algorithms for Minimization Without Derivatives, + *Richard P. Brent , * Dover 0-486-41998-3 *
+ * The given interval must bracket the root.
* * @param- * A First Course in Numerical Analysis* Laguerre's method is global in the sense that it can start with any initial * approximation and be able to solve all roots from that point. @@ -136,7 +136,7 @@ public class LaguerreSolver extends AbstractPolynomialSolver { * Despite the bracketing condition, the root returned by * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may * not be a real zero inside {@code [min, max]}. - * For example,
- * ISBN 048641454X, chapter 8.
+ * A First Course in Numerical Analysis, + * ISBN 048641454X, chapter 8. *
p(x) = x3 + 1,
+ * For example, p(x) = x3 + 1,
* with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
* When it occurs, this code calls
* {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
@@ -176,8 +176,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
/**
* Find all complex roots for the polynomial with the given
* coefficients, starting from the given initial value.
- * + * Note: This method is not part of the API of {@link BaseUnivariateSolver}.
* * @param coefficients Polynomial coefficients. * @param initial Start value. @@ -200,8 +200,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver { /** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. - *+ * Note: This method is not part of the API of {@link BaseUnivariateSolver}.
* * @param coefficients polynomial coefficients * @param initial start value @@ -231,8 +231,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver { /** * Find a complex root for the polynomial with the given coefficients, * starting from the given initial value. - *+ * Note: This method is not part of the API of {@link BaseUnivariateSolver}.
* * @param coefficients Polynomial coefficients. * @param initial Start value. @@ -255,8 +255,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver { /** * Find a complex root for the polynomial with the given coefficients, * starting from the given initial value. - *+ * Note: This method is not part of the API of {@link BaseUnivariateSolver}.
* * @param coefficients polynomial coefficients * @param initial start value diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java index 06a7b6bb0..2e59ed42c 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver.java @@ -16,10 +16,10 @@ */ package org.apache.commons.math3.analysis.solvers; -import org.apache.commons.math3.util.FastMath; -import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.exception.NoBracketingException; +import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.exception.TooManyEvaluationsException; +import org.apache.commons.math3.util.FastMath; /** * This class implements the @@ -30,7 +30,7 @@ import org.apache.commons.math3.exception.TooManyEvaluationsException; * Muller's method applies to both real and complex functions, but here we * restrict ourselves to real functions. * This class differs from {@link MullerSolver} in the way it avoids complex - * operations. + * operations.* Muller's original method would have function evaluation at complex point. * Since our f(x) is real, we have to find ways to avoid that. Bracketing * condition is one way to go: by requiring bracketing in every iteration, diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java b/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java index 2a79c118b..864cfd59c 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/MullerSolver2.java @@ -30,15 +30,15 @@ import org.apache.commons.math3.util.FastMath; * Muller's method applies to both real and complex functions, but here we * restrict ourselves to real functions. * This class differs from {@link MullerSolver} in the way it avoids complex - * operations.
+ * operations.* Except for the initial [min, max], it does not require bracketing - * condition, e.g. f(x0), f(x1), f(x2) can have the same sign. If complex - * number arises in the computation, we simply use its modulus as real + * condition, e.g. f(x0), f(x1), f(x2) can have the same sign. If a complex + * number arises in the computation, we simply use its modulus as a real * approximation.
*- * Because the interval may not be bracketing, bisection alternative is + * Because the interval may not be bracketing, the bisection alternative is * not applicable here. However in practice our treatment usually works - * well, especially near real zeroes where the imaginary part of complex + * well, especially near real zeroes where the imaginary part of the complex * approximation is often negligible.
** The formulas here do not use divided differences directly.
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java b/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java index b1ecded3a..71b34c5f7 100644 --- a/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java +++ b/src/main/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtils.java @@ -81,8 +81,10 @@ public class UnivariateSolverUtils { return solver.solve(Integer.MAX_VALUE, function, x0, x1); } - /** Force a root found by a non-bracketing solver to lie on a specified side, - * as if the solver was a bracketing one. + /** + * Force a root found by a non-bracketing solver to lie on a specified side, + * as if the solver were a bracketing one. + * * @param maxEval maximal number of new evaluations of the function * (evaluations already done for finding the root should have already been subtracted * from this number) @@ -173,13 +175,13 @@ public class UnivariateSolverUtils { * This method simply calls {@link #bracket(UnivariateFunction, double, double, double, * double, double, int) bracket(function, initial, lowerBound, upperBound, q, r, maximumIterations)} * with {@code q} and {@code r} set to 1.0 and {@code maximumIterations} set to {@code Integer.MAX_VALUE}. - * Note: this method can take - *Integer.MAX_VALUE
iterations to throw a
- * ConvergenceException.
Unless you are confident that there
- * is a root between lowerBound
and upperBound
- * near initial,
it is better to use
- * {@link #bracket(UnivariateFunction, double, double, double, double,
- * double, int) bracket(function, initial, lowerBound, upperBound, q, r, maximumIterations)},
+ * + * Note: this method can take {@code Integer.MAX_VALUE} + * iterations to throw a {@code ConvergenceException.} Unless you are + * confident that there is a root between {@code lowerBound} and + * {@code upperBound} near {@code initial}, it is better to use + * {@link #bracket(UnivariateFunction, double, double, double, double,double, int) + * bracket(function, initial, lowerBound, upperBound, q, r, maximumIterations)}, * explicitly specifying the maximum number of iterations.
* * @param function Function. @@ -244,11 +246,11 @@ public class UnivariateSolverUtils { * The algorithm stops when one of the following happens:* If different signs are found at first iteration ({@code k=1}), then the returned * interval will be \( [a, b] = [l_1, u_1] \). If different signs are found at a later - * iteration ({code k>1}, then the returned interval will be either + * iteration {@code k>1}, then the returned interval will be either * \( [a, b] = [l_{k+1}, l_{k}] \) or \( [a, b] = [u_{k}, u_{k+1}] \). A root solver called * with these parameters will therefore start with the smallest bracketing interval known * at this step.